Skip to content

Instantly share code, notes, and snippets.

@thiagomg
Created February 4, 2016 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagomg/1565db90a7cfa3c6d074 to your computer and use it in GitHub Desktop.
Save thiagomg/1565db90a7cfa3c6d074 to your computer and use it in GitHub Desktop.
Leitura de configuração em C++
template<typename Key, typename Value, typename AdderFunc>
void crack(config_holder<Key, Value> &config, const std::string &line, char delim, AdderFunc f) {
auto b = std::begin(line);
auto e = std::end(line);
auto pos = line.find(delim);
if( pos != std::string::npos ) {
f(config, b, b+pos, e);
}
}
//nossa AdderFunc
void default_adder(
config_holder<std::string, std::string> &config,
iter_type b, iter_type m, iter_type e) {
//b-m => key / m+1-e => value
config.add_item( b, m, m+1, e );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment