Anklang 0.3.0-460-gc4ef46ba
ASE — Anklang Sound Engine (C++)

« « « Anklang Documentation
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
strings.hh File Reference
#include <ase/cxxaux.hh>
#include <ase/formatter.hh>
#include <cstring>

Go to the source code of this file.

Classes

class  Ase::Strings
 Convenience Constructor for StringSeq or std::vector<std::string> More...
 

Namespaces

namespace  Ase
 The Anklang C++ API namespace.
 

Macros

#define ASE_STRING_SET_ASCII_ALNUM
 
#define ASE_STRING_SET_LOWER_ALNUM
 
#define ASE_STRING_VECTOR_FROM_ARRAY(ConstCharArray)
 
#define ASE_CQUOTE(str)
 

Functions

bool Ase::cstring_to_bool (const char *string, bool fallback)
 
const charAse::strrstr (const char *haystack, const char *needle)
 
const charAse::string_find_word (const char *haystack, const char *word)
 Find occurance of word in haystack.
 
String Ase::string_vprintf (const char *format, va_list vargs)
 Formatted printing ala vprintf() into a String, using the POSIX/C locale.
 
String Ase::string_locale_vprintf (const char *format, va_list vargs)
 Formatted printing like string_vprintf using the current locale.
 
String Ase::string_multiply (const String &s, uint64 count)
 Reproduce a string s for count times.
 
String Ase::string_canonify (const String &string, const String &valid_chars, const String &substitute)
 
String Ase::string_to_identifier (const String &input)
 Force lower case, alphanumerics + underscore and non-digit start.
 
bool Ase::string_is_canonified (const String &string, const String &valid_chars)
 Check if string_canonify() would modify string.
 
const StringAse::string_set_a2z ()
 Returns a string containing all of a-z.
 
const StringAse::string_set_A2Z ()
 Returns a string containing all of A-Z.
 
const StringAse::string_set_ascii_alnum ()
 Returns a string containing all of 0-9, A-Z and a-z.
 
bool Ase::string_is_ascii_alnum (const String &str)
 
bool Ase::string_islower (const String &str)
 Check if all string characters are Unicode lower case characters.
 
String Ase::string_tolower (const String &str)
 Convert all string characters into Unicode lower case characters.
 
bool Ase::string_isupper (const String &str)
 Check if all string characters are Unicode upper case characters.
 
String Ase::string_toupper (const String &str)
 Convert all string characters into Unicode upper case characters.
 
String Ase::string_totitle (const String &str)
 Convert all string characters into Unicode title characters.
 
String Ase::string_capitalize (const String &str, size_t maxn, bool rest_tolower)
 Capitalize words, so the first letter is upper case, the rest lower case.
 
StringS Ase::string_split (const String &string, const String &splitter, size_t maxn)
 
StringS Ase::string_split_any (const String &string, const String &splitchars, size_t maxn)
 
String Ase::string_join (const String &junctor, const StringS &strvec)
 
bool Ase::string_to_bool (const String &string, bool fallback)
 
String Ase::string_from_bool (bool value)
 Convert a boolean value into a string.
 
uint64 Ase::string_to_uint (const String &string, size_t *consumed, uint base)
 Parse a string into a 64bit unsigned integer, optionally specifying the expected number base.
 
String Ase::string_from_uint (uint64 value)
 Convert a 64bit unsigned integer into a string.
 
bool Ase::string_has_int (const String &string)
 Checks if a string contains a digit, optionally preceeded by whitespaces.
 
int64 Ase::string_to_int (const String &string, size_t *consumed, uint base)
 Parse a string into a 64bit integer, optionally specifying the expected number base.
 
String Ase::string_from_int (int64 value)
 Convert a 64bit signed integer into a string.
 
String Ase::string_from_float (float value)
 Convert a float into a string, using the POSIX/C locale.
 
long double Ase::string_to_long_double (const String &string)
 Parse a long double from a string, trying locale specific characters and POSIX/C formatting.
 
long double Ase::string_to_long_double (const char *dblstring, const char **endptr)
 Similar to string_to_long_double(const String&), but returns the first failing character position in endptr.
 
String Ase::string_from_long_double (long double value)
 Convert a long double into a string, using the POSIX/C locale.
 
double Ase::string_to_double (const String &string)
 Parse a double from a string, trying locale specific characters and POSIX/C formatting.
 
double Ase::string_to_double (const char *dblstring, const char **endptr)
 Similar to string_to_double(const String&), but returns the first failing character position in endptr.
 
