String.hpp

Simple class to facilitate string manipulations.

This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2023-2025 Michigan State University MIT Software license; see doc/LICENSE.md

Todo:

Make constexpr

Make handle non-‘char’ strings (i.e., use CharT template parameter)

Make handle allocators

Make work more broadly with string_views

Maybe add special construct types like RESERVE, REPEAT, and TO_STRING for special builds?

Note

Status: ALPHA

Defines

INCLUDE_EMP_TOOLS_STRING_HPP_GUARD

Functions

template<typename ...Ts>
inline String MakeString(Ts&&... args)
inline String MakeEscaped(char c, bool include_visible)

Convert a character into a escape sequence, if needed.

Parameters:
  • c – Character to convert

  • include_visible – Should we convert visible character that are often escaped (like “ or )

Returns:

A string representing the escaped character

inline String MakeEscaped(const String &in, bool include_visible)

Convert chars in a string into escape sequences, as needed.

Parameters:
  • in – String to convert

  • inc_visible – Should we convert visible character that are often escaped (like “ or )

Returns:

A string representing the escaped sequence of chars

inline String MakeCSVSafe(const String &in)
inline String MakeWebSafe(const String &in, bool convert_space)

Take a string and replace reserved HTML characters with character entities.

inline String MakeLiteral(char value)

Take a char and convert it to a C++-style literal.

inline String MakeLiteral(const std::string &value)

Take a string or iterable and convert it to a C++-style literal. This is the version for string. The version for an iterable is below.

template<typename T>
inline String MakeLiteral(const T &value)
inline char MakeCharFromLiteral(const String &value)

Convert a literal character representation to an actual string. (i.e., ‘A’, ‘;’, or ‘

’)

inline String MakeStringFromLiteral(const String &value, CharSet quotes = "\"")
inline int MakeIntFromLiteral(const String &value)
template<typename T>
inline T MakeFromLiteral(const String &value)
inline String MakeUpper(const String &value)

Convert a string to all uppercase.

inline String MakeLower(const String &value)

Convert a string to all lowercase.

inline String MakeTitleCase(String value)

Make first letter of each word upper case.

inline String PascalToCaps(String value)
inline String MakeCount(int val, const String &item, const String &plural_suffix)

Make a string with the correct pluralization of the item being counted. For example, MakeCount(1, “cow”) would produce “1 cow”, but MakeCount(2, “cow”) would produce “2 cows”.

inline String MakeRoman(int val)

Convert an integer to a roman numeral string.

template<typename CONTAINER_T>
inline String MakeList(const CONTAINER_T &container, std::string separator = ",")
template<typename ...ARG_Ts>
inline String MakeArgList(ARG_Ts&&... args)
template<typename CONTAINER_T, typename FUN_T>
inline String MakeEnglishList(const CONTAINER_T &container, FUN_T transform_fun)
template<typename CONTAINER_T>
inline String MakeEnglishList(const CONTAINER_T &container)

Create a standard English list from a container of strings. For example, the strings {“one”, “two”} would become “one and two”

template<typename CONTAINER_T>
inline String MakeQuotedList(const CONTAINER_T &container)
template<typename ...Args>
inline String MakeFormatted(const std::format_string<Args...> &format, Args&&... args)
inline String MakeRepeat(const String &base, size_t n)

Concatenate n copies of a string.

inline String MakeTrimFront(const String &in, const CharSet &chars = WhitespaceCharSet())
inline String MakeTrimBack(const String &in, const CharSet &chars = WhitespaceCharSet())
inline String MakeTrimmed(String in, const CharSet &chars)

Remove chars from the beginning AND end of a string.

inline String MakeCompressed(String in, const CharSet &chars = WhitespaceCharSet(), char compress_to = ' ', bool trim_start = true, bool trim_end = true)
inline String MakeFiltered(String in, const CharSet &chars)

Remove all characters not specified in CharSet.

inline String MakeRemoveChars(String in, const CharSet &chars)

Remove all instances of specified characters from file.

inline String MakeSlugify(String in)

Make a string safe(r)

template<typename CONTAINER_T>
inline String Join(const CONTAINER_T &container, const std::string &join_str = "", const std::string &open = "", const std::string &close = "")

