diff options
author | Clyne Sullivan <clyne@clyne-lp.lan> | 2021-08-08 22:02:52 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@clyne-lp.lan> | 2021-08-08 22:02:52 -0400 |
commit | 707b24dd07236243269cf092728f85172e94e8a4 (patch) | |
tree | c136716a5fc9ed9cbf570e24f8f6ab715adc73a2 /source/serial/tests/proof_of_concepts/tokenizer.cc |
initial commit
Diffstat (limited to 'source/serial/tests/proof_of_concepts/tokenizer.cc')
-rw-r--r-- | source/serial/tests/proof_of_concepts/tokenizer.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source/serial/tests/proof_of_concepts/tokenizer.cc b/source/serial/tests/proof_of_concepts/tokenizer.cc new file mode 100644 index 0000000..da15a09 --- /dev/null +++ b/source/serial/tests/proof_of_concepts/tokenizer.cc @@ -0,0 +1,31 @@ +#include <iostream> +#include <string> +#include <vector> + +#include <boost/bind.hpp> +#include <boost/function.hpp> +#include <boost/algorithm/string.hpp> +#include <boost/foreach.hpp> + +void +_delimeter_tokenizer (std::string &data, std::vector<std::string> &tokens, + std::string delimeter) +{ + boost::split(tokens, data, boost::is_any_of(delimeter)); +} + +typedef boost::function<void(std::string&,std::vector<std::string>&)> TokenizerType; + +int main(void) { + std::string data = "a\rb\rc\r"; + std::vector<std::string> tokens; + std::string delimeter = "\r"; + + TokenizerType f = boost::bind(_delimeter_tokenizer, _1, _2, delimeter); + f(data, tokens); + + BOOST_FOREACH(std::string token, tokens) + std::cout << token << std::endl; + + return 0; +}
\ No newline at end of file |