Function to_chars

Summary

#include <src/c4/base64.hpp>

(1) size_t to_chars(substr buf, fmt::const_base64_wrapper b)

#include <src/c4/format.hpp>

(2) size_t to_chars(substr buf, fmt::const_raw_wrapper r)

(3) template <class T>
    size_t to_chars(substr buf, fmt::boolalpha_< T > fmt)

(4) template <typename T>
    C4_ALWAYS_INLINE std::enable_if< std::is_signed< T >::value, size_t >::type to_chars(substr buf, fmt::integral_< T > fmt)

(5) template <typename T>
    C4_ALWAYS_INLINE std::enable_if< std::is_signed< T >::value, size_t >::type to_chars(substr buf, fmt::integral_padded_< T > fmt)

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

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

(8) size_t to_chars(substr buf, fmt::real_< float > fmt)

(9) size_t to_chars(substr buf, fmt::real_< double > fmt)

(10) template <class T>
     size_t to_chars(substr buf, fmt::left_< T > const &C4_RESTRICT align)

(11) template <class T>
     size_t to_chars(substr buf, fmt::right_< T > const &C4_RESTRICT align)

#include <src/c4/std/string.hpp>

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

Function overload

Synopsis

#include <src/c4/base64.hpp>

size_t to_chars(substr buf, fmt::const_base64_wrapper b)

Description

write a variable in base64 format

Mentioned in

Source

Lines 85-88 in src/c4/base64.hpp.

inline size_t to_chars(substr buf, fmt::const_base64_wrapper b)
{
    return base64_encode(buf, b.data);
}

Synopsis

#include <src/c4/format.hpp>

size_t to_chars(substr buf, fmt::const_raw_wrapper r)

Description

write a variable in raw binary format, using memcpy

Mentioned in

Source

Lines 16-34 in src/c4/format.cpp. Line 347 in src/c4/format.hpp.

size_t to_chars(substr buf, fmt::const_raw_wrapper r)
{
    void * vptr = buf.str;
    size_t space = buf.len;
    auto ptr = (decltype(buf.str)) std::align(r.alignment, r.len, vptr, space);
    if(ptr == nullptr)
    {
        // if it was not possible to align, return a conservative estimate
        // of the required space
        return r.alignment + r.len;
    }
    C4_CHECK(ptr >= buf.begin() && ptr <= buf.end());
    size_t sz = static_cast<size_t>(ptr - buf.str) + r.len;
    if(sz <= buf.len)
    {
        memcpy(ptr, r.buf, r.len);
    }
    return sz;
}

Synopsis

#include <src/c4/format.hpp>

template <class T>
size_t to_chars(substr buf, fmt::boolalpha_< T > fmt)

Description

write a variable as an alphabetic boolean, ie as either true or false

Mentioned in

Source

Lines 53-57 in src/c4/format.hpp.

template<class T>
inline size_t to_chars(substr buf, fmt::boolalpha_<T> fmt)
{
    return to_chars(buf, fmt.val ? "true" : "false");
}

Synopsis

#include <src/c4/format.hpp>

template <typename T>
C4_ALWAYS_INLINE std::enable_if< std::is_signed< T >::value, size_t >::type to_chars(substr buf, fmt::integral_< T > fmt)

Description

format an integral_ signed type

Mentioned in

Source

Lines 217-223 in src/c4/format.hpp.

template<typename T>
C4_ALWAYS_INLINE
typename std::enable_if<std::is_signed<T>::value, size_t>::type
to_chars(substr buf, fmt::integral_<T> fmt)
{
    return itoa(buf, fmt.val, fmt.radix);
}

Synopsis

#include <src/c4/format.hpp>

template <typename T>
C4_ALWAYS_INLINE std::enable_if< std::is_signed< T >::value, size_t >::type to_chars(substr buf, fmt::integral_padded_< T > fmt)

Description

format an integral_ signed type, pad with zeroes

Mentioned in

Source

