Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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