rapidyaml  0.7.2
parse and emit YAML, and do it fast
c4 Namespace Reference

Namespaces

 fmt
 
 yml
 

Classes

struct  basic_substring
 a non-owning string-view, consisting of a character pointer and a length. More...
 

Enumerations

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

Functions

substr to_substr (substr s) noexcept
 neutral version for use in generic code More...
 
csubstr to_csubstr (substr s) noexcept
 neutral version for use in generic code More...
 
csubstr to_csubstr (csubstr s) noexcept
 neutral version for use in generic code More...
 
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 >
std::enable_if< std::is_same< U, char * >::value, substr >::type to_substr (U s) noexcept
 
template<class U >
std::enable_if< std::is_same< U, const char * >::value||std::is_same< U, char * >::value, csubstr >::type to_csubstr (U s) noexcept
 
template<typename C , size_t N>
bool operator== (const char(&s)[N], basic_substring< C > const that) noexcept
 
template<typename C , size_t N>
bool operator!= (const char(&s)[N], basic_substring< C > const that) noexcept
 
template<typename C , size_t N>
bool operator< (const char(&s)[N], basic_substring< C > const that) noexcept
 
template<typename C , size_t N>
bool operator> (const char(&s)[N], basic_substring< C > const that) noexcept
 
template<typename C , size_t N>
bool operator<= (const char(&s)[N], basic_substring< C > const that) noexcept
 
template<typename C , size_t N>
bool operator>= (const char(&s)[N], 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 >
bool operator>= (const char c, basic_substring< C > const that) noexcept
 
template<class OStream , class C >
OStream & operator<< (OStream &os, basic_substring< C > s)
 output the string to a stream More...
 
template<class T >
auto digits_dec (T v) noexcept -> typename std::enable_if< sizeof(T)==1u, unsigned >::type
 decimal digits for 8 bit integers More...
 
template<class T >
unsigned digits_hex (T v) noexcept
 return the number of digits required to encode an hexadecimal number. More...
 
template<class T >
unsigned digits_bin (T v) noexcept
 return the number of digits required to encode a binary number. More...
 
template<class T >
unsigned digits_oct (T v_) noexcept
 return the number of digits required to encode an octal number. More...
 
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. More...
 
template<class T >
size_t write_hex (substr buf, T v) noexcept
 write an integer to a string in hexadecimal format. More...
 
template<class T >
size_t write_oct (substr buf, T v) noexcept
 write an integer to a string in octal format. More...
 
template<class T >
size_t write_bin (substr buf, T v) noexcept
 write an integer to a string in binary format. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<class I >
bool read_dec (csubstr s, I *v) noexcept
 read a decimal integer from a string. More...
 
template<class I >
bool read_hex (csubstr s, I *v) noexcept
 read an hexadecimal integer from a string. More...
 
template<class I >
bool read_bin (csubstr s, I *v) noexcept
 read a binary integer from a string. More...
 
template<class I >
bool read_oct (csubstr s, I *v) noexcept
 read an octal integer from a string. More...
 
template<class T >
size_t itoa (substr buf, T v) noexcept
 convert an integral signed decimal to a string. More...
 
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. More...
 
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). More...
 
template<class T >
size_t utoa (substr buf, T v) noexcept
 convert an integral unsigned decimal to a string. More...
 
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. More...
 
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. More...
 
template<class T >
bool atoi (csubstr str, T *v) noexcept
 Convert a trimmed string to a signed integral value. More...
 
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(). More...
 
template<class T >
bool atou (csubstr str, T *v) noexcept
 Convert a trimmed string to an unsigned integral value. More...
 
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(). More...
 
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. More...
 
size_t ftoa (substr str, float v, int precision=-1, RealFormat_e formatting=FTOA_FLEX) noexcept
 Convert a single-precision real number to string. More...
 
size_t dtoa (substr str, double v, int precision=-1, RealFormat_e formatting=FTOA_FLEX) noexcept
 Convert a double-precision real number to string. More...
 
bool atof (csubstr str, float *v) noexcept
 Convert a string to a single precision real number. More...
 
size_t atof_first (csubstr str, float *v) noexcept
 Convert a string to a single precision real number. More...
 
bool atod (csubstr str, double *v) noexcept
 Convert a string to a double precision real number. More...
 
size_t atod_first (csubstr str, double *v) noexcept
 Convert a string to a double precision real number. More...
 
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 >
size_t ::type xtoa (substr buf, T v) noexcept
 
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 >
bool ::type atox (csubstr buf, T *v) noexcept
 
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 >
size_t ::type to_chars (substr buf, T v) noexcept
 
