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); | |
} | |
} |
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
std::ifstream istr; | |
istr.open(file_name); | |
while( istr.good() ) { | |
std::string line; | |
std::getline(istr, line); | |
std::cout << line << std::endl; | |
} |
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 = std::string, typename Value = std::string, typename Store = std::unordered_map<Key, Value>> | |
struct config_holder { | |
using key_iter = typename Key::const_iterator; | |
using val_iter = typename Value::const_iterator; | |
using key_pair = std::pair<key_iter, key_iter>; | |
using val_pair = std::pair<val_iter, val_iter>; | |
using range = std::pair<key_pair, val_pair>; | |
using map_value = typename Store::value_type; | |
}; |
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 T> | |
T get_numeric(const T &input) | |
{ | |
T output; | |
std::copy_if(begin(input), end(input), std::back_inserter(output), [](auto c) { | |
return ( c >= '0' && c <= '9' ); | |
}); | |
return output; | |
} |
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 T> | |
T get_numeric(const T &input) | |
{ | |
T output; | |
std::for_each(begin(input), end(input), [&output](auto c) { | |
if( c >= '0' && c <= '9' ) output.push_back(c); | |
}); | |
return output; | |
} |
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
std::string get_numeric(const std::string &input) | |
{ | |
std::string output; | |
std::for_each(begin(input), end(input), [&output](const char c) { | |
if( c >= '0' && c <= '9' ) output.push_back(c); | |
}); | |
return output; | |
} |
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<class OutputIterator, class ValueType> | |
struct numerical_appender { | |
numerical_appender(OutputIterator it) : _it(it) { } | |
void operator()(const ValueType c) { | |
if( c >= '0' && c <= '9' ) { | |
*_it = c; | |
_it++; | |
} | |
} | |
private: |
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
struct numerical_appender { | |
numerical_appender(std::string &buf) : _buf(buf) { } | |
void operator()(const char c) { | |
if( c >= '0' && c <= '9' ) _buf.push_back(c); | |
} | |
private: | |
std::string &_buf; | |
}; | |
void get_numeric(const std::string &input, std::string &output) |
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
//16B | |
struct message { | |
int x; //4B | |
int y; //4B | |
int z; //4B | |
int w; //4B | |
}; | |
//16B | |
struct pack1 { |
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
class router { | |
message m1; | |
message *m2 | |
message &m3; | |
} |