14 #ifndef ESYS_LSMSTRINGUTIL_H
15 #define ESYS_LSMSTRINGUTIL_H
32 template <
class TmplIterator>
38 std::stringstream sStream;
45 template<
class TmplIterator,
class TmplStringOperator>
50 const std::string &delim,
56 TmplIterator it = begin;
57 str = toStringOp(begin);
58 for (it++; it != end; it++)
60 str += delim + toStringOp(it);
66 template<
class TmplContainer,
class TmplStringOperator>
69 const TmplContainer &container,
70 const std::string &delim,
73 typename TmplContainer::const_iterator it = container.begin();
74 typename TmplContainer::const_iterator end = container.end();
79 for (it++; it != end; it++)
81 str += delim + toStringOp(it);
90 const std::string &delim
93 StringVector::const_iterator it = container.begin();
94 StringVector::const_iterator end = container.end();
99 for (it++; it != end; it++)
107 template <
class TmplData>
113 std::stringstream sStream(str);
121 template <
typename TmplData>
122 TmplData
to(
const std::string &str)
127 template <
typename TmplData>
130 std::stringstream sStream;
132 return sStream.str();
135 template<
class TmplData,
class TmplStdStreamOp>
138 const std::string &str,
139 const std::string &delim,
143 std::vector<TmplData> vec;
144 std::string::size_type prevPos = 0;
145 std::string::size_type currPos = str.find(delim);
146 while (currPos != std::string::npos)
149 fromStringOp(str.substr(prevPos, currPos - prevPos))
151 prevPos = currPos + delim.length();
152 currPos = str.find(delim, prevPos);
154 if (prevPos < str.length())
157 fromStringOp(str.substr(prevPos, str.length()))
160 else if (prevPos == str.length())
162 vec.push_back(fromStringOp(
""));
175 std::string
trim(
const std::string &str)
178 for (; (b < str.size()) && std::isspace(str.at(b)); b++)
187 for (; (e > b) && std::isspace(str.at(e)); e--)
192 return ((e >= b) ? str.substr(b, e-b+1) :
"");