\hypertarget{stringops_8h}{}\doxysection{kblib/stringops.h File Reference} \label{stringops_8h}\index{kblib/stringops.h@{kblib/stringops.h}} Provides utilities for performing common operations on strings. {\ttfamily \#include \char`\"{}algorithm.\+h\char`\"{}}\newline {\ttfamily \#include \char`\"{}format.\+h\char`\"{}}\newline {\ttfamily \#include \char`\"{}tdecl.\+h\char`\"{}}\newline {\ttfamily \#include \char`\"{}traits.\+h\char`\"{}}\newline {\ttfamily \#include $<$algorithm$>$}\newline {\ttfamily \#include $<$cctype$>$}\newline {\ttfamily \#include $<$cwctype$>$}\newline {\ttfamily \#include $<$initializer\+\_\+list$>$}\newline {\ttfamily \#include $<$numeric$>$}\newline {\ttfamily \#include $<$string$>$}\newline {\ttfamily \#include $<$type\+\_\+traits$>$}\newline {\ttfamily \#include $<$string\+\_\+view$>$}\newline Include dependency graph for stringops.\+h\+:\nopagebreak \begin{figure}[H] \begin{center} \leavevmode \includegraphics[width=350pt]{stringops_8h__incl} \end{center} \end{figure} This graph shows which files directly or indirectly include this file\+:\nopagebreak \begin{figure}[H] \begin{center} \leavevmode \includegraphics[width=350pt]{stringops_8h__dep__incl} \end{center} \end{figure} \doxysubsection*{Classes} \begin{DoxyCompactItemize} \item struct \mbox{\hyperlink{structkblib_1_1is__character}{kblib\+::is\+\_\+character$<$ C $>$}} \begin{DoxyCompactList}\small\item\em Determine if the given type, ignoring const or reference qualifiers, is a character type. \end{DoxyCompactList}\item struct \mbox{\hyperlink{structkblib_1_1detail_1_1arithmetic__type}{kblib\+::detail\+::arithmetic\+\_\+type$<$ T, bool $>$}} \begin{DoxyCompactList}\small\item\em Filter only arithmetic types. \end{DoxyCompactList}\item struct \mbox{\hyperlink{structkblib_1_1detail_1_1arithmetic__type_3_01_t_00_01true_01_4}{kblib\+::detail\+::arithmetic\+\_\+type$<$ T, true $>$}} \begin{DoxyCompactList}\small\item\em Filter only arithmetic types. \end{DoxyCompactList}\item struct \mbox{\hyperlink{structkblib_1_1detail_1_1str__type}{kblib\+::detail\+::str\+\_\+type$<$ T, typename $>$}} \begin{DoxyCompactList}\small\item\em Converts arithmetic types to strings, but provides the identity transformation for all other types. \end{DoxyCompactList}\item struct \mbox{\hyperlink{structkblib_1_1detail_1_1str__type_3_01_t_00_01void_01_4}{kblib\+::detail\+::str\+\_\+type$<$ T, void $>$}} \begin{DoxyCompactList}\small\item\em Performs a natural conversion to a stringlike type. \end{DoxyCompactList}\item struct \mbox{\hyperlink{structkblib_1_1detail_1_1str__type_3_01char_00_01char_01_4}{kblib\+::detail\+::str\+\_\+type$<$ char, char $>$}} \begin{DoxyCompactList}\small\item\em Override for char to avoid conversion to integer. \end{DoxyCompactList}\item struct \mbox{\hyperlink{structkblib_1_1detail_1_1str__type_3_01wchar__t_00_01wchar__t_01_4}{kblib\+::detail\+::str\+\_\+type$<$ wchar\+\_\+t, wchar\+\_\+t $>$}} \begin{DoxyCompactList}\small\item\em Override for wchar\+\_\+t to avoid conversion to integer. \end{DoxyCompactList}\item struct \mbox{\hyperlink{structkblib_1_1detail_1_1str__type_3_01char16__t_00_01char16__t_01_4}{kblib\+::detail\+::str\+\_\+type$<$ char16\+\_\+t, char16\+\_\+t $>$}} \begin{DoxyCompactList}\small\item\em Override for char16\+\_\+t to avoid conversion to integer. \end{DoxyCompactList}\item struct \mbox{\hyperlink{structkblib_1_1detail_1_1str__type_3_01char32__t_00_01char32__t_01_4}{kblib\+::detail\+::str\+\_\+type$<$ char32\+\_\+t, char32\+\_\+t $>$}} \begin{DoxyCompactList}\small\item\em Override for char32\+\_\+t to avoid conversion to integer. \end{DoxyCompactList}\item struct \mbox{\hyperlink{structkblib_1_1detail_1_1value}{kblib\+::detail\+::value$<$ I, T $>$}} \item struct \mbox{\hyperlink{structkblib_1_1detail_1_1values_3_01std_1_1index__sequence_3_01_idxs_8_8_8_01_4_00_01_ts_8_8_8_01_4}{kblib\+::detail\+::values$<$ std\+::index\+\_\+sequence$<$ Idxs... $>$, Ts... $>$}} \item struct \mbox{\hyperlink{structkblib_1_1is__space}{kblib\+::is\+\_\+space}} \end{DoxyCompactItemize} \doxysubsection*{Namespaces} \begin{DoxyCompactItemize} \item namespace \mbox{\hyperlink{namespacekblib}{kblib}} \begin{DoxyCompactList}\small\item\em The main namespace in which all entities from kblib are defined. \end{DoxyCompactList}\item namespace \mbox{\hyperlink{namespacekblib_1_1detail}{kblib\+::detail}} \begin{DoxyCompactList}\small\item\em The namespace used for implementation details within kblib. \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsection*{Typedefs} \begin{DoxyCompactItemize} \item {\footnotesize template$<$typename T $>$ }\\using \mbox{\hyperlink{namespacekblib_1_1detail_a648ea881d24251358900553878900cf8}{kblib\+::detail\+::arithmetic\+\_\+type\+\_\+t}} = typename arithmetic\+\_\+type$<$ T $>$\+::type \begin{DoxyCompactList}\small\item\em Equivalent to typename \mbox{\hyperlink{structkblib_1_1detail_1_1arithmetic__type_a691889e4ec8c53a00e428f5382f45b94}{arithmetic\+\_\+type$<$\+T$>$\+::type}}. \end{DoxyCompactList}\item {\footnotesize template$<$typename T $>$ }\\using \mbox{\hyperlink{namespacekblib_1_1detail_a60fec688ea68a688f870726b652cf69f}{kblib\+::detail\+::str\+\_\+type\+\_\+t}} = typename str\+\_\+type$<$ T $>$\+::type \begin{DoxyCompactList}\small\item\em Provides the natural stringlike type for representing a T. \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsection*{Functions} \begin{DoxyCompactItemize} \item {\footnotesize template$<$typename Str $>$ }\\auto \mbox{\hyperlink{namespacekblib_a2fdc3a299b0c7c4d8432c253ad3bb1ca}{kblib\+::strsize}} (Str \&\&str) -\/$>$ std\+::size\+\_\+t \begin{DoxyCompactList}\small\item\em Determines the size in characters of any valid argument to concat or append. \end{DoxyCompactList}\item {\footnotesize template$<$typename CharT $>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_a793fd30664717fe1da593bf53e895e9d}{kblib\+::length}} (const CharT $\ast$str) noexcept -\/$>$ std\+::size\+\_\+t \item {\footnotesize template$<$typename string , typename F , typename... S$>$ }\\auto \mbox{\hyperlink{namespacekblib_ab4642bf06f44ec657126cea9a3272f1c}{kblib\+::append}} (string \&\&out, F \&\&f, S \&\&... tail) -\/$>$ void \begin{DoxyCompactList}\small\item\em Given an object out of resizable stringlike type string, appends all other arguments to it. \end{DoxyCompactList}\item {\footnotesize template$<$typename string , typename... S, std\+::size\+\_\+t... I$>$ }\\auto \mbox{\hyperlink{namespacekblib_1_1detail_a99e8609e0af635b31b30ac17a57456a7}{kblib\+::detail\+::concat\+\_\+impl}} (std\+::index\+\_\+sequence$<$ I... $>$, S \&\&... ins) -\/$>$ string \item {\footnotesize template$<$typename string = std\+::string, typename F , typename... S$>$ }\\auto \mbox{\hyperlink{namespacekblib_a56615de712caf1b43a541f5387a4b847}{kblib\+::concat}} (F \&\&f, S \&\&... ins) -\/$>$ string \begin{DoxyCompactList}\small\item\em Returns a string consisting of the concatenation of all arguments. \end{DoxyCompactList}\item {\footnotesize template$<$typename string = std\+::string, typename str $>$ }\\auto \mbox{\hyperlink{namespacekblib_abf1c606d3818a88fc90e6a264711c671}{kblib\+::concat}} (std\+::initializer\+\_\+list$<$ str $>$ ins) -\/$>$ string \begin{DoxyCompactList}\small\item\em Returns a string consisting of the concatenation of all elements of an initializer list. \end{DoxyCompactList}\item auto \mbox{\hyperlink{namespacekblib_a9ac0c26180c8c2c92776c9f5ab5d9cb5}{kblib\+::isspace}} (char c) -\/$>$ bool \item auto \mbox{\hyperlink{namespacekblib_a1b60023a02def7bd83ee293cb48979fb}{kblib\+::isspace}} (wchar\+\_\+t c) -\/$>$ bool \item constexpr auto \mbox{\hyperlink{namespacekblib_a93e9fd5013f05b5433d36a010f7d447d}{kblib\+::is\+Aspace}} (char c) -\/$>$ bool \item constexpr auto \mbox{\hyperlink{namespacekblib_a1d56bb6caa6ddf9f4bed73116501d2ed}{kblib\+::is\+Aspace}} (wchar\+\_\+t c) -\/$>$ bool \item {\footnotesize template$<$typename range , typename string = std\+::string$>$ }\\auto \mbox{\hyperlink{namespacekblib_a6127fe0b8fdc5d0374a81eddf28749df}{kblib\+::join}} (const range \&in, const string \&joiner=\char`\"{}\char`\"{}) \begin{DoxyCompactList}\small\item\em Concatenates all elements of a range together with an optional joiner. \end{DoxyCompactList}\item {\footnotesize template$<$typename Container = std\+::vector$<$std\+::string$>$, typename Predicate , typename String $>$ }\\auto \mbox{\hyperlink{namespacekblib_a05a551b96ff921bdd62cd2fc0110c54d}{kblib\+::split\+\_\+tokens}} (const String \&in, Predicate spacer) -\/$>$ return\+\_\+assert\+\_\+t$<$ is\+\_\+callable$<$ Predicate, typename Container\+::value\+\_\+type\+::value\+\_\+type $>$\+::value, Container $>$ \begin{DoxyCompactList}\small\item\em Split a string on all condensed delimiters. \end{DoxyCompactList}\item {\footnotesize template$<$typename Container = std\+::vector$<$std\+::string$>$, typename String $>$ }\\auto \mbox{\hyperlink{namespacekblib_a288c8338128b43f633100be6f592e3ec}{kblib\+::split\+\_\+tokens}} (const String \&in) -\/$>$ Container \begin{DoxyCompactList}\small\item\em Split a string on all instances of whitespace. \end{DoxyCompactList}\item {\footnotesize template$<$typename Container = std\+::vector$<$std\+::string$>$, typename String $>$ }\\auto \mbox{\hyperlink{namespacekblib_a34cba269622ee9886da3de3d723e1e3e}{kblib\+::split\+\_\+tokens}} (const String \&in, typename Container\+::value\+\_\+type\+::value\+\_\+type delim) -\/$>$ Container \begin{DoxyCompactList}\small\item\em Split a string on all instances of a delimiter. \end{DoxyCompactList}\item {\footnotesize template$<$typename Container = std\+::vector$<$std\+::string$>$, typename String $>$ }\\auto \mbox{\hyperlink{namespacekblib_a47a95399524c0bca50361169128f9db9}{kblib\+::kbsplit2}} (const String \&in, char delim=\textquotesingle{} \textquotesingle{}) -\/$>$ Container \item {\footnotesize template$<$typename Container = std\+::vector$<$std\+::string$>$, typename String $>$ }\\auto \mbox{\hyperlink{namespacekblib_aae5eb815715bae10bdcc0ea9475cfb7c}{kblib\+::split\+\_\+dsv}} (const String \&str, char delim) -\/$>$ Container \begin{DoxyCompactList}\small\item\em Split a string on all instances of delim. \end{DoxyCompactList}\item {\footnotesize template$<$typename Container = std\+::vector$<$std\+::string$>$, typename String , typename Predicate $>$ }\\auto \mbox{\hyperlink{namespacekblib_acbe121310e870b5e6281ce2a300c47f6}{kblib\+::split\+\_\+dsv}} (const String \&str, Predicate delim) -\/$>$ return\+\_\+assert\+\_\+t$<$ is\+\_\+callable$<$ Predicate, typename Container\+::value\+\_\+type\+::value\+\_\+type $>$\+::value, Container $>$ \begin{DoxyCompactList}\small\item\em Split a string on all instances of delim. \end{DoxyCompactList}\item {\footnotesize template$<$typename string $>$ }\\auto \mbox{\hyperlink{namespacekblib_a91ab01237b8d6ef57f55a74300815c6e}{kblib\+::reverse\+\_\+str}} (string val) -\/$>$ string \begin{DoxyCompactList}\small\item\em Reverses all the elements of its input. \end{DoxyCompactList}\item {\footnotesize template$<$typename CharT $>$ }\\auto \mbox{\hyperlink{namespacekblib_1_1detail_a837096897f96ab13aad120004c627f08}{kblib\+::detail\+::to\+\_\+int\+\_\+type}} (CharT ch) \item {\footnotesize template$<$typename CharT , typename IntT $>$ }\\auto \mbox{\hyperlink{namespacekblib_1_1detail_a144a5c91984c56014efceb17cd66800e}{kblib\+::detail\+::to\+\_\+char\+\_\+type}} (IntT ch) \item auto \mbox{\hyperlink{namespacekblib_1_1detail_a963222bf43702a2b2f274c59a76a26da}{kblib\+::detail\+::tolower}} (char ch) \item auto \mbox{\hyperlink{namespacekblib_1_1detail_a5c36259b747c433960c63641bd39c2af}{kblib\+::detail\+::towlower}} (wchar\+\_\+t ch) \item auto \mbox{\hyperlink{namespacekblib_1_1detail_a3d9c847e2f656fb6fed6f21b0339717d}{kblib\+::detail\+::toupper}} (char ch) \item auto \mbox{\hyperlink{namespacekblib_1_1detail_abf2db1653c3914ae47a28329b51986fe}{kblib\+::detail\+::towupper}} (wchar\+\_\+t ch) \item {\footnotesize template$<$typename string $>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_a4bd8237188786dec83b4d7f5e6d05139}{kblib\+::tolower}} (string str) -\/$>$ string \begin{DoxyCompactList}\small\item\em Folds all characters in a string using the default execution character set to lowercase. \end{DoxyCompactList}\item {\footnotesize template$<$typename string $>$ }\\auto \mbox{\hyperlink{namespacekblib_ac1094a7e020c9186d0e3a608f9ff70f4}{kblib\+::toupper}} (string str) -\/$>$ string \begin{DoxyCompactList}\small\item\em Folds all characters in a string using the default execution character set to uppercase. \end{DoxyCompactList}\item {\footnotesize template$<$typename string $>$ }\\auto \mbox{\hyperlink{namespacekblib_a5666bcdc72292d36178a604c518c1ba8}{kblib\+::repeat}} (string val, std\+::size\+\_\+t count) -\/$>$ string \begin{DoxyCompactList}\small\item\em Construct a string consisting of count copies of val concatenated together. \end{DoxyCompactList}\item auto \mbox{\hyperlink{namespacekblib_ae53be72bf8b3efff5d7a930ea6886cc0}{kblib\+::repeat}} (char val, std\+::size\+\_\+t count) -\/$>$ std\+::string \begin{DoxyCompactList}\small\item\em Construct a string consisting of count copies of val. \end{DoxyCompactList}\item auto \mbox{\hyperlink{namespacekblib_a7743f2e2f0dd3bd1542fa49368907206}{kblib\+::ends\+\_\+with}} (std\+::string\+\_\+view haystack, std\+::string\+\_\+view needle) -\/$>$ bool \begin{DoxyCompactList}\small\item\em Checks if a given string ends with a particular string. \end{DoxyCompactList}\item auto \mbox{\hyperlink{namespacekblib_a19adf8b75cebbc58c92f2ade7a3f2e87}{kblib\+::ends\+\_\+with}} (std\+::string\+\_\+view haystack, char needle) -\/$>$ bool \begin{DoxyCompactList}\small\item\em Checks if a given string ends with a particular string. \end{DoxyCompactList}\item auto \mbox{\hyperlink{namespacekblib_a43d878711202236ccdd3100d878e27f5}{kblib\+::starts\+\_\+with}} (std\+::string\+\_\+view haystack, std\+::string\+\_\+view needle) -\/$>$ bool \begin{DoxyCompactList}\small\item\em Checks if a given string starts with a particular string. \end{DoxyCompactList}\item auto \mbox{\hyperlink{namespacekblib_a07cac288890ce291ba1fe97874feba41}{kblib\+::starts\+\_\+with}} (std\+::string\+\_\+view haystack, char needle) -\/$>$ bool \begin{DoxyCompactList}\small\item\em Checks if a given string starts with a particular string. \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsection*{Variables} \begin{DoxyCompactItemize} \item {\footnotesize template$<$typename C $>$ }\\constexpr bool \mbox{\hyperlink{namespacekblib_a7161c2976d0e6426ae3a6fdd0d40bc54}{kblib\+::is\+\_\+character\+\_\+v}} = is\+\_\+character$<$C$>$\+::value \begin{DoxyCompactList}\small\item\em Equivalent to is\+\_\+character$<$\+C$>$\+::value. \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsection{Detailed Description} Provides utilities for performing common operations on strings. \begin{DoxyAuthor}{Author} killerbee \end{DoxyAuthor} \begin{DoxyDate}{Date} 2019-\/2021 \end{DoxyDate} \begin{DoxyCopyright}{Copyright} GNU General Public Licence v3.\+0 \end{DoxyCopyright} Definition in file \mbox{\hyperlink{stringops_8h_source}{stringops.\+h}}.