rapidyaml  0.7.0
parse and emit YAML, and do it fast
format.hpp File Reference

provides type-safe facilities for formatting arguments to string buffers More...

#include "c4/charconv.hpp"
#include "c4/blob.hpp"

Go to the source code of this file.

Classes

struct  c4::fmt::boolalpha_< T >
 write a variable as an alphabetic boolean, ie as either true or false More...
 
struct  c4::fmt::integral_< T >
 format an integral type with a custom radix More...
 
struct  c4::fmt::integral_padded_< T >
 format an integral type with a custom radix, and pad with zeroes on the left More...
 
struct  c4::fmt::overflow_checked_< T >
 
struct  c4::fmt::real_< T >
 
struct  c4::fmt::raw_wrapper_< T >
 
struct  c4::fmt::left_< T >
 
struct  c4::fmt::right_< T >
 

Namespaces

 c4
 
 c4::fmt
 

Typedefs

using c4::fmt::const_raw_wrapper = raw_wrapper_< cbyte >
 
using c4::fmt::raw_wrapper = raw_wrapper_< byte >
 

Functions

template<class T >
boolalpha_< T > c4::fmt::boolalpha (T const &val, bool strict_read=false)
 
template<class T >
size_t c4::to_chars (substr buf, fmt::boolalpha_< T > fmt)
 write a variable as an alphabetic boolean, ie as either true or false More...
 
template<class T >
integral_< T > c4::fmt::integral (T val, T radix=10)
 format an integral type with a custom radix More...
 
template<class T >
integral_< intptr_t > c4::fmt::integral (T const *val, T radix=10)
 format an integral type with a custom radix More...
 
template<class T >
integral_< intptr_t > c4::fmt::integral (std::nullptr_t, T radix=10)
 format an integral type with a custom radix More...
 
template<class T >
integral_< intptr_t > c4::fmt::hex (T *v)
 format the pointer as an hexadecimal value More...
 
template<class T >
integral_< intptr_t > c4::fmt::hex (T const *v)
 format the pointer as an hexadecimal value More...
 
template<class T >
integral_< T > c4::fmt::hex (T v)
 
template<class T >
integral_< intptr_t > c4::fmt::oct (T const *v)
 format the pointer as an octal value More...
 
template<class T >
integral_< intptr_t > c4::fmt::oct (T *v)
 format the pointer as an octal value More...
 
template<class T >
integral_< T > c4::fmt::oct (T v)
 format the integral_ argument as an octal value More...
 
template<class T >
integral_< intptr_t > c4::fmt::bin (T const *v)
 format the pointer as a binary 0-1 value More...
 
template<class T >
integral_< intptr_t > c4::fmt::bin (T *v)
 format the pointer as a binary 0-1 value More...
 
template<class T >
integral_< T > c4::fmt::bin (T v)
 format the integral_ argument as a binary 0-1 value More...
 
template<class T >
integral_padded_< T > c4::fmt::zpad (T val, size_t num_digits)
 pad the argument with zeroes on the left, with decimal radix More...
 
template<class T >
integral_padded_< T > c4::fmt::zpad (integral_< T > val, size_t num_digits)
 pad the argument with zeroes on the left More...
 
integral_padded_< intptr_t > c4::fmt::zpad (std::nullptr_t, size_t num_digits)
 pad the argument with zeroes on the left More...
 
template<class T >
integral_padded_< intptr_t > c4::fmt::zpad (T const *val, size_t num_digits)
 pad the argument with zeroes on the left More...
 
template<class T >
integral_padded_< intptr_t > c4::fmt::zpad (T *val, size_t num_digits)
 
template<class T >
overflow_checked_< T > c4::fmt::overflow_checked (T &val)
 
template<typename T >
std::enable_if< std::is_signed< T >::value, size_t >::type c4::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 c4::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 c4::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 c4::to_chars (substr buf, fmt::integral_padded_< T > fmt)
 format an integer unsigned type, pad with zeroes More...
 
template<class T >
bool c4::from_chars (csubstr s, fmt::overflow_checked_< T > wrapper)
 read an format an integer unsigned type More...
 
template<class T >
real_< T > c4::fmt::real (T val, int precision, RealFormat_e fmt=FTOA_FLOAT)
 
size_t c4::to_chars (substr buf, fmt::real_< float > fmt)
 
size_t c4::to_chars (substr buf, fmt::real_< double > fmt)
 
const_raw_wrapper c4::fmt::craw (cblob data, size_t alignment=alignof(max_align_t))
 mark a variable to be written in raw binary format, using memcpy More...
 
const_raw_wrapper c4::fmt::raw (cblob data, size_t alignment=alignof(max_align_t))
 mark a variable to be written in raw binary format, using memcpy More...
 
template<class T >
const_raw_wrapper c4::fmt::craw (T const &data, size_t alignment=alignof(T))
 mark a variable to be written in raw binary format, using memcpy More...
 
template<class T >
const_raw_wrapper c4::fmt::raw (T const &data, size_t alignment=alignof(T))
 mark a variable to be written in raw binary format, using memcpy More...
 
raw_wrapper c4::fmt::raw (blob data, size_t alignment=alignof(max_align_t))
 mark a variable to be read in raw binary format, using memcpy More...
 
template<class T >
raw_wrapper c4::fmt::raw (T &data, size_t alignment=alignof(T))
 mark a variable to be read in raw binary format, using memcpy More...
 
size_t c4::to_chars (substr buf, fmt::const_raw_wrapper r)
 write a variable in raw binary format, using memcpy More...
 
bool c4::from_chars (csubstr buf, fmt::raw_wrapper *r)
 read a variable in raw binary format, using memcpy More...
 
bool c4::from_chars (csubstr buf, fmt::raw_wrapper r)
 read a variable in raw binary format, using memcpy More...
 
size_t c4::from_chars_first (csubstr buf, fmt::raw_wrapper *r)
 read a variable in raw binary format, using memcpy More...
 
size_t c4::from_chars_first (csubstr buf, fmt::raw_wrapper r)
 read a variable in raw binary format, using memcpy More...
 
template<class T >
left_< T > c4::fmt::left (T val, size_t width, char padchar=' ')
 mark an argument to be aligned left More...
 
template<class T >
right_< T > c4::fmt::right (T val, size_t width, char padchar=' ')
 mark an argument to be aligned right More...
 
template<class T >
size_t c4::to_chars (substr buf, fmt::left_< T > const &align)
 
template<class T >
size_t c4::to_chars (substr buf, fmt::right_< T > const &align)
 
template<class Arg , class... Args>
size_t c4::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 c4::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 c4::uncat (csubstr buf, Arg &a, Args &...more)
 deserialize the arguments from the given buffer. More...
 
template<class Sep , class Arg , class... Args>
size_t c4::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 c4::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 c4::uncatsep (csubstr buf, Sep &sep, Arg &a, Args &...more)
 deserialize the arguments from the given buffer. More...
 
template<class Arg , class... Args>
size_t c4::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 c4::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 c4::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 c4::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 c4::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 c4::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 c4::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 c4::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 c4::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 c4::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 c4::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 c4::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...
 

Variables

integral_< intptr_t > c4::fmt::hex (std::nullptr_t)
 format null as an hexadecimal value More...
 
integral_< intptr_t > c4::fmt::oct (std::nullptr_t)
 format null as an octal value More...
 
integral_< intptr_t > c4::fmt::bin (std::nullptr_t)
 format null as a binary 0-1 value More...
 

Detailed Description

provides type-safe facilities for formatting arguments to string buffers

Definition in file format.hpp.