rapidyaml 0.14.0
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
c4 Namespace Reference

(Undefined by default) Use shorter error message from checks/asserts: do not show the check condition in the error message. More...

Namespaces

namespace  yml
namespace  fmt

Classes

struct  is_string
 a traits class to mark a type as a string type, meaning c4::to_csubstr() can be used directly instead of c4::to_chars() when formatting the string. More...
struct  is_writeable_string
 a traits class to mark a type as a writeable string type, meaning c4::to_substr() can be used directly instead of c4::from_chars() when reading the string. More...
struct  is_string< basic_substring< C > >
struct  is_string< const basic_substring< char > >
struct  is_string< const basic_substring< const char > >
struct  is_writeable_string< basic_substring< char > >
struct  is_writeable_string< const basic_substring< char > >
struct  is_compatible_char_ptr
struct  can_borrow_char_ptr
struct  basic_substring
 a non-owning string-view, consisting of a character pointer and a length. More...
struct  is_string< std::string >
struct  is_string< const std::string >
struct  is_writeable_string< std::string >
struct  is_string< std::string_view >
struct  is_string< const std::string_view >
struct  is_string< std::vector< char, Alloc > >
struct  is_string< const std::vector< char, Alloc > >
struct  is_writeable_string< std::vector< char, Alloc > >

Typedefs

using substr = basic_substring<char>
 a mutable string view
using csubstr = basic_substring<const char>
 an immutable string view

Enumerations

enum  RealFormat_e : char { FTOA_FLOAT = 'f' , FTOA_SCIENT = 'e' , FTOA_FLEX = 'g' , FTOA_HEXA = 'a' }

Functions

template<>
c4::EnumSymbols< yml::extra::ievt::EventFlagsesyms< yml::extra::ievt::EventFlags > ()
template<size_t N>
substr to_substr (char(&s)[N]) noexcept
template<size_t N>
csubstr to_csubstr (const char(&s)[N]) noexcept
template<class U>
auto to_substr (U s) noexcept -> typename std::enable_if< is_compatible_char_ptr< U, char >::value, substr >::type
 Create a substring from a C-string (char*-like pointer).
template<class U>
auto to_csubstr (U s) noexcept -> typename std::enable_if< is_compatible_char_ptr< U, const char >::value, csubstr >::type
 Create a substring from a const char*-like pointer.
substr to_substr (substr s) noexcept
csubstr to_csubstr (substr s) noexcept
csubstr to_csubstr (csubstr s) noexcept
template<typename C>
bool operator== (const char c, basic_substring< C > const that) noexcept
template<typename C>
bool operator!= (const char c, basic_substring< C > const that) noexcept
template<typename C>
bool operator< (const char c, basic_substring< C > const that) noexcept
template<typename C>
bool operator> (const char c, basic_substring< C > const that) noexcept
template<typename C>
bool operator<= (const char c, basic_substring< C > const that) noexcept
template<typename C>
bool operator>= (const char c, basic_substring< C > const that) noexcept
template<typename C, size_t N>
bool operator== (const char(&arr)[N], basic_substring< C > const that) noexcept
template<typename C, size_t N>
bool operator!= (const char(&arr)[N], basic_substring< C > const that) noexcept
template<typename C, size_t N>
bool operator< (const char(&arr)[N], basic_substring< C > const that) noexcept
template<typename C, size_t N>
bool operator> (const char(&arr)[N], basic_substring< C > const that) noexcept
template<typename C, size_t N>
bool operator<= (const char(&arr)[N], basic_substring< C > const that) noexcept
template<typename C, size_t N>
bool operator>= (const char(&arr)[N], basic_substring< C > const that) noexcept
template<typename U, typename C>
auto operator== (U c_str, basic_substring< C > const that) noexcept -> typename std::enable_if< is_compatible_char_ptr< U, C >::value, bool >::type
template<typename U, typename C>
auto operator!= (U c_str, basic_substring< C > const that) noexcept -> typename std::enable_if< is_compatible_char_ptr< U, C >::value, bool >::type
template<typename U, typename C>
auto operator< (U c_str, basic_substring< C > const that) noexcept -> typename std::enable_if< is_compatible_char_ptr< U, C >::value, bool >::type
template<typename U, typename C>
auto operator> (U c_str, basic_substring< C > const that) noexcept -> typename std::enable_if< is_compatible_char_ptr< U, C >::value, bool >::type
template<typename U, typename C>
auto operator<= (U c_str, basic_substring< C > const that) noexcept -> typename std::enable_if< is_compatible_char_ptr< U, C >::value, bool >::type
template<typename U, typename C>
auto operator>= (U c_str, basic_substring< C > const that) noexcept -> typename std::enable_if< is_compatible_char_ptr< U, C >::value, bool >::type
template<class OStream, class C>
OStream & operator<< (OStream &os, basic_substring< C > s)
 output the string to an ostream-like type
template<class T>
auto digits_dec (T v) noexcept -> typename std::enable_if< sizeof(T)==1u, unsigned >::type
 decimal digits for 8 bit integers
template<class T>
auto digits_dec (T v) noexcept -> typename std::enable_if< sizeof(T)==2u, unsigned >::type
 decimal digits for 16 bit integers
template<class T>
auto digits_dec (T v) noexcept -> typename std::enable_if< sizeof(T)==4u, unsigned >::type
 decimal digits for 32 bit integers
template<class T>
auto digits_dec (T v) noexcept -> typename std::enable_if< sizeof(T)==8u, unsigned >::type
 decimal digits for 64 bit integers
template<class T>
unsigned digits_hex (T v) noexcept
 return the number of digits required to encode an hexadecimal number.
