123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #ifndef BOOST_STRINGTOK_HPP
- #define BOOST_STRINGTOK_HPP
- #include <string>
- #include <cstring> // for strchr
- inline bool isws(char c, char const* const wstr)
- {
- using namespace std;
- return (strchr(wstr, c) != NULL);
- }
- namespace boost
- {
- template < typename Container >
- void stringtok(
- Container& l, std::string const& s, char const* const ws = " \t\n")
- {
- typedef std::string::size_type size_type;
- const size_type S = s.size();
- size_type i = 0;
- while (i < S)
- {
-
- while ((i < S) && (isws(s[i], ws)))
- ++i;
- if (i == S)
- return;
-
- size_type j = i + 1;
- while ((j < S) && (!isws(s[j], ws)))
- ++j;
-
- l.push_back(s.substr(i, j - i));
-
- i = j + 1;
- }
- }
- }
- #endif
|