rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches

Typedefs

using c4::fmt::const_base64_wrapper = detail::base64_wrapper_<cbyte>
 a tag type to mark a payload to be encoded as base64
using c4::fmt::base64_wrapper = detail::base64_wrapper_<byte>
 a tag type to mark a payload to be decoded as base64
template<class Container>
using c4::fmt::const_base64_container_wrapper = detail::base64_container_wrapper_<const Container, cbyte>
 a tag type to mark a payload as base64-encoded
template<class Container>
using c4::fmt::base64_container_wrapper = detail::base64_container_wrapper_<Container, byte>
 a tag type to mark a payload to be encoded as base64

Functions

const_base64_wrapper c4::fmt::cbase64 (csubstr s, size_t *reqsize=nullptr)
 a tag function to mark a csubstr payload to be encoded in base64 format
const_base64_wrapper c4::fmt::base64 (csubstr s, size_t *reqsize=nullptr)
 a tag function to mark a csubstr payload to be encoded in base64 format
base64_wrapper c4::fmt::base64 (substr s, size_t *reqsize=nullptr)
 a tag function to mark a variable to be decoded from base64
template<class T>
const_base64_wrapper c4::fmt::cbase64 (T const *arg, size_t sz, size_t *reqsize=nullptr)
 a tag function to mark a payload to be encoded in base64 format
template<class T>
auto c4::fmt::base64 (T *arg, size_t sz, size_t *reqsize=nullptr) -> typename std::conditional< std::is_const< typename std::remove_reference< typename std::remove_pointer< T >::type >::type >::value, const_base64_wrapper, base64_wrapper >::type
 a tag function to mark a payload to be encoded in base64 format
template<class T>
auto c4::fmt::cbase64 (T const &arg, size_t *reqsize=nullptr) -> typename std::enable_if< ! detail::has_resize< T >::value, const_base64_wrapper >::type
 a tag function to mark a payload to be encoded in base64 format
template<class T>
auto c4::fmt::base64 (T &arg, size_t *reqsize=nullptr) -> typename std::enable_if< ! detail::has_resize< T >::value, typename std::conditional< std::is_const< typename std::remove_reference< typename std::remove_pointer< T >::type >::type >::value, const_base64_wrapper, base64_wrapper >::type >::type
 a tag function to mark a payload to be encoded or decoded in base64 format
template<class T>
auto c4::fmt::cbase64 (T const &arg, size_t *reqsize=nullptr) -> typename std::enable_if< detail::has_resize< T >::value, const_base64_container_wrapper< T > >::type
 a tag function to mark a container (payload with a .resize() method) to be encoded in base64 format.
template<class T>
auto c4::fmt::base64 (T &arg, size_t *reqsize=nullptr) -> typename std::enable_if< detail::has_resize< T >::value, typename std::conditional< std::is_const< typename std::remove_reference< typename std::remove_pointer< T >::type >::type >::value, const_base64_container_wrapper< T >, base64_container_wrapper< T > >::type >::type
 a tag function to mark a container (payload with a .resize() method) to be encoded or decoded in base64 format.

Detailed Description