template<class T>
unsigned digits_bin (T v) noexcept
 return the number of digits required to encode a binary number.
template<class T>
unsigned digits_oct (T v_) noexcept
 return the number of digits required to encode an octal number.
template<class T>
void write_dec_unchecked (substr buf, T v, unsigned digits_v) noexcept
template<class T>
void write_hex_unchecked (substr buf, T v, unsigned digits_v) noexcept
template<class T>
void write_oct_unchecked (substr buf, T v, unsigned digits_v) noexcept
template<class T>
void write_bin_unchecked (substr buf, T v, unsigned digits_v) noexcept
template<class T>
size_t write_dec (substr buf, T v) noexcept
 write an integer to a string in decimal format.
template<class T>
size_t write_hex (substr buf, T v) noexcept
 write an integer to a string in hexadecimal format.
template<class T>
size_t write_oct (substr buf, T v) noexcept
 write an integer to a string in octal format.
template<class T>
size_t write_bin (substr buf, T v) noexcept
 write an integer to a string in binary format.
template<class T>
size_t write_dec (substr buf, T val, size_t num_digits) noexcept
 same as c4::write_dec(), but pad with zeroes on the left such that the resulting string is num_digits wide.
template<class T>
size_t write_hex (substr buf, T val, size_t num_digits) noexcept
 same as c4::write_hex(), but pad with zeroes on the left such that the resulting string is num_digits wide.
template<class T>
size_t write_bin (substr buf, T val, size_t num_digits) noexcept
 same as c4::write_bin(), but pad with zeroes on the left such that the resulting string is num_digits wide.
template<class T>
size_t write_oct (substr buf, T val, size_t num_digits) noexcept
 same as c4::write_oct(), but pad with zeroes on the left such that the resulting string is num_digits wide.
template<class I>
bool read_dec (csubstr s, I *v) noexcept
 read a decimal integer from a string.
template<class I>
bool read_hex (csubstr s, I *v) noexcept
 read an hexadecimal integer from a string.
template<class I>
bool read_bin (csubstr s, I *v) noexcept
 read a binary integer from a string.
template<class I>
bool read_oct (csubstr s, I *v) noexcept
 read an octal integer from a string.
template<class T>
size_t itoa (substr buf, T v) noexcept
 convert an integral signed decimal to a string.
template<class T>
size_t itoa (substr buf, T v, T radix) noexcept
 convert an integral signed integer to a string, using a specific radix.
template<class T>
size_t itoa (substr buf, T v, T radix, size_t num_digits) noexcept
 same as c4::itoa(), but pad with zeroes on the left such that the resulting string is num_digits wide, not accounting for radix prefix (0x,0o,0b).
template<class T>
size_t utoa (substr buf, T v) noexcept
 convert an integral unsigned decimal to a string.
template<class T>
size_t utoa (substr buf, T v, T radix) noexcept
 convert an integral unsigned integer to a string, using a specific radix.
template<class T>
size_t utoa (substr buf, T v, T radix, size_t num_digits) noexcept
 same as c4::utoa(), but pad with zeroes on the left such that the resulting string is num_digits wide.
template<class T>
bool atoi (csubstr str, T *v) noexcept
 Convert a trimmed string to a signed integral value.
template<class T>
size_t atoi_first (csubstr str, T *v)
 Select the next range of characters in the string that can be parsed as a signed integral value, and convert it using atoi().
template<class T>
bool atou (csubstr str, T *v) noexcept
 Convert a trimmed string to an unsigned integral value.
template<class T>
size_t atou_first (csubstr str, T *v)
 Select the next range of characters in the string that can be parsed as an unsigned integral value, and convert it using atou().
template<class T>
auto overflows (csubstr str) noexcept -> typename std::enable_if< std::is_unsigned< T >::value, bool >::type
 Test if the following string would overflow when converted to associated integral types; this function is dispatched with SFINAE to handle differently signed and unsigned types.
template<class T>
auto overflows (csubstr str) noexcept -> typename std::enable_if< std::is_signed< T >::value, bool >::type
 Test if the following string would overflow when converted to associated integral types; this function is dispatched with SFINAE to handle differently signed and unsigned types.
size_t ftoa (substr str, float v, int precision=-1, RealFormat_e formatting=FTOA_FLEX) noexcept
 Convert a single-precision real number to string.
size_t dtoa (substr str, double v, int precision=-1, RealFormat_e formatting=FTOA_FLEX) noexcept
 Convert a double-precision real number to string.
bool atof (csubstr str, float *v) noexcept
 Convert a string to a single precision real number.
size_t atof_first (csubstr str, float *v) noexcept
 Convert a string to a single precision real number.
bool atod (csubstr str, double *v) noexcept
 Convert a string to a double precision real number.
size_t atod_first (csubstr str, double *v) noexcept
 Convert a string to a double precision real number.
size_t xtoa (substr s, uint8_t v) noexcept
size_t xtoa (substr s, uint16_t v) noexcept
size_t xtoa (substr s, uint32_t v) noexcept
size_t xtoa (substr s, uint64_t v) noexcept
size_t xtoa (substr s, int8_t v) noexcept
size_t xtoa (substr s, int16_t v) noexcept
size_t xtoa (substr s, int32_t v) noexcept
size_t xtoa (substr s, int64_t v) noexcept
size_t xtoa (substr s, float v) noexcept
size_t xtoa (substr s, double v) noexcept
size_t xtoa (substr s, uint8_t v, uint8_t radix) noexcept
size_t xtoa (substr s, uint16_t v, uint16_t radix) noexcept
size_t xtoa (substr s, uint32_t v, uint32_t radix) noexcept
size_t xtoa (substr s, uint64_t v, uint64_t radix) noexcept
size_t xtoa (substr s, int8_t v, int8_t radix) noexcept
size_t xtoa (substr s, int16_t v, int16_t radix) noexcept
size_t xtoa (substr s, int32_t v, int32_t radix) noexcept
size_t xtoa (substr s, int64_t v, int64_t radix) noexcept
size_t xtoa (substr s, uint8_t v, uint8_t radix, size_t num_digits) noexcept
size_t xtoa (substr s, uint16_t v, uint16_t radix, size_t num_digits) noexcept
size_t xtoa (substr s, uint32_t v, uint32_t radix, size_t num_digits) noexcept
size_t xtoa (substr s, uint64_t v, uint64_t radix, size_t num_digits) noexcept
size_t xtoa (substr s, int8_t v, int8_t radix, size_t num_digits) noexcept
size_t xtoa (substr s, int16_t v, int16_t radix, size_t num_digits) noexcept
size_t xtoa (substr s, int32_t v, int32_t radix, size_t num_digits) noexcept
size_t xtoa (substr s, int64_t v, int64_t radix, size_t num_digits) noexcept
size_t xtoa (substr s, float v, int precision, RealFormat_e formatting=FTOA_FLEX) noexcept
size_t xtoa (substr s, double v, int precision, RealFormat_e formatting=FTOA_FLEX) noexcept
template<class T>
auto xtoa (substr buf, T v) noexcept -> size_t::type
template<class T>
size_t xtoa (substr s, T *v) noexcept
bool atox (csubstr s, uint8_t *v) noexcept
bool atox (csubstr s, uint16_t *v) noexcept
bool atox (csubstr s, uint32_t *v) noexcept
bool atox (csubstr s, uint64_t *v) noexcept
bool atox (csubstr s, int8_t *v) noexcept
bool atox (csubstr s, int16_t *v) noexcept
bool atox (csubstr s, int32_t *v) noexcept
bool atox (csubstr s, int64_t *v) noexcept
bool atox (csubstr s, float *v) noexcept
bool atox (csubstr s, double *v) noexcept
template<class T>
auto atox (csubstr buf, T *v) noexcept -> bool::type
template<class T>
bool atox (csubstr s, T **v) noexcept
size_t to_chars (substr buf, uint8_t v) noexcept
size_t to_chars (substr buf, uint16_t v) noexcept
size_t to_chars (substr buf, uint32_t v) noexcept
size_t to_chars (substr buf, uint64_t v) noexcept
size_t to_chars (substr buf, int8_t v) noexcept
size_t to_chars (substr buf, int16_t v) noexcept
size_t to_chars (substr buf, int32_t v) noexcept
size_t to_chars (substr buf, int64_t v) noexcept
size_t to_chars (substr buf, float v) noexcept
size_t to_chars (substr buf, double v) noexcept
template<class T>
auto to_chars (substr buf, T v) noexcept -> size_t::type
template<class T>
auto to_chars (substr s, T *v) noexcept -> typename std::enable_if<!std::is_same< T, char >::value &&!std::is_same< T, const char >::value, size_t >::type
bool from_chars (csubstr buf, uint8_t *v) noexcept
bool from_chars (csubstr buf, uint16_t *v) noexcept
bool from_chars (csubstr buf, uint32_t *v) noexcept
bool from_chars (csubstr buf, uint64_t *v) noexcept
bool from_chars (csubstr buf, int8_t *v) noexcept
bool from_chars (csubstr buf, int16_t *v) noexcept
bool from_chars (csubstr buf, int32_t *v) noexcept
bool from_chars (csubstr buf, int64_t *v) noexcept
bool from_chars (csubstr buf, float *v) noexcept
bool from_chars (csubstr buf, double *v) noexcept
template<class T>
auto from_chars (csubstr buf, T *v) noexcept -> bool::type
template<class T>
bool from_chars (csubstr buf, T **v) noexcept
size_t from_chars_first (csubstr buf, uint8_t *v) noexcept
size_t from_chars_first (csubstr buf, uint16_t *v) noexcept
size_t from_chars_first (csubstr buf, uint32_t *v) noexcept
size_t from_chars_first (csubstr buf, uint64_t *v) noexcept
size_t from_chars_first (csubstr buf, int8_t *v) noexcept
size_t from_chars_first (csubstr buf, int16_t *v) noexcept
size_t from_chars_first (csubstr buf, int32_t *v) noexcept
size_t from_chars_first (csubstr buf, int64_t *v) noexcept
size_t from_chars_first (csubstr buf, float *v) noexcept
size_t from_chars_first (csubstr buf, double *v) noexcept
template<class T>
auto from_chars_first (csubstr buf, T *v) noexcept -> size_t::type
template<class T>
size_t from_chars_first (csubstr buf, T **v) noexcept
template<class T>
substr to_chars_sub (substr buf, T const &v) noexcept
 call to_chars() and return a substr consisting of the written portion of the input buffer.
size_t to_chars (substr buf, bool v) noexcept
bool from_chars (csubstr buf, bool *v) noexcept
size_t from_chars_first (csubstr buf, bool *v) noexcept
size_t to_chars (substr buf, char v) noexcept
bool from_chars (csubstr buf, char *v) noexcept
 extract a single character from a substring
size_t from_chars_first (csubstr buf, char *v) noexcept
size_t to_chars (substr buf, csubstr v) noexcept
bool from_chars (csubstr buf, csubstr *v) noexcept
size_t from_chars_first (csubstr buf, csubstr *v) noexcept
size_t to_chars (substr buf, substr v) noexcept
bool from_chars (csubstr buf, substr *v) noexcept
size_t from_chars_first (csubstr buf, substr *v) noexcept
template<size_t N>
size_t to_chars (substr buf, const char(&v)[N]) noexcept
 (1) overload for char(&)[N] and const char(&)[N]
