The easy way would be something like
Code:
typedef std::map<std::string, std::string> valmap_t;
typedef valmap_t::iterator valmap_it;
bool parse(std::istream &is, valmap &m) {
std::string name, value;
while(std::getline(is,name,'=') && std::getline(is,value,';') m[name] = value;
return is.eof();
}
...
std::ifstream is("datafile.txt");
valmap_t values;
if(parse(is,values)) {
valmap_it it=values.find("v");
if(it != values.end()) std::cout << "v is " << it->second();
else std::cout << "v is undefined";
std::cout << std::endl;
} else {
std::cerr << "parse error" << std::endl;
}
This could then be used with an ifstream from a file, or any other type of stream. The only problem you might have is that both name and value will include all whitespace, plus values will be case sensitive. Thus before you add a name to the map you may want to normalize it(trim leading and trailing whitespace and convert to lowercase).