Gromacs  2024.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Functions
stringutil.h File Reference
#include <cstdarg>
#include <cstring>
#include <string>
#include <vector>
+ Include dependency graph for stringutil.h:
+ This graph shows which files directly or indirectly include this file:

Description

Declares common string utility and formatting routines.

Author
Teemu Murtola teemu.nosp@m..mur.nosp@m.tola@.nosp@m.gmai.nosp@m.l.com

Classes

class  gmx::StringFormatter
 Function object that wraps a call to formatString() that expects a single conversion argument, for use with algorithms. More...
 
class  gmx::IdentityFormatter
 Function object to implement the same interface as StringFormatter to use with strings that should not be formatted further. More...
 
class  gmx::EqualCaseInsensitive
 Function object for comparisons with equalCaseInsensitive. More...
 
class  gmx::TextLineWrapperSettings
 Stores settings for line wrapping. More...
 
class  gmx::TextLineWrapper
 Wraps lines to a predefined length. More...
 

Macros

#define gmx_format(archetype, string_index, first_to_check)
 GCC like function format attribute. More...
 
#define gmx_fmtstr
 MSVC like function format attribute. More...
 

Functions

static bool gmx::isNullOrEmpty (const char *str)
 Tests whether a string is null or empty. More...
 
static bool gmx::startsWith (const std::string &str, const std::string &prefix)
 Tests whether a string starts with another string. More...
 
static bool gmx::startsWith (const char *str, const char *prefix)
 Tests whether a string starts with another string. More...
 
bool gmx::endsWith (const char *str, const char *suffix)
 Tests whether a string ends with another string. More...
 
static bool gmx::endsWith (const std::string &str, const char *suffix)
 Tests whether a string ends with another string. More...
 
static bool gmx::contains (const std::string &str, const char *substr)
 Tests whether a string contains another as a substring. More...
 
static bool gmx::contains (const std::string &str, const std::string &substr)
 Tests whether a string contains another as a substring. More...
 
std::size_t gmx::countWords (const char *s)
 Returns number of space-separated words in zero-terminated char ptr. More...
 
std::size_t gmx::countWords (const std::string &str)
 Returns the number of space-separated words in a string object. More...
 
static bool gmx::endsWith (const std::string &str, const std::string &suffix)
 Tests whether a string ends with another string. More...
 
std::string gmx::stripSuffixIfPresent (const std::string &str, const char *suffix)
 Removes a suffix from a string. More...
 
std::string gmx::stripString (const std::string &str)
 Removes leading and trailing whitespace from a string. More...
 
std::string gmx::formatString (const char *fmt,...)
 Formats a string (snprintf() wrapper). More...
 
std::string gmx::formatStringV (const char *fmt, va_list ap)
 Formats a string (vsnprintf() wrapper). More...
 
template<typename InputIterator , typename FormatterType >
std::string gmx::formatAndJoin (InputIterator begin, InputIterator end, const char *separator, const FormatterType &formatter)
 Formats all the range as strings, and then joins them with a separator in between. More...
 
template<typename ContainerType , typename FormatterType >
std::string gmx::formatAndJoin (const ContainerType &container, const char *separator, const FormatterType &formatter)
 Formats all elements of the container as strings, and then joins them with a separator in between. More...
 
template<typename InputIterator >
std::string gmx::joinStrings (InputIterator begin, InputIterator end, const char *separator)
 Joins strings from a range with a separator in between. More...
 
template<typename ContainerType >
std::string gmx::joinStrings (const ContainerType &container, const char *separator)
 Joins strings from a container with a separator in between. More...
 
template<size_t count>
std::string gmx::joinStrings (const char *const (&array)[count], const char *separator)
 Joins strings from an array with a separator in between. More...
 
std::vector< std::string > gmx::splitString (const std::string &str)
 Splits a string to whitespace separated tokens. More...
 
std::vector< std::string > gmx::splitDelimitedString (const std::string &str, char delim)
 Splits a string to tokens separated by a given delimiter. More...
 
std::vector< std::string > gmx::splitAndTrimDelimitedString (const std::string &str, char delim)
 Splits str to tokens separated by delimiter delim. Removes leading and trailing whitespace from those strings with std::isspace. More...
 
std::string gmx::replaceAll (const std::string &input, const char *from, const char *to)
 Replace all occurrences of a string with another string. More...
 
std::string gmx::replaceAll (const std::string &input, const std::string &from, const std::string &to)
 Replace all occurrences of a string with another string. More...
 
std::string gmx::replaceAllWords (const std::string &input, const char *from, const char *to)
 Replace whole words with others. More...
 
std::string gmx::replaceAllWords (const std::string &input, const std::string &from, const std::string &to)
 Replace whole words with others. More...
 
bool gmx::equalCaseInsensitive (const std::string &source, const std::string &target)
 Return whether two strings are equal, ignoring case. More...
 
bool gmx::equalIgnoreDash (const std::string &source, const std::string &target)
 Return whether too strings are case sensitive equal, ignoring dashes.
 
bool gmx::equalCaseInsensitive (const std::string &source, const std::string &target, size_t maxLengthOfComparison)
 Checks if at most maxLengthOfComparison characters of two strings match case insensitive. More...
 
std::string gmx::toUpperCase (const std::string &text)
 Makes the string uppercase. More...
 
std::string gmx::toLowerCase (const std::string &text)
 Makes the string lowercase. More...