This function returns values from a container as a single string separated by a given delimiter and with optional surrounding strings.

Parameters:
  • container – is any standard-interface container holding objects to be joined.

  • join_str – optional delimiter

  • open – string to place before each string (e.g., “[” or “’”)

  • close – string to place after each string (e.g., “]” or “’”)

Returns:

merged string of all values

String MakeStringFromLiteral(const String &value, [[maybe_unused]] CharSet quotes)

Convert a literal string representation to an actual string.

inline String MakeCount(int val, const String &item)
template<typename CONTAINER_T, typename TRANSFORM_FUN_T>
String MakeEnglishList(const CONTAINER_T &container, TRANSFORM_FUN_T fun)
class String : public std::string
#include <String.hpp>

Public Functions

String() = default
inline String(const std::string &in_str)
inline String(std::string &&in_str)
inline String(const char *in_str)
inline String(size_t count, char in_str)
inline String(std::initializer_list<char> in_str)
inline String(const String &in_str, size_t start, size_t count = npos)
inline String(const std::string &in_str, size_t start, size_t count = npos)
inline String(const char *in_str, size_t count)
template<class InputIt>
inline String(InputIt first, InputIt last)
inline String(std::string_view _in_view)
String(std::nullptr_t) = delete
String(const String&) = default
String(String&&) = default
inline String(const std::string &in_str, const std::function<char(char)> &transform_fun)
inline String(const std::string &in_str, const std::function<String(char)> &transform_fun)
~String() = default
String &operator=(const String&) = default
String &operator=(String&&) = default
inline String &operator=(const std::string &_in)
inline String &operator=(std::string &&_in)
inline String &operator=(const char *_in)
inline String &operator=(char _in)
inline String &operator=(std::string_view _in)
inline String &operator=(std::initializer_list<char> _in)
String &operator=(std::nullptr_t) = delete
template<typename ...ARG_Ts>
inline String &assign(ARG_Ts&&... args)
inline std::string &str()
inline const std::string &str() const
inline char &operator[](size_t pos)
inline char operator[](size_t pos) const
inline char &front()
inline char front() const
inline char &back()
inline char back() const
inline char &Get(size_t pos)
inline char Get(size_t pos) const
inline String substr(size_t pos = 0, size_t count = npos) const
inline String GetRange(size_t start_pos, size_t end_pos) const
inline std::string_view View(size_t start = 0, size_t out_size = npos) const
inline std::string_view ViewFront(size_t out_size) const
inline std::string_view ViewBack(size_t out_size) const
inline std::string_view ViewRange(size_t start, size_t end) const
inline std::string_view ViewTo(CharSet stop_chars, size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline std::string_view ViewBackTo(CharSet stop_chars, size_t start = npos, const Syntax &syntax = Syntax::None()) const
inline std::string_view ViewWord(const Syntax &syntax = Syntax::Quotes(), size_t start = 0) const
inline std::string_view ViewLine(const Syntax &syntax = Syntax::Quotes(), size_t start = 0) const
inline int ssize() const
inline bool HasAt(const String &test, size_t pos) const
inline bool HasPrefix(const String &prefix) const
inline bool HasSuffix(const String &suffix) const
inline size_t Hash() const noexcept
inline size_t Count(char c, size_t start = 0) const
inline size_t Count(char c, size_t start, size_t end) const
inline bool IsLiteralChar() const

Test if an string is formatted as a literal character.

Test if an input string is properly formatted as a literal character.

inline bool IsLiteralString(CharSet quote_marks = "\"") const

Test if an string is formatted as a literal string.

Test if an input string is properly formatted as a literal string.

inline String DiagnoseLiteralString(CharSet quote_marks = "\"") const

Explain what string is NOT formatted as a literal string.

Test if an input string is properly formatted as a literal string.

inline bool IsComposedOf(CharSet char_set) const

Is string composed only of a set of characters (can be provided as a string)

template<typename... ARG_Ts> inline bool IsOneOf (ARG_Ts &&... args) const requires(std

Is this string one of the strings provided?

inline bool IsNumber() const

Is string a valid number (int, floating point, or scientific notation all valid)

Determine if this string represents a proper number.

inline bool IsIdentifier() const

Is string a valid identifier? At least one char; cannot begin with digit, only letters, digits and _

inline bool OnlyLower() const
inline bool OnlyUpper() const
inline bool OnlyDigits() const
inline bool OnlyAlphanumeric() const
inline bool OnlyWhitespace() const
inline bool OnlyIDChars() const
inline bool HasOneOf(CharSet char_set) const
inline bool Has(char c) const
inline bool HasWhitespace() const
inline bool HasNonwhitespace() const
inline bool HasUpper() const
inline bool HasLower() const
inline bool HasLetter() const
inline bool HasDigit() const
inline bool HasAlphanumeric() const
inline bool HasCharAt(char c, size_t pos) const
inline bool HasOneOfAt(CharSet opts, size_t pos) const
inline bool HasDigitAt(size_t pos) const
inline bool HasLetterAt(size_t pos) const
inline bool HasUpperAt(size_t pos) const
inline bool HasLowerAt(size_t pos) const
inline bool HasWhitespaceAt(size_t pos) const
inline size_t CountWhitespace() const
inline size_t CountNonwhitespace() const
inline size_t CountUpper() const
inline size_t CountLower() const
inline size_t CountLetters() const
inline size_t CountDigits() const
inline size_t CountAlphanumeric() const
inline size_t CountFrontWhitespace() const
inline size_t CountFrontUpper() const
inline size_t CountFrontLower() const
inline size_t CountFrontLetters() const
inline size_t CountFrontDigits() const
inline size_t CountFrontAlphanumeric() const
inline String &clear() noexcept
inline String &erase(size_t index = 0, size_t count = npos)
inline iterator erase(const_iterator pos)
inline iterator erase(const_iterator first, const_iterator last)
inline String &RemoveWhitespace()
inline String &RemoveUpper()
inline String &RemoveLower()
inline String &RemoveLetters()
inline String &RemoveDigits()
inline String &RemovePunctuation()
inline String AsRemoveWhitespace() const
inline String AsRemoveUpper() const
inline String AsRemoveLower() const
inline String AsRemoveLetters() const
inline String AsRemoveDigits() const
inline String AsRemovePunctuation() const
inline String &Resize(size_t new_size)
inline String &ResizeTo(CharSet chars, const Syntax &syntax = Syntax::None())
inline String &ResizeTo(const String &delim, const Syntax &syntax = Syntax::None())
inline bool PopIf(char c)
inline bool PopIf(const String &in)
inline bool PopIfAny(CharSet chars)

Pop the next character if it is any of the provided chars. Return true/false if popped.

inline String PopAll()

Pop the entire string.

inline String PopFixed(size_t end_pos, size_t delim_size = 0)

Pop a segment from the beginning of a string as another string, shortening original.

inline String Pop(CharSet chars = " \n\t\r", const Syntax &syntax = Syntax::None())

Remove a prefix of the string (up to a specified delimiter) and return it. If the delimiter is not found, return the entire string and clear it.

inline String PopTo(const String &delim, const Syntax &syntax = Syntax::None())

Remove a prefix of the string (up to a specified delimiter) and return it. If the delimiter is not found, return the entire string and clear it.

inline String PopWord(const Syntax &syntax = Syntax::None())
inline String PopLine(const Syntax &syntax = Syntax::None())
inline String PopQuote(const Syntax &syntax = Syntax::Quotes())
inline String PopParen(const Syntax &syntax = Syntax::Parens())
inline String PopLiteralSigned()
inline long long PopSigned()
inline String PopLiteralUnsigned()
inline unsigned long long PopUnsigned()
inline String PopLiteralFloat()
inline double PopFloat()
inline String PopLiteralChar(const Syntax &syntax = Syntax::CharQuotes())
inline char PopChar()
template<typename T>
inline String PopLiteral(const Syntax &syntax = Syntax::Quotes())
template<typename T>
inline T PopFromLiteral(const Syntax &syntax = Syntax::Quotes())
inline String &insert(size_t index, const String &in)
inline String &insert(size_t index, const String &in, size_t pos, size_t count = npos)
template<typename ...ARG_Ts>
inline String &insert(size_t index, ARG_Ts&&... args)
template<typename ...ARG_Ts>
inline String &insert(const_iterator pos, ARG_Ts&&... args)
inline String &append(const String &in)
inline String &append(const String &in, size_t pos, size_t count)
template<typename ...ARG_Ts>
inline String &append(ARG_Ts&&... args)
template<typename ARG_T>
inline String &operator+=(ARG_T &&arg)
template<typename ...ARG_Ts>
inline String &Prepend(ARG_Ts&&... args)
inline String &PadFront(char padding, size_t target_size)
inline String &PadBack(char padding, size_t target_size)
template<typename ...ARG_Ts>
inline String &replace(ARG_Ts&&... args)
inline String &resize(size_t count, char c = '\0')
inline size_t ReplaceAll(char from, char to, size_t start = 0)
inline size_t ReplaceAll(const String &from, const String &to, size_t start = 0)
inline String &ReplaceSet(CharSet from, char to, size_t start = 0)
inline String &ReplaceRange(size_t start, size_t end, const String &value)
template<typename MAP_T>
String AsReplaceVars(const MAP_T &var_map, const String &symbol = "$", const Syntax &syntax = Syntax::Full())

Find any instances of ${X} and replace with dictionary lookup of X in this variable.

template<typename MAP_T>
String &SetReplaceVars(const MAP_T &var_map, const String &symbol = "$", const Syntax &syntax = Syntax::Full())

Find any instances of ${X} and replace with dictionary lookup of X in this variable.

template<typename FUN_T>
String &ReplaceMacro(const String &start_str, const String &end_str, const FUN_T &fun, const Syntax &syntax = Syntax{"\"", "()"})

Find any instance of MACRO_NAME(ARGS) and replace it with fun(ARGS).

Todo:

Separate syntax into find_start syntax and find_end (inside macro) syntax.

Parameters:
  • start_str – Initial sequence of macro to look for; for example “REPLACE(”

  • end_str – Sequence that ends the macro; for example “)”

  • macro_fun – Function to call with contents of macro. Params are macro_args (string), line_num (size_t), and hit_num (size_t)

  • syntax – What values should we skip as quotes or parens?

Returns:

This string object, post processing.

inline size_t FindQuoteMatch(size_t pos = 0) const
inline size_t FindParenMatch(size_t pos = 0, const Syntax &syntax = Syntax::Parens()) const
inline size_t RFindQuoteMatch(size_t pos = npos) const
inline size_t RFindParenMatch(size_t pos = npos, const Syntax &syntax = Syntax::RParens()) const
inline size_t FindMatch(size_t pos = 0, const Syntax &syntax = Syntax::Full()) const
inline size_t RFindMatch(size_t pos = npos, const Syntax &syntax = Syntax::Full()) const
inline size_t Find(char target, size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t Find(const String &target, size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t Find(const CharSet &char_set, size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t Find(const char *target, size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t RFind(char target, size_t start = npos, const Syntax &syntax = Syntax::None()) const
inline size_t RFind(const String &target, size_t start = npos, const Syntax &syntax = Syntax::None()) const
inline size_t RFind(const CharSet &char_set, size_t start = npos, const Syntax &syntax = Syntax::None()) const
inline size_t RFind(const char *target, size_t start = npos, const Syntax &syntax = Syntax::None()) const
inline void FindAll(char target, vector<size_t> &results, const Syntax &syntax = Syntax::None()) const
inline vector<size_t> FindAll(char target, const Syntax &syntax = Syntax::None()) const
template<typename ...Ts>
inline size_t FindAnyOfFrom(size_t start, const String &test1, Ts... tests) const
template<typename T, typename ...Ts>
inline size_t FindAnyOf(T test1, Ts... tests) const
inline size_t FindID(const String &target, size_t start, const Syntax &syntax = Syntax::Quotes()) const
inline size_t FindWhitespace(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindNonWhitespace(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindUpper(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindNonUpper(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindLower(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindNonLower(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindLetter(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindNonLetter(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindDigit(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindNonDigit(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindAlphanumeric(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindNonAlphanumeric(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindIDChar(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline size_t FindNonIDChar(size_t start = 0, const Syntax &syntax = Syntax::None()) const
inline std::string_view ViewNestedBlock(size_t start = 0, const Syntax &syntax = Syntax::Quotes()) const
inline std::string_view ViewQuote(size_t start = 0, const Syntax &syntax = Syntax::Quotes()) const
inline std::string_view ScanTo(size_t &pos, size_t stop_pos) const
inline std::string_view ScanWhile(size_t &pos, CharSet chars) const
inline char ScanChar(size_t &pos) const
inline std::string_view ScanWhitespace(size_t &pos) const
inline std::string_view ScanUpper(size_t &pos) const
inline std::string_view ScanLower(size_t &pos) const
inline std::string_view ScanLetters(size_t &pos) const
inline std::string_view ScanDigits(size_t &pos) const
inline std::string_view ScanAlphanumeric(size_t &pos) const
inline std::string_view ScanNestedBlock(size_t &pos) const
inline std::string_view ScanQuote(size_t &pos) const
inline std::string_view ScanWord(size_t &pos) const
inline char ScanAsChar(size_t &pos) const
inline int ScanAsInt(size_t &pos) const
template<typename T>
T ConvertTo()
template<typename DELIM_T = String>
inline void Slice(vector<String> &out_set, const DELIM_T &delim = ",", const Syntax &syntax = Syntax::Quotes(), bool trim_whitespace = false) const

Cut up a string based on the provided delimiter; fill them in to the provided vector.

Parameters:
  • out_set – destination vector

  • delim – delimiter to split on (default: “,”)

  • syntax – identify quotes and parens that should be kept together.

  • trim_whitespace – Should whitespace around delim or assign be ignored? (default: true)

template<typename DELIM_T = String>
inline vector<String> Slice(const DELIM_T &delim = ",", const Syntax &syntax = Syntax::Quotes(), bool trim_whitespace = false) const

Slice a String on a delimiter; return a vector of results.

Note

May be less efficient, but easier than other version of Slice()

Parameters:
  • delim – delimiter to split on (default: “,”)

  • syntax – identify quotes and parens that should be kept together.

  • trim_whitespace – Should whitespace around delim or assign be ignored? (default: true)

inline void ViewSlices(vector<std::string_view> &out_set, const String &delim = ",", const Syntax &syntax = Syntax::Quotes()) const

Fill vector out_set of string_views based on the provided delimiter.

Parameters:
  • out_set – destination vector

  • delim – delimiter to split on (default: “,”)

  • syntax – identify quotes and parens that should be kept together.

inline vector<std::string_view> ViewSlices(const String &delim = ",", const Syntax &syntax = Syntax::Quotes()) const

Generate vector of string_views based on the provided delimiter.

Parameters:
  • delim – delimiter to split on (default: “,”)

  • syntax – identify quotes and parens that should be kept together.

inline void SliceAssign(std::map<String, String> &result_map, const String &delim = ",", const String &assign_op = "=", const Syntax &syntax = Syntax::Quotes(), bool trim_whitespace = true) const

Slice a string and treat each section as an assignment; place results in provided map.

Parameters:
  • delim – delimiter to split on (default ‘,’)

  • assign_op – separator for left and right side of assignment (default: “=”)

  • syntax – identify quotes and parens that should be kept together.

  • trim_whitespace – Should whitespace around delim or assign be ignored? (default: true)

inline std::map<String, String> SliceAssign(const String &delim = ",", const String &assign_op = "=", const Syntax &syntax = Syntax::Quotes(), bool trim_whitespace = true) const

Slice a string and treat each section as an assignment; fill out a map and return it.

Parameters:
  • delim – delimiter to split on (default ‘,’)

  • assign_op – separator for left and right side of assignment (default: “=”)

  • syntax – identify quotes and parens that should be kept together.

  • trim_whitespace – Should whitespace around delim or assign be ignored? (default: true)

template<typename T>
inline String operator+(T &&in) const
inline String operator*(size_t count) const
template<typename ...Ts>
inline String &Set(Ts... args)
template<typename T>
inline T As() const
template<typename ...Ts>
inline String &Append(Ts... args)
inline double AsDouble() const
inline int AsInt() const
inline unsigned long long AsULL() const
inline bool AsBool() const
inline String &AppendEscaped(char c, bool inc_visible = true)
inline String &SetEscaped(char c, bool inc_visible = true)
inline String &AppendEscaped(const String &in, bool inc_visible = true)
inline String &SetEscaped(const String &in, bool inc_visible = true)
inline String &SetEscaped(bool inc_visible = true)
inline String AsEscaped(bool inc_visible = true) const
inline String &AppendCSVSafe(const String &in)
inline String &SetCSVSafe(const String &in)
inline String &SetCSVSafe()
inline String AsCSVSafe() const
inline String &AppendWebSafe(const String &in, bool convert_space = false)
inline String &SetWebSafe(const String &in, bool convert_space = false)
inline String &SetWebSafe(bool convert_space = false)
inline String AsWebSafe(bool convert_space = false) const
template<typename T>
inline String &AppendLiteral(const T &in)
template<typename T>
inline String &SetLiteral(const T &in)
inline String &SetLiteral()
inline String AsLiteral() const
template<typename T>
inline T ConvertFromLiteral() const
inline String ConvertStringFromLiteral() const
inline String &AppendUpper(const String &in)
inline String &SetUpper(const String &in)
inline String &SetUpper()
inline String &SetUpperAt(size_t pos)
inline String AsUpper() const
inline String &AppendLower(const String &in)
inline String &SetLower(const String &in)
inline String &SetLower()
inline String &SetLowerAt(size_t pos)
inline String AsLower() const
inline String &AppendTitleCase(const String &in)
inline String &SetTitleCase(const String &in)
inline String &SetTitleCase()
inline String AsTitleCase() const
inline String &SetPascalToCaps()
inline String AsPascalToCaps() const
inline String &AppendCount(int val, const String &item, const String &suffix = "s")
inline String &SetCount(int val, const String &item, const String &suffix = "s")
inline String &SetAsCount(int val, const String &suffix = "s")
inline String &AppendRoman(int val)
inline String &SetRoman(int val)
template<typename ...Ts>
inline String &AppendList(const Ts&... args)
template<typename ...Ts>
inline String &SetList(const Ts&... args)
template<typename ...Ts>
inline String &AppendArgList(const Ts&... args)
template<typename ...Ts>
inline String &SetArgList(const Ts&... args)
template<typename ...Ts>
inline String &AppendEnglishList(const Ts&... args)
template<typename ...Ts>
inline String &SetEnglishList(const Ts&... args)
template<typename CONTAINER_T>
inline String &AppendQuotedList(const CONTAINER_T &container)
template<typename CONTAINER_T>
inline String &SetQuotedList(const CONTAINER_T &container)
template<typename ...ARG_Ts>
inline String &AppendFormatted(const std::format_string<ARG_Ts...> &format, ARG_Ts... args)
template<typename ...ARG_Ts>
inline String &SetFormatted(const std::format_string<ARG_Ts...> &format, ARG_Ts... args)
inline String &AppendTrimFront(const String &in, const CharSet &chars = WhitespaceCharSet())
inline String &SetTrimFront(const String &in, const CharSet &chars = WhitespaceCharSet())
inline String &TrimFront(const CharSet &chars = WhitespaceCharSet())
inline String AsTrimFront(const CharSet &chars = WhitespaceCharSet()) const
inline String &AppendTrimBack(const String &in, const CharSet &chars = WhitespaceCharSet())
inline String &SetTrimBack(const String &in, const CharSet &chars = WhitespaceCharSet())
inline String &TrimBack(const CharSet &chars = WhitespaceCharSet())
inline String AsTrimBack(const CharSet &chars = WhitespaceCharSet()) const
inline String &AppendTrimmed(const String &in, const CharSet &chars = WhitespaceCharSet())
inline String &SetTrimmed(const String &in, const CharSet &chars = WhitespaceCharSet())
inline String &Trim(const CharSet &chars = WhitespaceCharSet())
inline String AsTrimmed(const CharSet &chars = WhitespaceCharSet()) const
inline String &AppendCompressed(const String &in, const CharSet &chars = WhitespaceCharSet(), char compress_to = ' ', bool trim_start = true, bool trim_end = true)
inline String &SetCompressed(const String &in, const CharSet &chars = WhitespaceCharSet(), char compress_to = ' ', bool trim_start = true, bool trim_end = true)
inline String &Compress(const CharSet &chars = WhitespaceCharSet(), char compress_to = ' ', bool trim_start = true, bool trim_end = true)

Compress all consecutive instances from a set of chars to a single specified char.

inline String &Compress(char ch, bool trim_start = true, bool trim_end = true)

Compress multiple consecutive instances of whitespace to just one instance.

inline String AsCompressed(const CharSet &chars = WhitespaceCharSet(), char compress_to = ' ', bool trim_start = true, bool trim_end = true) const
inline String &AppendFiltered(const String &in, const CharSet &chars)
inline String &SetFiltered(const String &in, const CharSet &chars)
inline String &Filter(const CharSet &chars)
inline String AsFiltered(const CharSet &chars) const
inline String &AppendRemoveChars(const String &in, const CharSet &chars)
inline String &SetRemoveChars(const String &in, const CharSet &chars)
inline String &RemoveChars(const CharSet &chars)
inline String AsRemoveChars(const CharSet &chars) const
inline String &AppendSlugify(String in)
inline String &SetSlugify(String in)
inline String &Slugify()
inline String AsSlugify() const
template<typename CONTAINER_T>
inline String &AppendJoin(const CONTAINER_T &container, const String &delim = "", String open = "", String close = "")
template<typename CONTAINER_T>
inline String &SetJoin(const CONTAINER_T &container, const String &delim = "", String open = "", String close = "")
inline String AsANSIBold() const
inline String &SetANSIBold()
inline String &AppendANSIBold(std::string_view sv)
inline String AsANSIFaint() const
inline String &SetANSIFaint()
inline String &AppendANSIFaint(std::string_view sv)
inline String AsANSIItalic() const
inline String &SetANSIItalic()
inline String &AppendANSIItalic(std::string_view sv)
inline String AsANSIUnderline() const
inline String &SetANSIUnderline()
inline String &AppendANSIUnderline(std::string_view sv)
inline String AsANSISlowBlink() const
inline String &SetANSISlowBlink()
inline String &AppendANSISlowBlink(std::string_view sv)
inline String AsANSIBlink() const
inline String &SetANSIBlink()
inline String &AppendANSIBlink(std::string_view sv)
inline String AsANSIReverse() const
inline String &SetANSIReverse()
inline String &AppendANSIReverse(std::string_view sv)
inline String AsANSIStrike() const
inline String &SetANSIStrike()
inline String &AppendANSIStrike(std::string_view sv)
inline String AsANSIBlack() const
inline String &SetANSIBlack()
inline String &AppendANSIBlack(std::string_view sv)
inline String AsANSIRed() const
inline String &SetANSIRed()
inline String &AppendANSIRed(std::string_view sv)
inline String AsANSIGreen() const
inline String &SetANSIGreen()
inline String &AppendANSIGreen(std::string_view sv)
inline String AsANSIYellow() const
inline String &SetANSIYellow()
inline String &AppendANSIYellow(std::string_view sv)
inline String AsANSIBlue() const
inline String &SetANSIBlue()
inline String &AppendANSIBlue(std::string_view sv)
inline String AsANSIMagenta() const
inline String &SetANSIMagenta()
inline String &AppendANSIMagenta(std::string_view sv)
inline String AsANSICyan() const
inline String &SetANSICyan()
inline String &AppendANSICyan(std::string_view sv)
inline String AsANSIWhite() const
inline String &SetANSIWhite()
inline String &AppendANSIWhite(std::string_view sv)
inline String AsANSIBrightBlack() const
inline String &SetANSIBrightBlack()
inline String &AppendANSIBrightBlack(std::string_view sv)
inline String AsANSIBrightRed() const
inline String &SetANSIBrightRed()
inline String &AppendANSIBrightRed(std::string_view sv)
inline String AsANSIBrightGreen() const
inline String &SetANSIBrightGreen()
inline String &AppendANSIBrightGreen(std::string_view sv)
inline String AsANSIBrightYellow() const
inline String &SetANSIBrightYellow()
inline String &AppendANSIBrightYellow(std::string_view sv)
inline String AsANSIBrightBlue() const
inline String &SetANSIBrightBlue()
inline String &AppendANSIBrightBlue(std::string_view sv)
inline String AsANSIBrightMagenta() const
inline String &SetANSIBrightMagenta()
inline String &AppendANSIBrightMagenta(std::string_view sv)
inline String AsANSIBrightCyan() const
inline String &SetANSIBrightCyan()
inline String &AppendANSIBrightCyan(std::string_view sv)
inline String AsANSIBrightWhite() const
inline String &SetANSIBrightWhite()
inline String &AppendANSIBrightWhite(std::string_view sv)
inline String AsANSIBlackBG() const
inline String &SetANSIBlackBG()
inline String &AppendANSIBlackBG(std::string_view sv)
inline String AsANSIRedBG() const
inline String &SetANSIRedBG()
inline String &AppendANSIRedBG(std::string_view sv)
inline String AsANSIGreenBG() const
inline String &SetANSIGreenBG()
inline String &AppendANSIGreenBG(std::string_view sv)
inline String AsANSIYellowBG() const
inline String &SetANSIYellowBG()
inline String &AppendANSIYellowBG(std::string_view sv)
inline String AsANSIBlueBG() const
inline String &SetANSIBlueBG()
inline String &AppendANSIBlueBG(std::string_view sv)
inline String AsANSIMagentaBG() const
inline String &SetANSIMagentaBG()
inline String &AppendANSIMagentaBG(std::string_view sv)
inline String AsANSICyanBG() const
inline String &SetANSICyanBG()
inline String &AppendANSICyanBG(std::string_view sv)
inline String AsANSIWhiteBG() const
inline String &SetANSIWhiteBG()
inline String &AppendANSIWhiteBG(std::string_view sv)
inline String AsANSIBrightBlackBG() const
inline String &SetANSIBrightBlackBG()
inline String &AppendANSIBrightBlackBG(std::string_view sv)
inline String AsANSIBrightRedBG() const
inline String &SetANSIBrightRedBG()
inline String &AppendANSIBrightRedBG(std::string_view sv)
inline String AsANSIBrightGreenBG() const
inline String &SetANSIBrightGreenBG()
inline String &AppendANSIBrightGreenBG(std::string_view sv)
inline String AsANSIBrightYellowBG() const
inline String &SetANSIBrightYellowBG()
inline String &AppendANSIBrightYellowBG(std::string_view sv)
inline String AsANSIBrightBlueBG() const
inline String &SetANSIBrightBlueBG()
inline String &AppendANSIBrightBlueBG(std::string_view sv)
inline String AsANSIBrightMagentaBG() const
inline String &SetANSIBrightMagentaBG()
inline String &AppendANSIBrightMagentaBG(std::string_view sv)
inline String AsANSIBrightCyanBG() const
inline String &SetANSIBrightCyanBG()
inline String &AppendANSIBrightCyanBG(std::string_view sv)
inline String AsANSIBrightWhiteBG() const
inline String &SetANSIBrightWhiteBG()
inline String &AppendANSIBrightWhiteBG(std::string_view sv)

Public Static Functions

static inline const String &StaticEmpty()
template<typename ...ARG_Ts>
static inline String Make(ARG_Ts&&... args)
static inline String Make(const std::string &in_str)
static inline String Make(std::string &&in_str)
static inline const String &Make(const String &in_str)
static inline String Make(String &&in_str)

Private Types

using Syntax = StringSyntax

Private Functions

inline void AssertPos_([[maybe_unused]] size_t pos) const
inline auto Iterator_(size_t pos) const

Private Static Functions

static inline char &NoChar()
template<typename T>
static inline auto Convert_(T &&value)
template<>
struct hash<String>
#include <String.hpp>

Public Functions

inline size_t operator()(const String &str) const noexcept