kblib 0.2.3
General utilities library for modern C++
stringops.h File Reference

Provides utilities for performing common operations on strings. More...

#include "algorithm.h"
#include "format.h"
#include "tdecl.h"
#include "traits.h"
#include <algorithm>
#include <cctype>
#include <cwctype>
#include <initializer_list>
#include <numeric>
#include <string>
#include <type_traits>
#include <string_view>
Include dependency graph for stringops.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kblib::is_character< C >
 Determine if the given type, ignoring const or reference qualifiers, is a character type. More...
 
struct  kblib::detail::arithmetic_type< T, bool >
 Filter only arithmetic types. More...
 
struct  kblib::detail::arithmetic_type< T, true >
 Filter only arithmetic types. More...
 
struct  kblib::detail::str_type< T, typename >
 Converts arithmetic types to strings, but provides the identity transformation for all other types. More...
 
struct  kblib::detail::str_type< T, void >
 Performs a natural conversion to a stringlike type. More...
 
struct  kblib::detail::str_type< char, char >
 Override for char to avoid conversion to integer. More...
 
struct  kblib::detail::str_type< wchar_t, wchar_t >
 Override for wchar_t to avoid conversion to integer. More...
 
struct  kblib::detail::str_type< char16_t, char16_t >
 Override for char16_t to avoid conversion to integer. More...
 
struct  kblib::detail::str_type< char32_t, char32_t >
 Override for char32_t to avoid conversion to integer. More...
 
struct  kblib::detail::value< I, T >
 
struct  kblib::detail::values< std::index_sequence< Idxs... >, Ts... >
 
struct  kblib::is_space
 

Namespaces

namespace  kblib
 The main namespace in which all entities from kblib are defined.
 
namespace  kblib::detail
 The namespace used for implementation details within kblib.
 

Typedefs

template<typename T >
using kblib::detail::arithmetic_type_t = typename arithmetic_type< T >::type
 Equivalent to typename arithmetic_type<T>::type. More...
 
template<typename T >
using kblib::detail::str_type_t = typename str_type< T >::type
 Provides the natural stringlike type for representing a T. More...
 

Functions

template<typename Str >
auto kblib::strsize (Str &&str) -> std::size_t
 Determines the size in characters of any valid argument to concat or append. More...
 
template<typename CharT >
constexpr auto kblib::length (const CharT *str) noexcept -> std::size_t
 
template<typename string , typename F , typename... S>
auto kblib::append (string &&out, F &&f, S &&... tail) -> void
 Given an object out of resizable stringlike type string, appends all other arguments to it. More...
 
template<typename string , typename... S, std::size_t... I>
auto kblib::detail::concat_impl (std::index_sequence< I... >, S &&... ins) -> string
 
template<typename string = std::string, typename F , typename... S>
auto kblib::concat (F &&f, S &&... ins) -> string
 Returns a string consisting of the concatenation of all arguments. More...
 
template<typename string = std::string, typename str >
auto kblib::concat (std::initializer_list< str > ins) -> string
 Returns a string consisting of the concatenation of all elements of an initializer list. More...
 
auto kblib::isspace (char c) -> bool
 
auto kblib::isspace (wchar_t c) -> bool
 
constexpr auto kblib::isAspace (char c) -> bool
 
constexpr auto kblib::isAspace (wchar_t c) -> bool
 
template<typename range , typename string = std::string>
auto kblib::join (const range &in, const string &joiner="")
 Concatenates all elements of a range together with an optional joiner. More...
 
template<typename Container = std::vector<std::string>, typename Predicate , typename String >
auto kblib::split_tokens (const String &in, Predicate spacer) -> return_assert_t< is_callable< Predicate, typename Container::value_type::value_type >::value, Container >
 Split a string on all condensed delimiters. More...
 
template<typename Container = std::vector<std::string>, typename String >
auto kblib::split_tokens (const String &in) -> Container
 Split a string on all instances of whitespace. More...
 
template<typename Container = std::vector<std::string>, typename String >
auto kblib::split_tokens (const String &in, typename Container::value_type::value_type delim) -> Container
 Split a string on all instances of a delimiter. More...
 
template<typename Container = std::vector<std::string>, typename String >
auto kblib::kbsplit2 (const String &in, char delim=' ') -> Container
 
template<typename Container = std::vector<std::string>, typename String >
auto kblib::split_dsv (const String &str, char delim) -> Container
 Split a string on all instances of delim. More...
 
template<typename Container = std::vector<std::string>, typename String , typename Predicate >
auto kblib::split_dsv (const String &str, Predicate delim) -> return_assert_t< is_callable< Predicate, typename Container::value_type::value_type >::value, Container >
 Split a string on all instances of delim. More...
 
template<typename string >
auto kblib::reverse_str (string val) -> string
 Reverses all the elements of its input. More...
 
template<typename CharT >
auto kblib::detail::to_int_type (CharT ch)
 
template<typename CharT , typename IntT >
auto kblib::detail::to_char_type (IntT ch)
 
auto kblib::detail::tolower (char ch)
 
auto kblib::detail::towlower (wchar_t ch)
 
auto kblib::detail::toupper (char ch)
 
auto kblib::detail::towupper (wchar_t ch)
 
template<typename string >
constexpr auto kblib::tolower (string str) -> string
 Folds all characters in a string using the default execution character set to lowercase. More...
 
template<typename string >
auto kblib::toupper (string str) -> string
 Folds all characters in a string using the default execution character set to uppercase. More...
 
template<typename string >
auto kblib::repeat (string val, std::size_t count) -> string
 Construct a string consisting of count copies of val concatenated together. More...
 
auto kblib::repeat (char val, std::size_t count) -> std::string
 Construct a string consisting of count copies of val. More...
 
auto kblib::ends_with (std::string_view haystack, std::string_view needle) -> bool
 Checks if a given string ends with a particular string. More...
 
auto kblib::ends_with (std::string_view haystack, char needle) -> bool
 Checks if a given string ends with a particular string. More...
 
auto kblib::starts_with (std::string_view haystack, std::string_view needle) -> bool
 Checks if a given string starts with a particular string. More...
 
auto kblib::starts_with (std::string_view haystack, char needle) -> bool
 Checks if a given string starts with a particular string. More...
 

Variables

template<typename C >
constexpr bool kblib::is_character_v = is_character<C>::value
 Equivalent to is_character<C>::value. More...
 

Detailed Description

Provides utilities for performing common operations on strings.

Author
killerbee
Date
2019-2021

Definition in file stringops.h.