Results 1 to 3 of 3

Thread: float_array C parse

  1. #1

    float_array C parse

    Ok, imagine I don't wanna use the Collada DOM c++ api... Any ideas about how to parse mesh "float array" returned as a string like:

    "-4.18 89.2220 1.192 -7.91"

    fast and without using tokenize?

    Currently I iterate over all the characters in the string and sscanf the numbers between two spaces... but is slow... any other ideas pls?

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Foster City, CA
    Here's how I'd do it:
    Code :
    int numValues = 4;
    string data; // Let's say this has your ascii float data
    istringstream iss(data);
    vector<float> values(numValues, 0.0f);
    for (int i = 0; i < numValues; i++)
        iss >> values[i];
    If you don't like the C++ I could show you the C-way of doing it, but it might be the same as what you're doing now. Can you post your code?

  3. #3
    Senior Member
    Join Date
    Apr 2005
    Feeling Software, Montreal, Quebec
    We have some code to do this, in ColladaMaya, because we found that using the STDC function was too slow, because of the locale handling.

    Check out the FUStringConversion::ToFloat function in FUtils/FUStringConversion.cpp

    Guillaume Laforte
    Feeling Software Inc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean