rapidyaml 0.14.0
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
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_
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::center_< T >
struct  c4::fmt::right_< T >

Namespaces

namespace  c4
 (Undefined by default) Use shorter error message from checks/asserts: do not show the check condition in the error message.
namespace  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_ c4::fmt::boolalpha (T const &val=false)
 tag function to mark a variable to be written as an alphabetic boolean, ie as either true or false
size_t c4::to_chars (substr buf, fmt::boolalpha_ fmt)
 write a variable as an alphabetic boolean, ie as either true or false
template<class T>
integral_< T > c4::fmt::integral (T val, T radix=10)
 format an integral type with a custom radix
template<class T>
integral_< intptr_t > c4::fmt::integral (T const *val, T radix=10)
 format an integral type with a custom radix
template<class T>
integral_< intptr_t > c4::fmt::integral (std::nullptr_t, T radix=10)
 format an integral type with a custom radix
template<class T>
integral_< intptr_t > c4::fmt::hex (T *v)
 format the pointer as an hexadecimal value
template<class T>
integral_< intptr_t > c4::fmt::hex (T const *v)
 format the pointer as an hexadecimal value
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
template<class T>
integral_< intptr_t > c4::fmt::oct (T *v)
 format the pointer as an octal value
template<class T>
integral_< T > c4::fmt::oct (T v)
 format the integral_ argument as an octal value
template<class T>
integral_< intptr_t > c4::fmt::bin (T const *v)
 format the pointer as a binary 0-1 value
template<class T>
integral_< intptr_t > c4::fmt::bin (T *v)
 format the pointer as a binary 0-1 value
template<class T>
integral_< T > c4::fmt::bin (T v)
 format the integral_ argument as a binary 0-1 value
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
template<class T>
integral_padded_< T > c4::fmt::zpad (integral_< T > val, size_t num_digits)
 pad the argument with zeroes on the left
integral_padded_< intptr_t > c4::fmt::zpad (std::nullptr_t, size_t num_digits)
 pad the argument with zeroes on the left
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
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>
auto c4::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 c4::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 c4::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 c4::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 c4::from_chars (csubstr s, fmt::overflow_checked_< T > wrapper)
 read an integer type, detecting overflow (returns false on overflow)
template<class T>
bool c4::from_chars (csubstr s, fmt::overflow_checked_< T > *wrapper)
 read an integer type, detecting overflow (returns false on overflow)
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
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
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
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
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
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
size_t c4::to_chars (substr buf, fmt::const_raw_wrapper r)
 write a variable in raw binary format, using memcpy
bool c4::from_chars (csubstr buf, fmt::raw_wrapper *r)
 read a variable in raw binary format, using memcpy
bool c4::from_chars (csubstr buf, fmt::raw_wrapper r)
 read a variable in raw binary format, using memcpy
size_t c4::from_chars_first (csubstr buf, fmt::raw_wrapper *r)
 read a variable in raw binary format, using memcpy
size_t c4::from_chars_first (csubstr buf, fmt::raw_wrapper r)
 read a variable in raw binary format, using memcpy
template<class T>
left_< T > c4::fmt::left (T val, size_t width, char padchar=' ')
 tag type to mark an argument to be aligned left.
template<class T>
center_< T > c4::fmt::center (T val, size_t width, char padchar=' ')
 tag function to mark an argument to be aligned center
template<class T>
right_< T > c4::fmt::right (T val, size_t width, char padchar=' ')
 tag function to mark an argument to be aligned right
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 T>
size_t c4::to_chars (substr buf, fmt::center_< 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.
template<class... Args>
substr c4::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 c4::uncat (csubstr buf, Arg &a, Args &...more)
 deserialize the arguments from the given buffer.
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.
template<class... Args>
substr c4::catsep_sub (substr buf, Args &&...args)
 like c4::catsep() but return a substr instead of a size
template<class Arg, class... Args>
size_t c4::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 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.
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
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.
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.
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.
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.
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.
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.
template<class CharOwningContainer, class Sep, class... Args>
csubstr c4::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 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.
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.
template<class CharOwningContainer, class... Args>
csubstr c4::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.

Variables

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

Detailed Description

provides type-safe facilities for formatting arguments to string buffers

Definition in file format.hpp.