30 template<
class StringType,
class UnaryPredicate>
33 const StringType& str,
34 const UnaryPredicate& meta,
38 if (str.empty() || !quote)
44 result.reserve(1.5*str.size());
47 for (
const char c : str)
64 result.shrink_to_fit();
69 template<
class StringType,
class UnaryPredicate>
72 const std::string& str,
73 const UnaryPredicate& accept,
78 out.resize(str.length());
84 const char c = str[i];
96 template<
class StringType>
99 const StringType& str,
110 || (
pos == std::string::npos ||
pos >= str.size())
119 while ((
end = str.find(delim,
pos)) != std::string::npos)
121 if (keepEmpty || (
pos <
end))
129 if (keepEmpty ? (
pos <= str.size()) : (
pos < str.size()))
131 list.
append(str.cbegin() +
pos, str.cend());
138 template<
class StringType>
141 const StringType& str,
142 const std::string& delim,
152 || (
pos == std::string::npos ||
pos >= str.size())
161 while ((
end = str.find(delim,
pos)) != std::string::npos)
163 if (keepEmpty || (
pos <
end))
171 if (keepEmpty ? (
pos <= str.size()) : (
pos < str.size()))
173 list.
append(str.cbegin() +
pos, str.cend());
180 template<
class StringType>
183 const StringType& str,
184 const std::string& delim,
193 || (
pos == std::string::npos ||
pos >= str.size())
201 while ((
pos = str.find_first_not_of(delim,
pos)) != std::string::npos)
203 const auto end = str.find_first_of(delim,
pos);
205 if (
end == std::string::npos)
208 list.
append(str.cbegin() +
pos, str.cend());
222 template<
class StringType>
225 const StringType& str,
235 || (
pos == std::string::npos ||
pos >= str.size())
241 list.reserve(1 + ((str.size() -
pos) / width));
243 const auto len = str.size();
247 const auto end = (
pos + width);
252 list.
append(str.cbegin() +
pos, str.cend());
266 template<
class StringType>
269 const StringType& str,
Foam::SubStrings< StringType > split(const StringType &str, const char delim, std::string::size_type pos=0, const bool keepEmpty=false)
Split string into sub-strings at the delimiter character.
Foam::SubStrings< StringType > splitFixed(const StringType &str, const std::string::size_type width, std::string::size_type pos=0)
Split string into sub-strings using a fixed field width.
Sub-ranges of a string with a structure similar to std::match_results, but without the underlying reg...
Foam::SubStrings< StringType > splitAny(const StringType &str, const std::string &delim, std::string::size_type pos=0)
Split string into sub-strings using any characters in delimiter.
StringType quotemeta(const StringType &str, const UnaryPredicate &meta, const char quote='\\')
Quote any meta-characters in given string.
StringType validate(const std::string &str, const UnaryPredicate &accept, const bool invert=false)
Return a copy of the input string with validated characters.
dimensionedScalar pos(const dimensionedScalar &ds)
graph_traits< Graph >::vertices_size_type size_type
void append(const typename StringType::const_iterator &b, const typename StringType::const_iterator &e)
Append sub-string defined by begin/end iterators.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
const dimensionedScalar c
Speed of light in a vacuum.
Foam::SubStrings< StringType > splitSpace(const StringType &str, std::string::size_type pos=0)
Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC)