Index: /trunk/libffado/src/genericavc/avc_vendormodel.cpp =================================================================== --- /trunk/libffado/src/genericavc/avc_vendormodel.cpp (revision 557) +++ /trunk/libffado/src/genericavc/avc_vendormodel.cpp (revision 558) @@ -27,11 +27,31 @@ #include #include +#include + +using namespace std; + +static void +tokenize(const string& str, + vector& tokens, + const string& delimiters = " ") +{ + // Skip delimiters at beginning. + string::size_type lastPos = str.find_first_not_of(delimiters, 0); + // Find first "non-delimiter". + string::size_type pos = str.find_first_of(delimiters, lastPos); + + while (string::npos != pos || string::npos != lastPos) + { + // Found a token, add it to the vector. + tokens.push_back(str.substr(lastPos, pos - lastPos)); + // Skip delimiters. Note the "not_of" + lastPos = str.find_first_not_of(delimiters, pos); + // Find next "non-delimiter" + pos = str.find_first_of(delimiters, lastPos); + } +} GenericAVC::VendorModel::VendorModel( const char* filename ) { - using namespace std; - - cout << "XXX GenericAVC::VendorModel::VendorModel" << endl; - ifstream in ( filename ); @@ -41,8 +61,28 @@ } + cout << "vendorId\t\tmodelId\t\tvendorName\t\tmodelName" << endl; string line; while ( !getline( in, line ).eof() ) { + string::size_type i = line.find_first_not_of( " \t\n\v" ); + if ( i != string::npos && line[i] == '#' ) + continue; + vector tokens; + tokenize( line, tokens, "," ); + for ( vector::iterator it = tokens.begin(); + it != tokens.end(); + ++it ) + { + string vendorId = *it++; + string modelId = *it++; + string vendorName = *it++; + string modelName= *it; + cout << vendorId << "\t" << modelId << "\t" <