Changeset 558
- Timestamp:
- 08/24/07 01:33:45 (16 years ago)
- Files:
-
- trunk/libffado/src/genericavc/avc_vendormodel.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/genericavc/avc_vendormodel.cpp
r557 r558 27 27 #include <istream> 28 28 #include <iostream> 29 #include <iterator> 30 31 using namespace std; 32 33 static void 34 tokenize(const string& str, 35 vector<string>& tokens, 36 const string& delimiters = " ") 37 { 38 // Skip delimiters at beginning. 39 string::size_type lastPos = str.find_first_not_of(delimiters, 0); 40 // Find first "non-delimiter". 41 string::size_type pos = str.find_first_of(delimiters, lastPos); 42 43 while (string::npos != pos || string::npos != lastPos) 44 { 45 // Found a token, add it to the vector. 46 tokens.push_back(str.substr(lastPos, pos - lastPos)); 47 // Skip delimiters. Note the "not_of" 48 lastPos = str.find_first_not_of(delimiters, pos); 49 // Find next "non-delimiter" 50 pos = str.find_first_of(delimiters, lastPos); 51 } 52 } 29 53 30 54 GenericAVC::VendorModel::VendorModel( const char* filename ) 31 55 { 32 using namespace std;33 34 cout << "XXX GenericAVC::VendorModel::VendorModel" << endl;35 36 56 ifstream in ( filename ); 37 57 … … 41 61 } 42 62 63 cout << "vendorId\t\tmodelId\t\tvendorName\t\tmodelName" << endl; 43 64 string line; 44 65 while ( !getline( in, line ).eof() ) { 66 string::size_type i = line.find_first_not_of( " \t\n\v" ); 67 if ( i != string::npos && line[i] == '#' ) 68 continue; 45 69 70 vector<string> tokens; 71 tokenize( line, tokens, "," ); 46 72 73 for ( vector<string>::iterator it = tokens.begin(); 74 it != tokens.end(); 75 ++it ) 76 { 77 string vendorId = *it++; 78 string modelId = *it++; 79 string vendorName = *it++; 80 string modelName= *it; 81 cout << vendorId << "\t" << modelId << "\t" <<vendorName << "\t" << modelName << endl; 82 } 83 } 84 85 if ( !in.eof() ) { 86 cout << "GenericAVC::VendorModel::VendorModel: error in parsing" << endl; 47 87 } 48 88 }