template<class CharPtr>
auto to_chars (substr buf, CharPtr v) noexcept -> typename std::enable_if< std::is_same< CharPtr, char * >::value||std::is_same< CharPtr, const char * >::value, size_t >::type
 (2) overload for char* and const char*.
size_t to_chars (substr, std::nullptr_t) noexcept
size_t to_chars (substr buf, fmt::boolalpha_ fmt)
 write a variable as an alphabetic boolean, ie as either true or false
template<typename T>
auto to_chars (substr buf, fmt::integral_< T > fmt) -> typename std::enable_if< std::is_signed< T >::value, size_t >::type
 format an integer signed type
template<typename T>
auto to_chars (substr buf, fmt::integral_padded_< T > fmt) -> typename std::enable_if< std::is_signed< T >::value, size_t >::type
 format an integer signed type, pad with zeroes
template<typename T>
auto to_chars (substr buf, fmt::integral_< T > fmt) -> typename std::enable_if< std::is_unsigned< T >::value, size_t >::type
 format an integer unsigned type
template<typename T>
auto to_chars (substr buf, fmt::integral_padded_< T > fmt) -> typename std::enable_if< std::is_unsigned< T >::value, size_t >::type
 format an integer unsigned type, pad with zeroes
template<class T>
bool from_chars (csubstr s, fmt::overflow_checked_< T > wrapper)
 read an integer type, detecting overflow (returns false on overflow)
template<class T>
bool from_chars (csubstr s, fmt::overflow_checked_< T > *wrapper)
 read an integer type, detecting overflow (returns false on overflow)
size_t to_chars (substr buf, fmt::real_< float > fmt)
size_t to_chars (substr buf, fmt::real_< double > fmt)
size_t to_chars (substr buf, fmt::const_raw_wrapper r)
 write a variable in raw binary format, using memcpy
bool from_chars (csubstr buf, fmt::raw_wrapper *r)
 read a variable in raw binary format, using memcpy
bool from_chars (csubstr buf, fmt::raw_wrapper r)
 read a variable in raw binary format, using memcpy
size_t from_chars_first (csubstr buf, fmt::raw_wrapper *r)
 read a variable in raw binary format, using memcpy
size_t from_chars_first (csubstr buf, fmt::raw_wrapper r)
 read a variable in raw binary format, using memcpy
template<class T>
size_t to_chars (substr buf, fmt::left_< T > const &align)
template<class T>
size_t to_chars (substr buf, fmt::right_< T > const &align)
template<class T>
size_t to_chars (substr buf, fmt::center_< T > const &align)
template<class Arg, class... Args>
size_t cat (substr buf, Arg const &a, Args const &...more)
 serialize the arguments, concatenating them to the given fixed-size buffer.
template<class... Args>
substr cat_sub (substr buf, Args const &...args)
 like c4::cat() but return a substr instead of a size
template<class Arg, class... Args>
size_t uncat (csubstr buf, Arg &a, Args &...more)
 deserialize the arguments from the given buffer.
template<class Sep, class Arg, class... Args>
size_t catsep (substr buf, Sep const &sep, Arg const &a, Args const &...more)
 serialize the arguments, concatenating them to the given fixed-size buffer, using a separator between each argument.
template<class... Args>
substr catsep_sub (substr buf, Args &&...args)
 like c4::catsep() but return a substr instead of a size
template<class Arg, class... Args>
size_t uncatsep (csubstr buf, csubstr sep, Arg &a, Args &...more)
 deserialize the arguments from the given buffer, using a separator.
template<class Arg, class... Args>
size_t format (substr buf, csubstr fmt, Arg const &a, Args const &...more)
 Using a format string, serialize the arguments into the given fixed-size buffer.
template<class... Args>
substr format_sub (substr buf, csubstr fmt, Args const &...args)
 like c4::format() but return a substr instead of a size
template<class Arg, class... Args>
size_t unformat (csubstr buf, csubstr fmt, Arg &a, Args &...more)
 using a format string, deserialize the arguments from the given buffer.
template<class CharOwningContainer, class... Args>
void catrs (CharOwningContainer *cont, Args const &...args)
 cat+resize: like c4::cat(), but receives a container, and resizes it as needed to contain the result.
template<class CharOwningContainer, class... Args>
CharOwningContainer catrs (Args const &...args)
 cat+resize: like c4::cat(), but creates and returns a new container sized as needed to contain the result.
template<class CharOwningContainer, class... Args>
csubstr catrs_append (CharOwningContainer *cont, Args const &...args)
 cat+resize+append: like c4::cat(), but receives a container, and appends to it instead of overwriting it.
template<class CharOwningContainer, class Sep, class... Args>
void catseprs (CharOwningContainer *cont, Sep const &sep, Args const &...args)
 catsep+resize: like c4::catsep(), but receives a container, and resizes it as needed to contain the result.
template<class CharOwningContainer, class Sep, class... Args>
CharOwningContainer catseprs (Sep const &sep, Args const &...args)
 catsep+resize: like c4::catsep(), but create a new container with the result.
template<class CharOwningContainer, class Sep, class... Args>
csubstr catseprs_append (CharOwningContainer *cont, Sep const &sep, Args const &...args)
 catsep+resize+append: like c4::catsep(), but receives a container, and appends the arguments, resizing the container as needed to contain the result.
template<class CharOwningContainer, class... Args>
void formatrs (CharOwningContainer *cont, csubstr fmt, Args const &...args)
 format+resize: like c4::format(), but receives a container, and resizes it as needed to contain the result.
