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?

Here’s how I’d do it:

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?

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