template<class T >
size_t to_chars (substr s, T *v) noexcept
 
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 >
bool ::type from_chars (csubstr buf, T *v) noexcept
 
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 >
size_t ::type from_chars_first (csubstr buf, T *v) noexcept
 
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. More...
 
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 More...
 
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 (substr 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
 
size_t to_chars (substr buf, const char *v) noexcept
 
template<class T >
size_t to_chars (substr buf, fmt::boolalpha_< T > fmt)
 write a variable as an alphabetic boolean, ie as either true or false More...
 
template<typename T >
std::enable_if< std::is_signed< T >::value, size_t >::type to_chars (substr buf, fmt::integral_< T > fmt)
 format an integer signed type More...
 
template<typename T >
std::enable_if< std::is_signed< T >::value, size_t >::type to_chars (substr buf, fmt::integral_padded_< T > fmt)
 format an integer signed type, pad with zeroes More...
 
template<typename T >
std::enable_if< std::is_unsigned< T >::value, size_t >::type to_chars (substr buf, fmt::integral_< T > fmt)
 format an integer unsigned type More...
 
template<typename T >
std::enable_if< std::is_unsigned< T >::value, size_t >::type to_chars (substr buf, fmt::integral_padded_< T > fmt)
 format an integer unsigned type, pad with zeroes More...
 
template<class T >
bool from_chars (csubstr s, fmt::overflow_checked_< T > wrapper)
 read an integer type, detecting overflow (returns false on overflow) More...
 
template<class T >
bool from_chars (csubstr s, fmt::overflow_checked_< T > *wrapper)
 read an integer type, detecting overflow (returns false on overflow) More...
 
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 More...
 
bool from_chars (csubstr buf, fmt::raw_wrapper *r)
 read a variable in raw binary format, using memcpy More...
 
bool from_chars (csubstr buf, fmt::raw_wrapper r)
 read a variable in raw binary format, using memcpy More...
 
size_t from_chars_first (csubstr buf, fmt::raw_wrapper *r)
 read a variable in raw binary format, using memcpy More...
 
size_t from_chars_first (csubstr buf, fmt::raw_wrapper r)
 read a variable in raw binary format, using memcpy More...
 
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 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. More...
 
template<class... Args>
substr cat_sub (substr buf, Args &&...args)
 like c4::cat() but return a substr instead of a size More...
 
template<class Arg , class... Args>
size_t uncat (csubstr buf, Arg &a, Args &...more)
 deserialize the arguments from the given buffer. More...
 
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. More...
 
template<class... Args>
substr catsep_sub (substr buf, Args &&...args)
 like c4::catsep() but return a substr instead of a size More...
 
template<class Sep , class Arg , class... Args>
size_t uncatsep (csubstr buf, Sep &sep, Arg &a, Args &...more)
 deserialize the arguments from the given buffer. More...
 
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. More...
 
template<class... Args>
substr format_sub (substr buf, csubstr fmt, Args const &...args)
 like c4::format() but return a substr instead of a size More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<class CharOwningContainer , class Sep , class... Args>
csubstr catseprs_append (CharOwningContainer *cont, Sep const &sep, Args const &...args)
 catsep+resize+append: like catsep(), but receives a container, and appends the arguments, resizing the container as needed to contain the result. More...
 
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. More...
 
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. More...
 
template<class CharOwningContainer , class... Args>
csubstr formatrs_append (CharOwningContainer *cont, csubstr fmt, Args const &...args)
 format+resize+append: like format(), but receives a container, and appends the arguments, resizing the container as needed to contain the result. More...
 
bool base64_valid (csubstr encoded)
 check that the given buffer is a valid base64 encoding More...
 
size_t base64_encode (substr encoded, cblob data)
 base64-encode binary data. More...
 
size_t base64_decode (csubstr encoded, blob data)
 decode the base64 encoding in the given buffer More...
 
size_t to_chars (substr buf, fmt::const_base64_wrapper b)
 write a variable in base64 format More...
 
size_t from_chars (csubstr buf, fmt::base64_wrapper *b)
 read a variable in base64 format More...
 
c4::substr to_substr (std::string &s) noexcept
 get a writeable view to an existing std::string. More...
 
c4::csubstr to_csubstr (std::string const &s) noexcept
 get a readonly view to an existing std::string. More...
 
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 an std::string to a writeable string view More...
 
bool from_chars (c4::csubstr buf, std::string *s)
 copy a string view to an existing std::string More...
 
c4::csubstr to_csubstr (std::string_view s) noexcept
 create a csubstr from an existing std::string_view. More...
 
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 More...
 
template<class Alloc >
c4::substr to_substr (std::vector< char, Alloc > &vec)
 get a substr (writeable string view) of an existing std::vector<char> More...
 
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> More...
 
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 writeable string view More...
 
template<class Alloc >
bool from_chars (c4::csubstr buf, std::vector< char, Alloc > *s)
 copy a string view to an existing std::vector<char> More...
 

Function Documentation

◆ to_chars() [1/5]

template<typename T >
std::enable_if<std::is_unsigned<T>::value, size_t>::type c4::to_chars ( substr  buf,
fmt::integral_< T >  fmt 
)
inline

format an integer unsigned type

Definition at line 312 of file format.hpp.

313 {
314  return utoa(buf, fmt.val, fmt.radix);
315 }
size_t utoa(substr buf, T v) noexcept
convert an integral unsigned decimal to a string.
Definition: charconv.hpp:1304

References c4::fmt::integral_< T >::radix, utoa(), and c4::fmt::integral_< T >::val.

◆ to_chars() [2/5]

template<typename T >
std::enable_if<std::is_unsigned<T>::value, size_t>::type c4::to_chars ( substr  buf,
fmt::integral_padded_< T >  fmt 
)
inline

format an integer unsigned type, pad with zeroes

Definition at line 321 of file format.hpp.

322 {
323  return utoa(buf, fmt.val, fmt.radix, fmt.num_digits);
324 }

References c4::fmt::integral_padded_< T >::num_digits, c4::fmt::integral_padded_< T >::radix, utoa(), and c4::fmt::integral_padded_< T >::val.

◆ 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 21 of file string.hpp.

22 {
23  #if C4_CPP < 11
24  #error this function will have undefined behavior
25  #endif
26  // since c++11 it is legal to call s[s.size()].
27  return c4::substr(&s[0], s.size());
28 }

◆ 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 35 of file string.hpp.

36 {
37  #if C4_CPP < 11
38  #error this function will have undefined behavior
39  #endif
40  // since c++11 it is legal to call s[s.size()].
41  return c4::csubstr(&s[0], s.size());
42 }

◆ operator==() [1/6]

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

Definition at line 46 of file string.hpp.

46 { return ss.compare(to_csubstr(s)) == 0; }
c4::csubstr to_csubstr(std::string const &s) noexcept
get a readonly view to an existing std::string.
Definition: string.hpp:35

References to_csubstr().

◆ operator!=() [1/6]

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

Definition at line 47 of file string.hpp.

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

References to_csubstr().

◆ operator>=() [1/6]

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

Definition at line 48 of file string.hpp.

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

References to_csubstr().

◆ operator>() [1/6]

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

Definition at line 49 of file string.hpp.

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

References to_csubstr().

◆ operator<=() [1/6]

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

Definition at line 50 of file string.hpp.

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

References to_csubstr().

◆ operator<() [1/6]

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

Definition at line 51 of file string.hpp.

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

References to_csubstr().

◆ operator==() [2/6]

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

Definition at line 53 of file string.hpp.

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

References to_csubstr().

◆ operator!=() [2/6]

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

Definition at line 54 of file string.hpp.

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

References to_csubstr().

◆ operator>=() [2/6]

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

Definition at line 55 of file string.hpp.

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

References to_csubstr().

◆ operator>() [2/6]

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

Definition at line 56 of file string.hpp.

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

References to_csubstr().

◆ operator<=() [2/6]

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

Definition at line 57 of file string.hpp.

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

References to_csubstr().

◆ operator<() [2/6]

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

Definition at line 58 of file string.hpp.

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

References to_csubstr().

◆ to_chars() [3/5]

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

copy an std::string to a writeable string view

Definition at line 63 of file string.hpp.

64 {
65  C4_ASSERT(!buf.overlaps(to_csubstr(s)));
66  size_t len = buf.len < s.size() ? buf.len : s.size();
67  // calling memcpy with null strings is undefined behavior
68  // and will wreak havoc in calling code's branches.
69  // see https://github.com/biojppm/rapidyaml/pull/264#issuecomment-1262133637
70  if(len)
71  {
72  C4_ASSERT(s.data() != nullptr);
73  C4_ASSERT(buf.str != nullptr);
74  memcpy(buf.str, s.data(), len);
75  }
76  return s.size(); // return the number of needed chars
77 }

References to_csubstr().

◆ from_chars() [1/2]

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

copy a string view to an existing std::string

Definition at line 80 of file string.hpp.

81 {
82  s->resize(buf.len);
83  C4_ASSERT(!buf.overlaps(to_csubstr(*s)));
84  // calling memcpy with null strings is undefined behavior
85  // and will wreak havoc in calling code's branches.
86  // see https://github.com/biojppm/rapidyaml/pull/264#issuecomment-1262133637
87  if(buf.len)
88  {
89  C4_ASSERT(buf.str != nullptr);
90  memcpy(&(*s)[0], buf.str, buf.len);
91  }
92  return true;
93 }

References to_csubstr().

◆ 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 24 of file string_view.hpp.

25 {
26  return c4::csubstr(s.data(), s.size());
27 }

◆ operator==() [3/6]

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

Definition at line 32 of file string_view.hpp.

32 { 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 33 of file string_view.hpp.

33 { 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 34 of file string_view.hpp.

34 { 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 35 of file string_view.hpp.

35 { 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 36 of file string_view.hpp.

36 { 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 37 of file string_view.hpp.

37 { 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 39 of file string_view.hpp.

39 { 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 40 of file string_view.hpp.

40 { 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 41 of file string_view.hpp.

41 { 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 42 of file string_view.hpp.

42 { 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 43 of file string_view.hpp.

43 { 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 44 of file string_view.hpp.

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

◆ to_chars() [4/5]

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 50 of file string_view.hpp.

51 {
52  C4_ASSERT(!buf.overlaps(to_csubstr(s)));
53  size_t sz = s.size();
54  size_t len = buf.len < sz ? buf.len : sz;
55  // calling memcpy with null strings is undefined behavior
56  // and will wreak havoc in calling code's branches.
57  // see https://github.com/biojppm/rapidyaml/pull/264#issuecomment-1262133637
58  if(len)
59  {
60  C4_ASSERT(s.data() != nullptr);
61  C4_ASSERT(buf.str != nullptr);
62  memcpy(buf.str, s.data(), len);
63  }
64  return sz; // return the number of needed chars
65 }
c4::csubstr to_csubstr(std::string_view s) noexcept
create a csubstr from an existing std::string_view.
Definition: string_view.hpp:24

References to_csubstr().

◆ 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 21 of file vector.hpp.

22 {
23  char *data = vec.empty() ? nullptr : vec.data(); // data() may or may not return a null pointer.
24  return c4::substr(data, vec.size());
25 }

◆ 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 29 of file vector.hpp.

30 {
31  const char *data = vec.empty() ? nullptr : vec.data(); // data() may or may not return a null pointer.
32  return c4::csubstr(data, vec.size());
33 }

◆ operator!=() [5/6]

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

Definition at line 38 of file vector.hpp.

38 { return ss != to_csubstr(s); }
c4::csubstr to_csubstr(std::vector< char, Alloc > const &vec)
get a csubstr (read-only string) view of an existing std::vector<char>
Definition: vector.hpp:29

References to_csubstr().

◆ operator==() [5/6]

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

Definition at line 39 of file vector.hpp.

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

References to_csubstr().

◆ operator>=() [5/6]

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

Definition at line 40 of file vector.hpp.

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

References to_csubstr().

◆ operator>() [5/6]

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

Definition at line 41 of file vector.hpp.

41 { return ss > to_csubstr(s); }

References to_csubstr().

◆ operator<=() [5/6]

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

Definition at line 42 of file vector.hpp.

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

References to_csubstr().

◆ operator<() [5/6]

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

Definition at line 43 of file vector.hpp.

43 { return ss < to_csubstr(s); }

References to_csubstr().

◆ operator!=() [6/6]

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

Definition at line 45 of file vector.hpp.

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

References to_csubstr().

◆ operator==() [6/6]

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

Definition at line 46 of file vector.hpp.

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

References to_csubstr().

◆ operator>=() [6/6]

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

Definition at line 47 of file vector.hpp.

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

References to_csubstr().

◆ operator>() [6/6]

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

Definition at line 48 of file vector.hpp.

48 { return ss < to_csubstr(s); }

References to_csubstr().

◆ operator<=() [6/6]

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

Definition at line 49 of file vector.hpp.

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

References to_csubstr().

◆ operator<() [6/6]

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

Definition at line 50 of file vector.hpp.

50 { return ss > to_csubstr(s); }

References to_csubstr().

◆ to_chars() [5/5]

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 writeable string view

Definition at line 56 of file vector.hpp.

57 {
58  C4_ASSERT(!buf.overlaps(to_csubstr(s)));
59  size_t len = buf.len < s.size() ? buf.len : s.size();
60  // calling memcpy with null strings is undefined behavior
61  // and will wreak havoc in calling code's branches.
62  // see https://github.com/biojppm/rapidyaml/pull/264#issuecomment-1262133637
63  if(len > 0)
64  {
65  memcpy(buf.str, s.data(), len);
66  }
67  return s.size(); // return the number of needed chars
68 }

References to_csubstr().

◆ from_chars() [2/2]

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

copy a string view to an existing std::vector<char>

Definition at line 72 of file vector.hpp.

73 {
74  s->resize(buf.len);
75  C4_ASSERT(!buf.overlaps(to_csubstr(*s)));
76  // calling memcpy with null strings is undefined behavior
77  // and will wreak havoc in calling code's branches.
78  // see https://github.com/biojppm/rapidyaml/pull/264#issuecomment-1262133637
79  if(buf.len > 0)
80  {
81  memcpy(&(*s)[0], buf.str, buf.len);
82  }
83  return true;
84 }

References to_csubstr().