Lines 225-231 in src/c4/format.hpp.

template<typename T>
C4_ALWAYS_INLINE
typename std::enable_if<std::is_signed<T>::value, size_t>::type
to_chars(substr buf, fmt::integral_padded_<T> fmt)
{
    return itoa(buf, fmt.val, fmt.radix, fmt.num_digits);
}

Synopsis

#include <src/c4/format.hpp>

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

Description

format an integral_ unsigned type

Mentioned in

Source

Lines 234-240 in src/c4/format.hpp.

template<typename T>
C4_ALWAYS_INLINE
typename std::enable_if<std::is_unsigned<T>::value, size_t>::type
to_chars(substr buf, fmt::integral_<T> fmt)
{
    return utoa(buf, fmt.val, fmt.radix);
}

Synopsis

#include <src/c4/format.hpp>

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

Description

format an integral_ unsigned type, pad with zeroes

Mentioned in

Source

Lines 242-248 in src/c4/format.hpp.

template<typename T>
C4_ALWAYS_INLINE
typename std::enable_if<std::is_unsigned<T>::value, size_t>::type
to_chars(substr buf, fmt::integral_padded_<T> fmt)
{
    return utoa(buf, fmt.val, fmt.radix, fmt.num_digits);
}

Synopsis

#include <src/c4/format.hpp>

size_t to_chars(substr buf, fmt::real_< float > fmt)

Description

No description yet.

Mentioned in

Source

Lines 275-275 in src/c4/format.hpp.

inline size_t to_chars(substr buf, fmt::real_< float> fmt) { return ftoa(buf, fmt.val, fmt.precision, fmt.fmt); }

Synopsis

#include <src/c4/format.hpp>

size_t to_chars(substr buf, fmt::real_< double > fmt)

Description

No description yet.

Mentioned in

Source

Lines 276-276 in src/c4/format.hpp.

inline size_t to_chars(substr buf, fmt::real_<double> fmt) { return dtoa(buf, fmt.val, fmt.precision, fmt.fmt); }

Synopsis

#include <src/c4/format.hpp>

template <class T>
size_t to_chars(substr buf, fmt::left_< T > const &C4_RESTRICT align)

Description

No description yet.

Mentioned in

Source

Lines 411-422 in src/c4/format.hpp.

template<class T>
size_t to_chars(substr buf, fmt::left_<T> const& C4_RESTRICT align)
{
    size_t ret = to_chars(buf, align.val);
    if(ret >= buf.len || ret >= align.width)
    {
        return ret > align.width ? ret : align.width;
    }
    buf.first(align.width).sub(ret).fill(align.pad);
    to_chars(buf, align.val);
    return align.width;
}

Synopsis

#include <src/c4/format.hpp>

template <class T>
size_t to_chars(substr buf, fmt::right_< T > const &C4_RESTRICT align)

Description

No description yet.

Mentioned in

Source

Lines 424-436 in src/c4/format.hpp.

template<class T>
size_t to_chars(substr buf, fmt::right_<T> const& C4_RESTRICT align)
{
    size_t ret = to_chars(buf, align.val);
    if(ret >= buf.len || ret >= align.width)
    {
        return ret > align.width ? ret : align.width;
    }
    size_t rem = static_cast<size_t>(align.width - ret);
    buf.first(rem).fill(align.pad);
    to_chars(buf.sub(rem), align.val);
    return align.width;
}

Synopsis

#include <src/c4/std/string.hpp>

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

Description

copy an std::string to a writeable string view

Mentioned in

Source

Lines 47-53 in src/c4/std/string.hpp.

inline size_t to_chars(c4::substr buf, std::string const& s)
{
    C4_ASSERT(!buf.overlaps(to_csubstr(s)));
    size_t len = buf.len < s.size() ? buf.len : s.size();
    memcpy(buf.str, s.data(), len);
    return s.size(); // return the number of needed chars
}





Add Discussion as Guest

Log in