String Ase::string_from_double (double value)
 Convert a double into a string, using the POSIX/C locale.
 
String Ase::string_from_float (double value)
 
double Ase::string_to_float (const String &string)
 
std::vector< doubleAse::string_to_double_vector (const String &string)
 Parse a string into a list of doubles, expects ';' as delimiter.
 
String Ase::string_from_double_vector (const std::vector< double > &dvec, const String &delim)
 Construct a string out of all double values passed in dvec, separated by delim.
 
double Ase::string_to_seconds (const String &string, double fallback)
 Parse string into seconds.
 
String Ase::string_from_errno (int errno_val)
 Returns a String describing the passed in errno value, similar to strerror().
 
bool Ase::string_is_uuid (const String &uuid_string)
 Returns whether uuid_string contains a properly formatted UUID string.
 
int Ase::string_cmp_uuid (const String &uuid_string1, const String &uuid_string2)
 Returns whether uuid_string1 compares smaller (-1), equal (0) or greater (+1) to uuid_string2.
 
bool Ase::string_startswith (const String &string, const String &fragment)
 Returns whether string starts with fragment.
 
bool Ase::string_startswith (const String &string, const StringS &fragments)
 Returns whether string starts with any element of fragments.
 
bool Ase::string_endswith (const String &string, const String &fragment)
 Returns whether string ends with fragment.
 
bool Ase::string_endswith (const String &string, const StringS &fragments)
 Returns whether string ends with any element of fragments.
 
bool Ase::string_match_identifier (const String &ident1, const String &ident2)
 Check equality of strings canonicalized to "[0-9a-z_]+".
 
bool Ase::string_match_identifier_tail (const String &ident, const String &tail)
 Variant of string_match_identifier() that matches tail against ident at word boundary.
 
String Ase::string_from_pretty_function_name (const char *cxx_pretty_function)
 
String Ase::string_to_cescape (const String &str)
 
String Ase::string_to_cquote (const String &str)
 Returns a string as C string including double quotes.
 
String Ase::string_from_cquote (const String &input)
 Parse a possibly quoted C string into regular string.
 
String Ase::string_url_decode (const String &urlstr, const bool form_url_encoded)
 Decode URL %-sequences in a string, decode '+' if form_url_encoded.
 
String Ase::string_url_encode (const String &rawstr, const bool form_url_encoded)
 Encode special characters to URL %-sequences, encode space as '+' if form_url_encoded.
 
String Ase::string_to_hex (const String &input)
 Convert bytes in string input to hexadecimal numbers.
 
String Ase::string_hexdump (const void *addr, size_t length, size_t initial_offset)
 
String Ase::string_lstrip (const String &input)
 Strip whitespaces from the left of a string.
 
String Ase::string_rstrip (const String &input)
 Strip whitespaces from the right of a string.
 
String Ase::string_strip (const String &input)
 Strip whitespaces from the left and right of a string.
 
String Ase::string_replace (const String &input, const String &marker, const String &replacement, size_t maxn)
 Replace substring marker in input with replacement, at most maxn times.
 
String Ase::string_substitute_char (const String &input, const char match, const char subst)
 Replace all occouranes of match in input with subst.
 
void Ase::string_vector_lstrip (StringS &svector)
 Left-strip all elements of a string vector, see string_lstrip().
 
void Ase::string_vector_rstrip (StringS &svector)
 Right-strip all elements of a string vector, see string_rstrip().
 
void Ase::string_vector_strip (StringS &svector)
 Strip all elements of a string vector, see string_strip().
 
void Ase::string_vector_erase_empty (StringS &svector)
 Remove empty elements from a string vector.
 
String Ase::string_vector_find (const StringS &svector, const String &prefix, const String &fallback)
 
String Ase::string_vector_find_value (const StringS &svector, const String &prefix, const String &fallback)
 
StringS Ase::cstrings_to_vector (const char *s,...)
 Construct a StringS from a NULL terminated list of string arguments.
 
void Ase::memset4 (uint32 *mem, uint32 filler, uint length)
 Fill a memory area with a 32-bit quantitiy.
 
long double Ase::posix_locale_strtold (const char *nptr, char **endptr)
 Parse a double from a string ala strtod(), trying locale specific characters and POSIX/C formatting.
 
long double Ase::current_locale_strtold (const char *nptr, char **endptr)
 Parse a double from a string ala strtod(), trying locale specific characters and POSIX/C formatting.
 
StringS Ase::strings_version_sort (const StringS &strings, bool reverse)
 
