| 1 | #include <boost/tokenizer.hpp> | 
|---|
| 2 | #include <iostream> | 
|---|
| 3 | #include <sstream> | 
|---|
| 4 |  | 
|---|
| 5 | int main() { | 
|---|
| 6 | std::ostringstream tmp; | 
|---|
| 7 |  | 
|---|
| 8 | // does not work | 
|---|
| 9 | tmp << "McStructuredLoanEngine::calculate() trace information\n"; | 
|---|
| 10 |  | 
|---|
| 11 | // works | 
|---|
| 12 | // tmp << "McStructuredLoanEngine::calculate() trace " | 
|---|
| 13 | //        "information\nMcStructuredLoanEngine::calculate() trace " | 
|---|
| 14 | //        "information\n"; | 
|---|
| 15 |  | 
|---|
| 16 | // works | 
|---|
| 17 | // tmp << "A shorter test string\n"; | 
|---|
| 18 |  | 
|---|
| 19 | boost::char_separator<char> sep("\n", "", boost::drop_empty_tokens); | 
|---|
| 20 | boost::tokenizer<boost::char_separator<char> > t(tmp.str(), sep); | 
|---|
| 21 | for (boost::tokenizer<boost::char_separator<char> >::const_iterator it = | 
|---|
| 22 | t.begin(); | 
|---|
| 23 | it != t.end(); ++it) { | 
|---|
| 24 | std::string s = *it; | 
|---|
| 25 | std::cout << "TokenStartsHere:" << s << ":TokenEndsHere / length of string is " << it->length() << std::endl; | 
|---|
| 26 | } | 
|---|
| 27 | } | 
|---|