template<class CharOwningContainer, class... Args>
CharOwningContainer formatrs (csubstr fmt, Args const &...args)
 format+resize: like c4::format(), but create a new container with the result.
template<class CharOwningContainer, class... Args>
csubstr formatrs_append (CharOwningContainer *cont, csubstr fmt, Args const &...args)
 format+resize+append: like c4::format(), but receives a container, and appends the arguments, resizing the container as needed to contain the result.
bool base64_valid (const char *encoded, size_t encoded_sz)
 check that the given buffer is a valid base64 encoding
size_t base64_encode (char *encoded, size_t encoded_sz, void const *data, size_t data_sz)
 base64-encode binary data.
bool base64_decode (char const *encoded, size_t encoded_sz, void *data, size_t data_sz, size_t *data_sz_required)
 decode the base64 encoding in the given buffer.
substr skip_bom (substr s)
 skip the Byte Order Mark, or get the full string if there is Byte Order Mark.
csubstr skip_bom (csubstr s)
 skip the Byte Order Mark, or get the full string if there is Byte Order Mark
substr get_bom (substr s)
 get the Byte Order Mark, or an empty string if there is no Byte Order Mark
csubstr get_bom (csubstr s)
 get the Byte Order Mark, or an empty string if there is no Byte Order Mark
size_t first_non_bom (csubstr s)
 return the position of the first character not belonging to the Byte Order Mark, or 0 if there is no Byte Order Mark.
substr decode_code_point (substr out, csubstr code_point)
 decode the given code_point, writing into the output string in out.
size_t decode_code_point (uint8_t *buf, size_t buflen, uint32_t code)
 decode the given code point, writing into the output string buf, of size buflen
c4::substr to_substr (std::string &s) noexcept
 get a writeable view to an existing std::string.
c4::csubstr to_csubstr (std::string const &s) noexcept
 get a readonly view to an existing std::string.
bool operator== (c4::csubstr ss, std::string const &s)
bool operator!= (c4::csubstr ss, std::string const &s)
bool operator>= (c4::csubstr ss, std::string const &s)
bool operator> (c4::csubstr ss, std::string const &s)
bool operator<= (c4::csubstr ss, std::string const &s)
bool operator< (c4::csubstr ss, std::string const &s)
bool operator== (std::string const &s, c4::csubstr ss)
bool operator!= (std::string const &s, c4::csubstr ss)
bool operator>= (std::string const &s, c4::csubstr ss)
bool operator> (std::string const &s, c4::csubstr ss)
bool operator<= (std::string const &s, c4::csubstr ss)
bool operator< (std::string const &s, c4::csubstr ss)
size_t to_chars (c4::substr buf, std::string const &s)
 copy a std::string to a writeable substr
bool from_chars (c4::csubstr buf, std::string *s)
 copy a csubstr to an existing std::string
c4::csubstr to_csubstr (std::string_view s) noexcept
 create a csubstr from an existing std::string_view.
bool operator== (c4::csubstr ss, std::string_view s)
bool operator!= (c4::csubstr ss, std::string_view s)
bool operator>= (c4::csubstr ss, std::string_view s)
bool operator> (c4::csubstr ss, std::string_view s)
bool operator<= (c4::csubstr ss, std::string_view s)
bool operator< (c4::csubstr ss, std::string_view s)
bool operator== (std::string_view s, c4::csubstr ss)
bool operator!= (std::string_view s, c4::csubstr ss)
bool operator<= (std::string_view s, c4::csubstr ss)
bool operator< (std::string_view s, c4::csubstr ss)
bool operator>= (std::string_view s, c4::csubstr ss)
bool operator> (std::string_view s, c4::csubstr ss)
size_t to_chars (c4::substr buf, std::string_view s)
 copy an std::string_view to a writeable substr
template<class Alloc>
c4::substr to_substr (std::vector< char, Alloc > &vec)
 get a substr (writeable string view) of an existing std::vector<char>
template<class Alloc>
c4::csubstr to_csubstr (std::vector< char, Alloc > const &vec)
 get a csubstr (read-only string) view of an existing std::vector<char>
template<class Alloc>
bool operator!= (c4::csubstr ss, std::vector< char, Alloc > const &s)
template<class Alloc>
bool operator== (c4::csubstr ss, std::vector< char, Alloc > const &s)
template<class Alloc>
bool operator>= (c4::csubstr ss, std::vector< char, Alloc > const &s)
template<class Alloc>
bool operator> (c4::csubstr ss, std::vector< char, Alloc > const &s)
template<class Alloc>
bool operator<= (c4::csubstr ss, std::vector< char, Alloc > const &s)
template<class Alloc>
bool operator< (c4::csubstr ss, std::vector< char, Alloc > const &s)
template<class Alloc>
bool operator!= (std::vector< char, Alloc > const &s, c4::csubstr ss)
template<class Alloc>
bool operator== (std::vector< char, Alloc > const &s, c4::csubstr ss)
template<class Alloc>
bool operator>= (std::vector< char, Alloc > const &s, c4::csubstr ss)
template<class Alloc>
bool operator> (std::vector< char, Alloc > const &s, c4::csubstr ss)
template<class Alloc>
bool operator<= (std::vector< char, Alloc > const &s, c4::csubstr ss)
template<class Alloc>
bool operator< (std::vector< char, Alloc > const &s, c4::csubstr ss)
template<class Alloc>
size_t to_chars (c4::substr buf, std::vector< char, Alloc > const &s)
 copy a std::vector<char> to a substr
template<class Alloc>
bool from_chars (c4::csubstr buf, std::vector< char, Alloc > *s)
 copy a csubstr to an existing std::vector<char>

Detailed Description

