text-file lesen
-
hallo leute ich hoffe mir kann jemand helfen !! ich verzweifle gerade an einem ascii parser:
und zwar m öchte ich gerne von einem txt file folgende zeile einlesen:
"SYSTEMSIZE 70 30 25"ich habe das schon geschafft für ein keyword mit nur einem wert:
"SCENEUPDATEINT 54"z.B.:
int vfrConfigParser::getSceneUpdInt(int &sceneUpdInt) { //is already a file read? int size = lineMap.size(); typedef multimap<string,vector<string> >::iterator mapIt; mapIt first; //used to point on the first object with a certain key mapIt last; //used to point on the first object without that certain key pair<mapIt,mapIt> it_pair; // lineMap; //liegt vor als Klassenmember int count = lineMap.count("SCENEUPDATEINT"); if(count==0) { return -1; } if(count>1) { return -2; } first = lineMap.find("SCENEUPDATEINT"); if(first->second.size()==1) { sceneUpdInt = atoi(first->second[0].c_str()); } else { return -3; } printf("\n SCENEUPDATEINT= \t %d \n", sceneUpdInt); return 1; }
wie kann ich das für mein problem umändern????
in meinem main.cpp und in der headerdatei vfrParser.h
habe ich folgendes stehenint size [3]; myParser.getSystemsize (size [3]);
(funktioniert nicht)
class vfrConfigParser : public asciiParser { public: vfrConfigParser(); vfrConfigParser(string path); int getSystemsize(int size [3]); };
kann mir jemand helfen????
vielen dank ciao Daniel
-
Such mal im Forum nach. Irgenwann wurde mal eine explode-Funktion (ähnlich wie in Perl) für std::string gepostet