// given these variables:
T var = {};
T &ref = var;
std::vector<T> vec = ...;
substr buf = ...;
// there are different approaches to encode/decode base64:
size_t numchars = to_chars(buf, base64(var)); // encode var as base64
size_t numchars = to_chars(buf, base64(ref)); // same as above
size_t numchars = to_chars(buf, base64(&var, 1)); // same as above
size_t numchars = to_chars(buf, base64(vec.data(), vec.size())); // for the container, but same call form as above
size_t numchars = to_chars(buf, base64(vec)); // same effect as prev call
// using cbase64() (the `c` prefix is for const) is equivalent
// for encoding, but quicker to compile:
size_t numchars = to_chars(buf, cbase64(var)); // encode var as base64
size_t numchars = to_chars(buf, cbase64(ref)); // same as above
size_t numchars = to_chars(buf, cbase64(&var, 1)); // same as above
size_t numchars = to_chars(buf, cbase64(vec.data(), vec.size())); // for the container, but same call as above
size_t numchars = to_chars(buf, cbase64(vec)); // same effect as prev call
// to decode:
csubstr buf = ...;
size_t reqbytes = 0; // number of bytes of decoded data
bool ok = from_chars(buf, base64(var)); // decode base64 to var
bool ok = from_chars(buf, base64(var, &reqbytes)); // same. reqbytes will be sizeof(var)
bool ok = from_chars(buf, base64(ref)); // same as above
bool ok = from_chars(buf, base64(ref, &reqbytes)); // same. reqbytes will be sizeof(var)
bool ok = from_chars(buf, base64(&var, 1, &reqbytes)); // same
bool ok = from_chars(buf, base64(vec.data(), vec.size(), &reqbytes)); // for the container, but same call as above
bool ok = from_chars(buf, base64(vec, &reqbytes)); // same effect as prev call
const_base64_wrapper base64(csubstr s, size_t *reqsize=nullptr)
a tag function to mark a csubstr payload to be encoded in base64 format
const_base64_wrapper cbase64(csubstr s, size_t *reqsize=nullptr)
a tag function to mark a csubstr payload to be encoded in base64 format
bool from_chars(csubstr buf, uint8_t *v) noexcept
basic_substring< char > substr
a mutable string view
Definition substr.hpp:2355
basic_substring< const char > csubstr
an immutable string view
Definition substr.hpp:2356
size_t to_chars(substr buf, uint8_t v) noexcept

Typedef Documentation

◆ const_base64_wrapper

using c4::fmt::const_base64_wrapper = detail::base64_wrapper_<cbyte>

a tag type to mark a payload to be encoded as base64

Definition at line 103 of file format_base64.hpp.

◆ base64_wrapper

using c4::fmt::base64_wrapper = detail::base64_wrapper_<byte>

a tag type to mark a payload to be decoded as base64

Definition at line 105 of file format_base64.hpp.

◆ const_base64_container_wrapper

template<class Container>
using c4::fmt::const_base64_container_wrapper = detail::base64_container_wrapper_<const Container, cbyte>

a tag type to mark a payload as base64-encoded

Definition at line 110 of file format_base64.hpp.

◆ base64_container_wrapper

template<class Container>
using c4::fmt::base64_container_wrapper = detail::base64_container_wrapper_<Container, byte>

a tag type to mark a payload to be encoded as base64

Definition at line 113 of file format_base64.hpp.

Function Documentation

◆ cbase64() [1/4]

const_base64_wrapper c4::fmt::cbase64 ( csubstr s,
size_t * reqsize = nullptr )
inline

a tag function to mark a csubstr payload to be encoded in base64 format

Definition at line 117 of file format_base64.hpp.

118{
119 return const_base64_wrapper(cblob(s.str, s.len), reqsize);
120}
detail::base64_wrapper_< cbyte > const_base64_wrapper
a tag type to mark a payload to be encoded as base64
size_t len
the length of the substring
Definition substr.hpp:218
C * str
a restricted pointer to the first character of the substring
Definition substr.hpp:216

◆ base64() [1/5]

const_base64_wrapper c4::fmt::base64 ( csubstr s,
size_t * reqsize = nullptr )
inline

a tag function to mark a csubstr payload to be encoded in base64 format

Definition at line 122 of file format_base64.hpp.

123{
124 return const_base64_wrapper(cblob(s.str, s.len), reqsize);
125}

Referenced by sample_base64().

◆ base64() [2/5]

base64_wrapper c4::fmt::base64 ( substr s,
size_t * reqsize = nullptr )
inline

a tag function to mark a variable to be decoded from base64

Definition at line 127 of file format_base64.hpp.

128{
129 return base64_wrapper(blob(s.str, s.len), reqsize);
130}
detail::base64_wrapper_< byte > base64_wrapper
a tag type to mark a payload to be decoded as base64

◆ cbase64() [2/4]