(Undefined by default) Use shorter error message from checks/asserts: do not show the check condition in the error message.

Function Documentation

◆ esyms< yml::extra::ievt::EventFlags >()

template<>
c4::EnumSymbols< yml::extra::ievt::EventFlags > c4::esyms< yml::extra::ievt::EventFlags > ( )

Definition at line 1 of file ints_utils.cpp.

32{
33 static constexpr const EnumSymbols<yml::extra::ievt::EventFlags>::Sym syms[] = {
34 {yml::extra::ievt::KEY_, "KEY_"},
35 {yml::extra::ievt::VAL_, "VAL_"},
36 {yml::extra::ievt::SCLR, "SCLR"},
37 {yml::extra::ievt::BSEQ, "BSEQ"},
38 {yml::extra::ievt::ESEQ, "ESEQ"},
39 {yml::extra::ievt::BMAP, "BMAP"},
40 {yml::extra::ievt::EMAP, "EMAP"},
41 {yml::extra::ievt::ALIA, "ALIA"},
42 {yml::extra::ievt::ANCH, "ANCH"},
43 {yml::extra::ievt::TAG_, "TAG_"},
44 {yml::extra::ievt::PLAI, "PLAI"},
45 {yml::extra::ievt::SQUO, "SQUO"},
46 {yml::extra::ievt::DQUO, "DQUO"},
47 {yml::extra::ievt::LITL, "LITL"},
48 {yml::extra::ievt::FOLD, "FOLD"},
49 {yml::extra::ievt::FLOW, "FLOW"},
50 {yml::extra::ievt::BLCK, "BLCK"},
51 {yml::extra::ievt::BDOC, "BDOC"},
52 {yml::extra::ievt::EDOC, "EDOC"},
53 {yml::extra::ievt::BSTR, "BSTR"},
54 {yml::extra::ievt::ESTR, "ESTR"},
55 {yml::extra::ievt::EXPL, "EXPL"},
56 {yml::extra::ievt::AREN, "AREN"},
57 {yml::extra::ievt::PSTR, "PSTR"},
58 {yml::extra::ievt::UNFILT, "UNFILT"},
59 {yml::extra::ievt::YAML, "YAML"},
60 {yml::extra::ievt::TAGH, "TAGH"},
61 {yml::extra::ievt::TAGP, "TAGP"},
62 };
63 return EnumSymbols<yml::extra::ievt::EventFlags>(syms);
64}
@ SCLR
scalar (=VAL in test suite events)
@ LITL
scalar: block literal (|)
@ UNFILT
special flag to mark a scalar as unfiltered (when the parser is set not to filter).
@ EMAP
end map (-MAP in test suite events)
@ DQUO
scalar: double-quoted ("")
@ FOLD
scalar: block folded (>)
@ BMAP
begin map (+MAP in test suite events)
@ TAGH
tag directive, handle: \TAG <handle> ........
@ ESTR
end stream (-STR in test suite events)
@ BSTR
begin stream (+STR in test suite events)
@ BSEQ
begin seq (+SEQ in test suite events)
@ ESEQ
end seq (-SEQ in test suite events)
@ FLOW
container: flow: [] for seqs or {} for maps
@ TAGP
tag directive, prefix: \TAG ........ <prefix>
@ VAL_
as value special flag to enable look-back in the event array. it signifies that the previous event ha...
@ BDOC
begin doc (+DOC in test suite events)
@ AREN
IMPORTANT. Marks events whose string was placed in the arena. This happens when the filtered string i...
@ YAML
yaml directive: \YAML <version>
@ EDOC
end doc (-DOC in test suite events)
@ EXPL
--- (with BDOC) or ... (with EDOC)
@ SQUO
scalar: single-quoted (')

◆ to_substr() [1/2]

c4::substr c4::to_substr ( std::string & s)
inlinenoexcept

get a writeable view to an existing std::string.

When the string is empty, the returned view will be pointing at the character with value '\0', but the size will be zero.

See also
https://en.cppreference.com/w/cpp/string/basic_string/operator_at

Definition at line 31 of file string.hpp.

32{
33 #if C4_CPP < 11
34 #error this function requires c++11
35 #endif
36 // since c++11 it is legal to call s[s.size()].
37 return c4::substr(&s[0], s.size()); // NOLINT
38}
basic_substring< char > substr
a mutable string view
Definition substr.hpp:2356

◆ to_csubstr() [1/3]

c4::csubstr c4::to_csubstr ( std::string const & s)
inlinenoexcept

get a readonly view to an existing std::string.

When the string is empty, the returned view will be pointing at the character with value '\0', but the size will be zero.

See also
https://en.cppreference.com/w/cpp/string/basic_string/operator_at

Definition at line 45 of file string.hpp.

46{
47 #if C4_CPP < 11
48 #error this function requires c++11
49 #endif
50 // since c++11 it is legal to call s[s.size()].
51 return c4::csubstr(&s[0], s.size()); // NOLINT
52}
basic_substring< const char > csubstr
an immutable string view
Definition substr.hpp:2357

◆ operator==() [1/6]

bool c4::operator== ( c4::csubstr ss,
std::string const & s )
inline

Definition at line 57 of file string.hpp.

57{ return ss.compare(to_csubstr(s)) == 0; }
csubstr to_csubstr(const char(&s)[N]) noexcept
Definition substr.hpp:2381
int compare(C const c) const noexcept
Definition substr.hpp:385

◆ operator!=() [1/6]

bool c4::operator!= ( c4::csubstr ss,
std::string const & s )
inline

Definition at line 58 of file string.hpp.

58{ return ss.compare(to_csubstr(s)) != 0; }

◆ operator>=() [1/6]

bool c4::operator>= ( c4::csubstr ss,
std::string const & s )
inline

Definition at line 59 of file string.hpp.

59{ return ss.compare(to_csubstr(s)) >= 0; }

◆ operator>() [1/6]

bool c4::operator> ( c4::csubstr ss,
std::string const & s )
inline

Definition at line 60 of file string.hpp.

60{ return ss.compare(to_csubstr(s)) > 0; }

◆ operator<=() [1/6]

bool c4::operator<= ( c4::csubstr ss,
std::string const & s )
inline

Definition at line 61 of file string.hpp.

61{ return ss.compare(to_csubstr(s)) <= 0; }

◆ operator<() [1/6]

bool c4::operator< ( c4::csubstr ss,
std::string const & s )
inline

Definition at line 62 of file string.hpp.

62{ return ss.compare(to_csubstr(s)) < 0; }

◆ operator==() [2/6]

bool c4::operator== ( std::string const & s,
c4::csubstr ss )
inline

Definition at line 64 of file string.hpp.

64{ return ss.compare(to_csubstr(s)) == 0; }

◆ operator!=() [2/6]

bool c4::operator!= ( std::string const & s,
c4::csubstr ss )
inline

Definition at line 65 of file string.hpp.

65{ return ss.compare(to_csubstr(s)) != 0; }

◆ operator>=() [2/6]

bool c4::operator>= ( std::string const & s,
c4::csubstr ss )
inline

Definition at line 66 of file string.hpp.

66{ return ss.compare(to_csubstr(s)) <= 0; }

◆ operator>() [2/6]

bool c4::operator> ( std::string const & s,
c4::csubstr ss )
inline

Definition at line 67 of file string.hpp.

67{ return ss.compare(to_csubstr(s)) < 0; }

◆ operator<=() [2/6]

bool c4::operator<= ( std::string const & s,
c4::csubstr ss )
inline

Definition at line 68 of file string.hpp.

68{ return ss.compare(to_csubstr(s)) >= 0; }

◆ operator<() [2/6]

bool c4::operator< ( std::string const & s,
c4::csubstr ss )
inline

Definition at line 69 of file string.hpp.

69{ return ss.compare(to_csubstr(s)) > 0; }

◆ to_chars() [1/3]

size_t c4::to_chars ( c4::substr buf,
std::string const & s )
inline

copy a std::string to a writeable substr

Definition at line 75 of file string.hpp.

76{
77 size_t sz = s.size();
78 size_t len = buf.len < sz ? buf.len : sz;
79 buf.copy_from(csubstr(s.data(), len)); // copy only available chars
80 return sz; // return the number of needed chars
81}
auto copy_from(ro_substr that) -> typename std::enable_if< !std::is_const< U >::value, void >::type
copy a string to this substr, starting at 0
Definition substr.hpp:2166
size_t len
the length of the substring
Definition substr.hpp:218

◆ from_chars() [1/2]

bool c4::from_chars ( c4::csubstr buf,
std::string * s )
inline

copy a csubstr to an existing std::string

Definition at line 84 of file string.hpp.

85{
86 s->resize(buf.len);
87 substr(&(*s)[0], buf.len).copy_from(buf); // NOLINT
88 return true;
89}

◆ to_csubstr() [2/3]

c4::csubstr c4::to_csubstr ( std::string_view s)
inlinenoexcept

create a csubstr from an existing std::string_view.

Definition at line 34 of file string_view.hpp.

35{
36 return c4::csubstr(s.data(), s.size());
37}

◆ operator==() [3/6]

bool c4::operator== ( c4::csubstr ss,
std::string_view s )
inline

Definition at line 42 of file string_view.hpp.

42{ return ss.compare(s.data(), s.size()) == 0; }

◆ operator!=() [3/6]

bool c4::operator!= ( c4::csubstr ss,
std::string_view s )
inline

Definition at line 43 of file string_view.hpp.

43{ return ss.compare(s.data(), s.size()) != 0; }

◆ operator>=() [3/6]

bool c4::operator>= ( c4::csubstr ss,
std::string_view s )
inline

Definition at line 44 of file string_view.hpp.

44{ return ss.compare(s.data(), s.size()) >= 0; }

◆ operator>() [3/6]

bool c4::operator> ( c4::csubstr ss,
std::string_view s )
inline

Definition at line 45 of file string_view.hpp.

45{ return ss.compare(s.data(), s.size()) > 0; }

◆ operator<=() [3/6]

bool c4::operator<= ( c4::csubstr ss,
std::string_view s )
inline

Definition at line 46 of file string_view.hpp.

46{ return ss.compare(s.data(), s.size()) <= 0; }

◆ operator<() [3/6]

bool c4::operator< ( c4::csubstr ss,
std::string_view s )
inline

Definition at line 47 of file string_view.hpp.

47{ return ss.compare(s.data(), s.size()) < 0; }

◆ operator==() [4/6]

bool c4::operator== ( std::string_view s,
c4::csubstr ss )
inline

Definition at line 49 of file string_view.hpp.

49{ return ss.compare(s.data(), s.size()) == 0; }

◆ operator!=() [4/6]

bool c4::operator!= ( std::string_view s,
c4::csubstr ss )
inline

Definition at line 50 of file string_view.hpp.

50{ return ss.compare(s.data(), s.size()) != 0; }

◆ operator<=() [4/6]

bool c4::operator<= ( std::string_view s,
c4::csubstr ss )
inline

Definition at line 51 of file string_view.hpp.

51{ return ss.compare(s.data(), s.size()) >= 0; }

◆ operator<() [4/6]

bool c4::operator< ( std::string_view s,
c4::csubstr ss )
inline

Definition at line 52 of file string_view.hpp.

52{ return ss.compare(s.data(), s.size()) > 0; }

◆ operator>=() [4/6]

bool c4::operator>= ( std::string_view s,
c4::csubstr ss )
inline

Definition at line 53 of file string_view.hpp.

53{ return ss.compare(s.data(), s.size()) <= 0; }

◆ operator>() [4/6]

bool c4::operator> ( std::string_view s,
c4::csubstr ss )
inline

Definition at line 54 of file string_view.hpp.

54{ return ss.compare(s.data(), s.size()) < 0; }

◆ to_chars() [2/3]

size_t c4::to_chars ( c4::substr buf,
std::string_view s )
inline

copy an std::string_view to a writeable substr

Definition at line 60 of file string_view.hpp.

61{
62 size_t sz = s.size();
63 size_t len = buf.len < sz ? buf.len : sz;
64 buf.copy_from(csubstr(s.data(), len)); // copy only available chars
65 return sz; // return the number of needed chars
66}

◆ to_substr() [2/2]

template<class Alloc>
c4::substr c4::to_substr ( std::vector< char, Alloc > & vec)

get a substr (writeable string view) of an existing std::vector<char>

Definition at line 37 of file vector.hpp.

38{
39 char *data = vec.empty() ? nullptr : vec.data(); // data() may or may not return a null pointer.
40 return c4::substr(data, vec.size());
41}

◆ to_csubstr() [3/3]

template<class Alloc>
c4::csubstr c4::to_csubstr ( std::vector< char, Alloc > const & vec)

get a csubstr (read-only string) view of an existing std::vector<char>

Definition at line 45 of file vector.hpp.

46{
47 const char *data = vec.empty() ? nullptr : vec.data(); // data() may or may not return a null pointer.
48 return c4::csubstr(data, vec.size());
49}

◆ operator!=() [5/6]

template<class Alloc>
bool c4::operator!= ( c4::csubstr ss,
std::vector< char, Alloc > const & s )
inline

Definition at line 55 of file vector.hpp.

55{ return ss != to_csubstr(s); }

◆ operator==() [5/6]

template<class Alloc>
bool c4::operator== ( c4::csubstr ss,
std::vector< char, Alloc > const & s )
inline

Definition at line 56 of file vector.hpp.

56{ return ss == to_csubstr(s); }

◆ operator>=() [5/6]

template<class Alloc>
bool c4::operator>= ( c4::csubstr ss,
std::vector< char, Alloc > const & s )
inline

Definition at line 57 of file vector.hpp.

57{ return ss >= to_csubstr(s); }

◆ operator>() [5/6]

template<class Alloc>
bool c4::operator> ( c4::csubstr ss,
std::vector< char, Alloc > const & s )
inline

Definition at line 58 of file vector.hpp.

58{ return ss > to_csubstr(s); }

◆ operator<=() [5/6]

template<class Alloc>
bool c4::operator<= ( c4::csubstr ss,
std::vector< char, Alloc > const & s )
inline

Definition at line 59 of file vector.hpp.

59{ return ss <= to_csubstr(s); }

◆ operator<() [5/6]

template<class Alloc>
bool c4::operator< ( c4::csubstr ss,
std::vector< char, Alloc > const & s )
inline

Definition at line 60 of file vector.hpp.

60{ return ss < to_csubstr(s); }

◆ operator!=() [6/6]

template<class Alloc>
bool c4::operator!= ( std::vector< char, Alloc > const & s,
c4::csubstr ss )
inline

Definition at line 62 of file vector.hpp.

62{ return ss != to_csubstr(s); }

◆ operator==() [6/6]

template<class Alloc>
bool c4::operator== ( std::vector< char, Alloc > const & s,
c4::csubstr ss )
inline

Definition at line 63 of file vector.hpp.

63{ return ss == to_csubstr(s); }

◆ operator>=() [6/6]

template<class Alloc>
bool c4::operator>= ( std::vector< char, Alloc > const & s,
c4::csubstr ss )
inline

Definition at line 64 of file vector.hpp.

64{ return ss <= to_csubstr(s); }

◆ operator>() [6/6]

template<class Alloc>
bool c4::operator> ( std::vector< char, Alloc > const & s,
c4::csubstr ss )
inline

Definition at line 65 of file vector.hpp.

65{ return ss < to_csubstr(s); }

◆ operator<=() [6/6]

template<class Alloc>
bool c4::operator<= ( std::vector< char, Alloc > const & s,
c4::csubstr ss )
inline

Definition at line 66 of file vector.hpp.

66{ return ss >= to_csubstr(s); }

◆ operator<() [6/6]

template<class Alloc>
bool c4::operator< ( std::vector< char, Alloc > const & s,
c4::csubstr ss )
inline

Definition at line 67 of file vector.hpp.

67{ return ss > to_csubstr(s); }

◆ to_chars() [3/3]

template<class Alloc>
size_t c4::to_chars ( c4::substr buf,
std::vector< char, Alloc > const & s )
inline

copy a std::vector<char> to a substr

Definition at line 74 of file vector.hpp.

75{
76 size_t sz = s.size();
77 size_t len = buf.len < sz ? buf.len : sz;
78 buf.copy_from(csubstr(s.data(), len)); // copy only available chars
79 return sz; // return the number of needed chars
80}

◆ from_chars() [2/2]

template<class Alloc>
bool c4::from_chars ( c4::csubstr buf,
std::vector< char, Alloc > * s )
inline

copy a csubstr to an existing std::vector<char>

Definition at line 84 of file vector.hpp.

85{
86 s->resize(buf.len);
87 substr(s->data(), buf.len).copy_from(buf);
88 return true;
89}