41#ifndef Foam_stringOps_H
42#define Foam_stringOps_H
60template<
class T1,
class T2>
class Tuple2;
70 std::string::size_type
count(
const char*
s,
const char c);
73 std::string::size_type
count(
const std::string&
s,
const char c);
82 template<
class StringType,
class UnaryPredicate>
85 const StringType& str,
86 const UnaryPredicate& meta,
87 const char quote =
'\\'
98 const char sigil =
'$'
140 const char sigil =
'$'
212 const bool allowEmpty,
213 const bool allowSubDict =
false,
214 const char sigil =
'$'
226 const std::string&
s,
228 const char sigil =
'$'
250 const char sigil =
'$'
259 string expand(
const std::string&
s,
const bool allowEmpty =
false);
277 void inplaceExpand(std::string&
s,
const bool allowEmpty =
false);
287 template<
class StringType,
class UnaryPredicate>
290 const std::string& str,
291 const UnaryPredicate& accept,
297 std::pair<size_t, size_t>
300 const std::string&
s,
302 size_t len = std::string::npos
318 string trim(
const std::string&
s);
335 string lower(
const std::string&
s);
341 string upper(
const std::string&
s);
366 const std::string& str,
377 const std::string& str,
381 std::string::size_type
pos = 0,
383 const bool keepEmpty =
false
391 const std::string& str,
393 const std::string& delim,
395 std::string::size_type
pos = 0,
397 const bool keepEmpty =
false
406 const std::string& str,
408 const std::string& delim,
410 std::string::size_type
pos = 0
418 const std::string& str,
420 const std::string::size_type width,
422 std::string::size_type
pos = 0
430 const std::string& str,
432 std::string::size_type
pos = 0
442 const std::string& str,
444 const std::string::size_type width,
446 const std::string::size_type
indent = 0,
448 const bool escape =
false
460 #include "stringOps.txx"
A HashTable similar to std::unordered_map.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Generic output stream using a standard (STL) stream.
Sub-ranges of a string with a structure similar to std::match_results, but without the underlying reg...
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A List of wordRe with additional matching capabilities.
static bool match(const UList< wordRe > &selectors, const std::string &text, bool literal=false)
Test for a match of any selectors against the text.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Collection of static functions for various string-related operations.
label splitFunctionArgs(const std::string &str, wordRes &args, List< Tuple2< word, string > > &namedArgs)
Split out arguments (named or unnamed) from an input string.
StringType quotemeta(const StringType &str, const UnaryPredicate &meta, const char quote='\\')
Quote any meta-characters in given string.
void inplaceLower(std::string &s)
Inplace transform string with std::tolower on each character.
string trim(const std::string &s)
Return string trimmed of leading and trailing whitespace.
Foam::SubStrings split(const std::string &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 splitSpace(const std::string &str, std::string::size_type pos=0)
Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC).
string removeComments(const std::string &s)
Return string with C/C++ comments removed.
void inplaceRemoveComments(std::string &s)
Remove C/C++ comments inplace.
string trimRight(const std::string &s)
Return string trimmed of trailing whitespace.
bool inplaceReplaceVar(std::string &s, const word &varName)
Replace environment variable contents with its name.
void writeWrapped(OSstream &os, const std::string &str, const std::string::size_type width, const std::string::size_type indent=0, const bool escape=false)
Output string with text wrapping.
string trimLeft(const std::string &s)
Return string trimmed of leading whitespace.
void inplaceUpper(std::string &s)
Inplace transform string with std::toupper on each character.
StringType validate(const std::string &str, const UnaryPredicate &accept, const bool invert=false)
Return a copy of the input string with validated characters.
bool match(const UList< wordRe > &selectors, const std::string &text)
True if text matches one of the selector expressions.
std::pair< size_t, size_t > findTrim(const std::string &s, size_t pos=0, size_t len=std::string::npos)
Find (first, last) non-space locations in string or sub-string.
void inplaceExpand(std::string &s, const HashTable< string > &mapping, const char sigil='$')
Inplace expand occurrences of variables according to the mapping. Does not use environment values.
void inplaceTrimLeft(std::string &s)
Trim leading whitespace inplace.
string expand(const std::string &s, const HashTable< string > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping and return the expanded string.
Foam::SubStrings splitAny(const std::string &str, const std::string &delim, std::string::size_type pos=0)
Split string into sub-strings using any characters in delimiter.
void inplaceTrim(std::string &s)
Trim leading and trailing whitespace inplace.
std::string::size_type count(const char *s, const char c)
Count the number of occurrences of the specified character.
Foam::SubStrings splitFixed(const std::string &str, const std::string::size_type width, std::string::size_type pos=0)
Split string into sub-strings using a fixed field width.
void inplaceTrimRight(std::string &s)
Trim trailing whitespace inplace.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
void inplaceRemoveSpace(std::string &s)
Eliminate whitespace inplace.
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
dimensionedScalar pos(const dimensionedScalar &ds)
Ostream & indent(Ostream &os)
Indent stream.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
Foam::argList args(argc, argv)
String expression evaluation.
Specialized string sorting.