void Ase::strings_version_sort (StringS *strings, bool reverse)
 
String Ase::string_normalize_nfc (const String &src)
 Yield normalized composed UTF-8 string.
 
String Ase::string_normalize_nfd (const String &src)
 Yield normalized decomposed UTF-8 string.
 
String Ase::string_normalize_nfkc (const String &src)
 Formatting stripped normalized composed UTF-8 string.
 
String Ase::string_normalize_nfkd (const String &src)
 Formatting stripped normalized decomposed UTF-8 string.
 
String Ase::string_casefold (const String &src)
 Yield UTF-8 string useful for case insensitive comparisons.
 
int Ase::string_casecmp (const String &s1, const String &s2)
 Like strcasecmp(3) for UTF-8 strings.
 
int Ase::string_cmp (const String &s1, const String &s2)
 Like strcmp(3) for UTF-8 strings.
 
template<typename Type >
Type Ase::string_to_type (const String &string)
 Convert a string to template argument type, such as bool, int, double.
 
template<typename Type >
String Ase::string_from_type (Type value)
 Create a string from a templated argument value, such as bool, int, double.
 
template<>
long double Ase::string_to_type< long double > (const String &string)
 
template<>
String Ase::string_from_type< long double > (long double value)
 
template<>
double Ase::string_to_type< double > (const String &string)
 
template<>
String Ase::string_from_type< double > (double value)
 
template<>
float Ase::string_to_type< float > (const String &string)
 
template<>
String Ase::string_from_type< float > (float value)
 
template<>
bool Ase::string_to_type< bool > (const String &string)
 
template<>
String Ase::string_from_type< bool > (bool value)
 
template<>
int16 Ase::string_to_type< int16 > (const String &string)
 
template<>
String Ase::string_from_type< int16 > (int16 value)
 
template<>
uint16 Ase::string_to_type< uint16 > (const String &string)
 
template<>
String Ase::string_from_type< uint16 > (uint16 value)
 
template<>
int Ase::string_to_type< int > (const String &string)
 
template<>
String Ase::string_from_type< int > (int value)
 
template<>
uint Ase::string_to_type< uint > (const String &string)
 
template<>
String Ase::string_from_type< uint > (uint value)
 
template<>
int64 Ase::string_to_type< int64 > (const String &string)
 
template<>
String Ase::string_from_type< int64 > (int64 value)
 
template<>
uint64 Ase::string_to_type< uint64 > (const String &string)
 
template<>
String Ase::string_from_type< uint64 > (uint64 value)
 
template<>
String Ase::string_to_type< String > (const String &string)
 
template<>
String Ase::string_from_type< String > (String value)
 
bool Ase::string_option_check (const String &optionlist, const String &feature)
 Check if an option is set/unset in an options list string.
 
String Ase::string_option_find (const String &optionlist, const String &feature, const String &fallback)
 Retrieve the option value from an options list separated by ':' or ';' or fallback.
 
std::string_view Ase::string_option_find_value (const char *string, const char *feature, const char *fallback, const char *denied, bool matchallnone)
 Low level option search, avoids dynamic allocations.
 
String Ase::kvpair_key (const String &key_value_pair)
 
String Ase::kvpair_value (const String &key_value_pair)
 
String Ase::kvpairs_fetch (const StringS &kvs, const String &key, bool casesensitive)
 
ssize_t Ase::kvpairs_search (const StringS &kvs, const String &k, const bool casesensitive)
 
bool Ase::kvpairs_assign (StringS &kvs, const String &key_value_pair, bool casesensitive)
 
bool Ase::text_convert (const String &to_charset, String &output_string, const String &from_charset, const String &input_string, const String &fallback_charset, const String &output_mark)
 
const charAse::strerror (int errno_num)
 Get POSIX locale strerror.
 
const charAse::strerror ()
 

Macro Definition Documentation

◆ ASE_CQUOTE

#define ASE_CQUOTE (   str)

Definition at line 194 of file strings.hh.

◆ ASE_STRING_SET_ASCII_ALNUM

#define ASE_STRING_SET_ASCII_ALNUM

Definition at line 12 of file strings.hh.

◆ ASE_STRING_SET_LOWER_ALNUM

#define ASE_STRING_SET_LOWER_ALNUM

Definition at line 13 of file strings.hh.

◆ ASE_STRING_VECTOR_FROM_ARRAY

#define ASE_STRING_VECTOR_FROM_ARRAY (   ConstCharArray)

Definition at line 188 of file strings.hh.