72template<
class T>
struct Hash;
88 inline static std::string::size_type
find_ext(
const std::string& str);
92 inline std::string::size_type
find_ext()
const;
95 template<
class PrimitiveType>
100 const PrimitiveType& val
104 template<
class PrimitiveType>
108 const std::string& fmt,
109 const PrimitiveType& val
127 inline bool has_ext(
const char* ending)
const;
130 inline bool has_ext(
const std::string& ending)
const;
149 unsigned operator()(
const std::string& str,
unsigned seed=0)
const
169 static const string null;
178 inline string(
const std::string& str);
181 inline string(std::string&& str);
184 inline string(
const char* str);
190 inline explicit string(
const char c);
202 using std::string::length;
205 static inline std::string::size_type
length(
const char*
s)
207 return (
s ? strlen(
s) : 0);
211 static inline std::string::size_type
length(
const std::string&
s)
217 template<
class StringType>
218 static inline bool valid(
const std::string& str);
221 template<
class StringType>
225 template<
class StringType>
226 static inline StringType
validate(
const std::string& str);
233 inline bool match(
const std::string& text)
const;
236 using std::string::replace;
242 const std::string& s1,
243 const std::string& s2,
252 const std::string& s1,
253 const std::string& s2,
262 const std::string& s1,
273 string&
expand(
const bool allowEmpty =
false);
299 inline void swap(std::string& str);
306 inline bool operator()(
const std::string& text)
const;
312 bool contains(
char c)
const noexcept
314 return (find(c) != std::string::npos);
318 bool contains(
const std::string&
s)
const noexcept
320 return (find(
s) != std::string::npos);
326 return (find(
s) != std::string::npos);
332 return (!empty() && front() == c);
338 return (size() >=
s.size() && !compare(0,
s.size(),
s));
344 const auto len = strlen(
s);
345 return (size() >= len && !compare(0, len,
s, len));
351 return (!empty() && back() == c);
357 return (size() >=
s.size() && !compare(size()-
s.size(), npos,
s));
363 const auto len = strlen(
s);
364 return (size() >= len && !compare(size()-len, npos,
s, len));
Miscellaneous hashing functions, mostly from Bob Jenkins.
graph_traits< Graph >::vertices_size_type size_type
A character and a pointer to a character string.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A class for handling character strings derived from std::string.
bool removeStart(const std::string &text)
Remove the given text from the start of the string.
static const string null
An empty string.
bool startsWith(const std::string &s) const
Deprecated(2019-11).
bool endsWith(const std::string &s) const
Deprecated(2019-11).
static std::string::size_type length(const std::string &s)
The length of the string.
bool ends_with(const std::string &s) const
True if string ends with given [string view] suffix (cf. C++20).
static bool valid(const std::string &str)
Does the string contain valid characters only?
bool remove_ext()
Remove extension, return true if string changed.
bool ends_with(const char *s) const
True if string ends with given suffix (cf. C++20).
size_type count(const char c) const
Count the number of occurrences of the specified character in the string.
string()=default
Default construct.
bool contains(const char *s) const
True if string contains given substring (cf. C++23).
static bool stripInvalid(std::string &str)
Strip invalid characters from the given string.
static std::string::size_type length(const char *s)
Length of the character sequence (with nullptr protection).
bool starts_with(const char *s) const
True if string starts with given prefix (C++20).
bool contains(char c) const noexcept
True if string contains given character (cf. C++23).
std::string::size_type find_ext() const
Find position of a file extension dot, return npos on failure.
bool match(const std::string &text) const
Test for equality.
bool starts_with(const std::string &s) const
True if string starts with given [string view] prefix (C++20).
static StringType validate(const std::string &str)
Return a valid String from the given string.
bool removeTrailing(const char c)
Deprecated(2019-11).
bool remove_path()
Remove leading path, return true if string changed.
string & replaceAll(const std::string &s1, const std::string &s2, size_type pos=0)
Replace all occurrences of sub-string s1 with s2, beginning at pos in the string.
bool ends_with(char c) const
True if string ends with given character (cf. C++20).
bool removeRepeated(const char character)
Remove repeated characters.
string & expand(const bool allowEmpty=false)
Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::e...
bool has_ext() const
Return true if it has an extension or simply ends with a '.'.
word ext() const
Return file name extension (part after last .).
bool operator()(const std::string &text) const
Test for equality. Allows use as a predicate.
bool starts_with(char c) const
True if string starts with given character (cf. C++20).
string & replaceAny(const std::string &s1, const char c2, size_type pos=0)
Replace any occurrence of s1 characters with c2, beginning at pos in the string.
static int debug
The debug flag.
string & replace(const std::string &s1, const std::string &s2, size_type pos=0)
Replace first occurrence of sub-string s1 with s2, beginning at pos.
static std::string::size_type string_printf(std::string &output, const char *fmt, const PrimitiveType &val)
A printf-style formatter for a primitive.
bool contains(const std::string &s) const noexcept
True if string contains given [string view] substring (cf. C++23).
void swap(std::string &str)
Swap contents. Self-swapping is a no-op.
static const char *const typeName
The type name "string".
bool removeEnd(const std::string &text)
Remove the given text from the end of the string.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
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))
dimensionedScalar pos(const dimensionedScalar &ds)
unsigned Hasher(const void *data, size_t len, unsigned seed=0)
Bob Jenkins's 96-bit mixer hashing function (lookup3).
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
Deprecated hashing functor - use hasher.
Hashing functor for string and derived string classes.
unsigned operator()(const std::string &str, unsigned seed=0) const