Created
February 4, 2016 22:20
-
-
Save thiagomg/1565db90a7cfa3c6d074 to your computer and use it in GitHub Desktop.
Leitura de configuração em C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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