template<class T>
const_base64_wrapper c4::fmt::cbase64 ( T const * arg,
size_t sz,
size_t * reqsize = nullptr )
inline

a tag function to mark a payload to be encoded in base64 format

Definition at line 135 of file format_base64.hpp.

136{
137 return const_base64_wrapper(cblob(arg, sz), reqsize);
138}

◆ base64() [3/5]

template<class T>
auto c4::fmt::base64 ( T * arg,
size_t sz,
size_t * reqsize = nullptr )->typenamestd::conditional< std::is_const< typenamestd::remove_reference< typenamestd::remove_pointer< T >::type >::type >::value, const_base64_wrapper, base64_wrapper >::type
inline

a tag function to mark a payload to be encoded in base64 format

Definition at line 141 of file format_base64.hpp.

145{
146 using U = typename std::remove_reference<typename std::remove_pointer<T>::type>::type;
147 using ret_type = typename std::conditional<std::is_const<U>::value,
149 base64_wrapper>::type;
150 using blob_type = typename std::conditional<std::is_const<U>::value,
151 cblob,
152 blob>::type;
153 return ret_type(blob_type(arg, sz), reqsize);
154}

◆ cbase64() [3/4]

template<class T>
auto c4::fmt::cbase64 ( T const & arg,
size_t * reqsize = nullptr )->typenamestd::enable_if<!detail::has_resize< T >::value, const_base64_wrapper >::type
inline

a tag function to mark a payload to be encoded in base64 format

Definition at line 159 of file format_base64.hpp.

161{
162 return const_base64_wrapper(cblob(arg), reqsize);
163}

◆ base64() [4/5]

template<class T>
auto c4::fmt::base64 ( T & arg,
size_t * reqsize = nullptr )->typenamestd::enable_if<!detail::has_resize< T >::value, typenamestd::conditional< std::is_const< typenamestd::remove_reference< typenamestd::remove_pointer< T >::type >::type >::value, const_base64_wrapper, base64_wrapper >::type >::type
inline

a tag function to mark a payload to be encoded or decoded in base64 format

Definition at line 166 of file format_base64.hpp.

171{
172 using U = typename std::remove_reference<typename std::remove_pointer<T>::type>::type;
173 using ret_type = typename std::conditional<std::is_const<U>::value,
175 base64_wrapper>::type;
176 using blob_type = typename std::conditional<std::is_const<U>::value,
177 cblob,
178 blob>::type;
179 return ret_type(blob_type(arg), reqsize);
180}

◆ cbase64() [4/4]

template<class T>
auto c4::fmt::cbase64 ( T const & arg,
size_t * reqsize = nullptr )->typenamestd::enable_if< detail::has_resize< T >::value, const_base64_container_wrapper< T > >::type
inline

a tag function to mark a container (payload with a .resize() method) to be encoded in base64 format.

Definition at line 185 of file format_base64.hpp.

187{
188 return const_base64_container_wrapper<T>(&arg, reqsize);
189}
detail::base64_container_wrapper_< const Container, cbyte > const_base64_container_wrapper
a tag type to mark a payload as base64-encoded

◆ base64() [5/5]

template<class T>
auto c4::fmt::base64 ( T & arg,
size_t * reqsize = nullptr )->typenamestd::enable_if< detail::has_resize< T >::value, typenamestd::conditional< std::is_const< typenamestd::remove_reference< typenamestd::remove_pointer< T >::type >::type >::value, const_base64_container_wrapper< T >, base64_container_wrapper< T > >::type >::type
inline

a tag function to mark a container (payload with a .resize() method) to be encoded or decoded in base64 format.

Subsequently when decoding, from_chars() will resize the container to fit the decoded data.

Definition at line 195 of file format_base64.hpp.

200{
201 using ret_type = typename std::conditional<std::is_const<typename std::remove_reference<typename std::remove_pointer<T>::type>::type>::value,
204 return ret_type(&arg, reqsize);
205}
detail::base64_container_wrapper_< Container, byte > base64_container_wrapper
a tag type to mark a payload to be encoded as base64