void main() { int a[100] = {2,1,1,1,3,4,4,4,5,5,5,5}, n=12, M=2, i; reGroup(a, n, M); for(i=0 ; i<n ; i++) printf("%d, ", a[i]); printf("\n"); }
ConfigFile CConfig::Read(string filename) { ifstream fs(filename.c_str()); ConfigFile ret; string group; boost::match_results<string::const_iterator> what; boost::regex reGroup("^\\[(.+)\\]"); boost::regex reProperty("^(\\S+)\\s*=\\s*\"?([^\"]+)\"?"); string line; while (getline(fs, line)) { if (line[0] == '[' && boost::regex_match(line, what, reGroup)) { string name = string(what[1].first, what[1].second); group = name; ret[group]; continue; } if (boost::regex_match(line, what, reProperty)) { string name = string(what[1].first, what[1].second); string value = string(what[2].first, what[2].second); ret[group][name] = SConfigValue(value); } } return ret; }