Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
Loading...
Searching...
No Matches
strings.h File Reference
#include "elementa/license.inc"
#include "elementa/checks.inc"
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <type_traits>
#include <sstream>
#include <bitset>
#include <iomanip>
#include <functional>
#include <cctype>
#include <limits>
#include "elementa/base/fundamentaltypes.h"
Include dependency graph for strings.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  elementa::base::is_charlike< T >
 Return TRUE if type T is char, wchar_t, char16_t or char32_t. More...
 
struct  elementa::base::is_charlike< char >
 Specialization of is_charlike for char. More...
 
struct  elementa::base::is_charlike< wchar_t >
 Specialization of is_charlike for wchar_t. More...
 
struct  elementa::base::is_charlike< char16_t >
 Specialization of is_charlike for char16_t. More...
 
struct  elementa::base::is_charlike< char32_t >
 Specialization of is_charlike for char32_t. More...
 
struct  elementa::base::IsStringHelperPriv< T >
 A struct with a void member. More...
 
struct  elementa::base::is_string< T, Enable >
 Template class to check whether T is derived from std::basic_string. More...
 
struct  elementa::base::is_string< T, typename IsStringHelperPriv< typename T::value_type, typename T::traits_type, typename T::allocator_type >::type >
 
class  elementa::base::Strings
 A number of strings. More...
 

Functions

bool elementa::base::is_all_upper (const std::string &s) noexcept
 Return TRUE if all characters in S are uppercase. More...
 
bool elementa::base::is_all_lower (const std::string &s) noexcept
 Return TRUE if all characters in S are lowercase. More...
 
constexpr bool elementa::base::is_hex_digit (char c) noexcept
 Return TRUE if C is an hexadecimal digit, either in lower or uppercase. More...
 
bool elementa::base::is_identifier (const std::string &s)
 Return TRUE if S is a standard identifier. More...
 
bool elementa::base::is_number (const std::string &s, uint8_t base=10, bool onlyint=false)
 Return TRUE if S contains a number (possibly with sign) in some base. More...
 
constexpr bool elementa::base::is_linechanger (char c)
 Return TRUE if C is a character involved in changing to new lines of text. More...
 
constexpr bool elementa::base::is_blank (char c)
 Return TRUE if C is a tab or space character. More...
 
constexpr bool elementa::base::is_separator (char c)
 Return TRUE if C is a separator character. More...
 
const std::vector< uint8_t > & elementa::base::bytes_for_eol (void)
 Return a vector containing the bytes that form std::endl in this machine.
 
template<typename NumType >
std::string elementa::base::to_string_dec (NumType n, bool padding=true)
 Convert an integral number to string in decimal format. More...
 
template<>
std::string elementa::base::to_string_dec (uint8_t n, bool padding)
 Convert an integral number to string in decimal format. More...
 
template<typename NumType >
std::string elementa::base::to_string_hex (NumType n, bool padding=true)
 Convert an integral number to string in hexadecimal format, without preffix. More...
 
template<typename NumType >
std::string elementa::base::to_string_bin (NumType n, bool padding=true)
 Convert an integral number to string in binary format. More...
 
template<typename NumType >
std::string elementa::base::to_string_oct (NumType n, bool padding=true)
 Convert an integral number to string in octal format. More...
 
template<typename NumType >
NumType elementa::base::from_string_hex (const std::string &txt)
 Return the unsigned int. value of a number expressed in hexadecimal form. More...
 
template<typename NumType >
NumType elementa::base::from_string_bin (const std::string &txt)
 Return the unsigned int. value of a number expressed in binary form. More...
 
std::string elementa::base::real_to_string (LongestReal n)
 Convert a N to string with high precision. More...
 
std::string elementa::base::real_to_string_fixdec (LongestReal n, unsigned ds)
 Convert N to string with a fixed number of decimal digits. *‍/.
 
std::string elementa::base::char_to_string (char c)
 Convert a char to a string of 1 char. More...
 
template<typename PointedType >
std::string elementa::base::hexdump (const PointedType *data, size_t howmany, bool toupp=true, bool sepelems=true)
 Return a string that represents all hex codes of the pointed bytes. More...
 
std::string elementa::base::toCase (const std::string &s, char to)
 Convert a string into upper ('U') or lower ('L') case.
 
std::string & elementa::base::ltrim_mut (std::string &s)
 Remove left space-like characters, modifying the input string directly. More...
 
std::string elementa::base::ltrim (const std::string &s)
 Remove left space-like characters, creating a new string with the result. More...
 
std::string & elementa::base::rtrim_mut (std::string &s)
 Remove right space-like characters, modifying the input string directly. More...
 
std::string elementa::base::rtrim (const std::string &s)
 Remove right space-like characters, creating a new string with the result. More...
 
std::string & elementa::base::trim_mut (std::string &s)
 Remove both right and left space-like characters, directly on input string. More...
 
std::string elementa::base::trim (const std::string &s)
 Remove both right and left space-like characters, creating new string. More...
 
void elementa::base::pad (std::string &s, size_t len, bool leftorright=false, char padding=' ')
 Pad S with character PADDING if shorter than LEN. More...
 
void elementa::base::chop (std::string &s, size_t len, char excess=0x00, bool leftorright=false, char padding=' ')
 Chop S to a string of length LEN, padding it if necessary. More...
 
std::vector< std::string > elementa::base::split (const std::string &s, char delim)
 Split a string through a given delimiter. More...
 
std::string elementa::base::concatWithMiddle (const std::string &s1, const std::string &s2, const std::string &m=". ")
 Concatenate two strings putting a middle one only if the second is not empty.
 
std::string elementa::base::indentlinedtext (const std::string &txt, bool atstarttoo=false, std::string::size_type maxlinelength=80, const std::string &newlinepreffix=" ", const std::string &newlinetext="\n")
 Return a string after splitting it into a number of indented lines. More...