Function to_chars

Summary

#include <src/c4/base64.hpp>

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

#include <src/c4/charconv.hpp>

(2) C4_ALWAYS_INLINE size_t to_chars(substr buf, uint8_t v)

(3) C4_ALWAYS_INLINE size_t to_chars(substr buf, uint16_t v)

(4) C4_ALWAYS_INLINE size_t to_chars(substr buf, uint32_t v)

(5) C4_ALWAYS_INLINE size_t to_chars(substr buf, uint64_t v)

(6) C4_ALWAYS_INLINE size_t to_chars(substr buf, int8_t v)

(7) C4_ALWAYS_INLINE size_t to_chars(substr buf, int16_t v)

(8) C4_ALWAYS_INLINE size_t to_chars(substr buf, int32_t v)

(9) C4_ALWAYS_INLINE size_t to_chars(substr buf, int64_t v)

(10) C4_ALWAYS_INLINE size_t to_chars(substr buf, float v)

(11) C4_ALWAYS_INLINE size_t to_chars(substr buf, double v)

(12) template <class T>
     C4_ALWAYS_INLINE size_t to_chars(substr s, T *v)

(13) size_t to_chars(substr buf, bool v)

(14) size_t to_chars(substr buf, char v)

(15) size_t to_chars(substr buf, csubstr v)

(16) size_t to_chars(substr buf, substr v)

(17) template <size_t N>
     size_t to_chars(substr buf, const char(&C4_RESTRICT v)[N])

(18) size_t to_chars(substr buf, const char *C4_RESTRICT v)

#include <src/c4/format.hpp>

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

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

(21) 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)

(22) 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)

(23) 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)

(24) 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)

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

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

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

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

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

(29) 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 74-77 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/charconv.hpp>

C4_ALWAYS_INLINE size_t to_chars(substr buf, uint8_t v)

Description

No description yet.

Mentioned in

Source

Lines 1278-1278 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE size_t to_chars(substr buf,  uint8_t v) { return utoa(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE size_t to_chars(substr buf, uint16_t v)

Description

No description yet.

Mentioned in

Source

Lines 1279-1279 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE size_t to_chars(substr buf, uint16_t v) { return utoa(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE size_t to_chars(substr buf, uint32_t v)

Description

No description yet.

Mentioned in

Source

Lines 1280-1280 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE size_t to_chars(substr buf, uint32_t v) { return utoa(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE size_t to_chars(substr buf, uint64_t v)

Description

No description yet.

Mentioned in

Source

Lines 1281-1281 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE size_t to_chars(substr buf, uint64_t v) { return utoa(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE size_t to_chars(substr buf, int8_t v)

Description

No description yet.

Mentioned in

Source

Lines 1282-1282 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE size_t to_chars(substr buf,   int8_t v) { return itoa(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE size_t to_chars(substr buf, int16_t v)

Description

No description yet.

Mentioned in

Source

Lines 1283-1283 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE size_t to_chars(substr buf,  int16_t v) { return itoa(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE size_t to_chars(substr buf, int32_t v)

Description

No description yet.

Mentioned in

Source

Lines 1284-1284 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE size_t to_chars(substr buf,  int32_t v) { return itoa(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE size_t to_chars(substr buf, int64_t v)

Description

No description yet.

Mentioned in

Source

Lines 1285-1285 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE size_t to_chars(substr buf,  int64_t v) { return itoa(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE size_t to_chars(substr buf, float v)

Description

No description yet.

Mentioned in

Source

Lines 1286-1286 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE size_t to_chars(substr buf,    float v) { return ftoa(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

C4_ALWAYS_INLINE size_t to_chars(substr buf, double v)

Description

No description yet.

Mentioned in

Source

Lines 1287-1287 in src/c4/charconv.hpp.

C4_ALWAYS_INLINE size_t to_chars(substr buf,   double v) { return dtoa(buf, v); }

Synopsis

#include <src/c4/charconv.hpp>

template <class T>
C4_ALWAYS_INLINE size_t to_chars(substr s, T *v)

Description

No description yet.

Mentioned in

Source

Lines 1343-1343 in src/c4/charconv.hpp.

template <class T> C4_ALWAYS_INLINE size_t to_chars(substr s, T *v) { return to_chars(s, *v); }

Synopsis

#include <src/c4/charconv.hpp>

size_t to_chars(substr buf, bool v)

Description

bool implementation

Mentioned in

Source

Lines 1368-1372 in src/c4/charconv.hpp.

inline size_t to_chars(substr buf, bool v)
{
    int val = v;
    return to_chars(buf, val);
}

Synopsis

#include <src/c4/charconv.hpp>

size_t to_chars(substr buf, char v)

Description

single-char implementation

Mentioned in

Source

Lines 1408-1412 in src/c4/charconv.hpp.

inline size_t to_chars(substr buf, char v)
{
    if(buf.len > 0) buf[0] = v;
    return 1;
}

Synopsis

#include <src/c4/charconv.hpp>

size_t to_chars(substr buf, csubstr v)

Description

csubstr implementation

Mentioned in

Source

Lines 1434-1440 in src/c4/charconv.hpp.

inline size_t to_chars(substr buf, csubstr v)
{
    C4_ASSERT(!buf.overlaps(v));
    size_t len = buf.len < v.len ? buf.len : v.len;
    memcpy(buf.str, v.str, len);
    return v.len;
}

Synopsis

#include <src/c4/charconv.hpp>

size_t to_chars(substr buf, substr v)

Description

substr

Mentioned in

Source

Lines 1460-1466 in src/c4/charconv.hpp.

inline size_t to_chars(substr buf, substr v)
{
    C4_ASSERT(!buf.overlaps(v));
    size_t len = buf.len < v.len ? buf.len : v.len;
    memcpy(buf.str, v.str, len);
    return v.len;
}

Synopsis

#include <src/c4/charconv.hpp>

template <size_t N>
size_t to_chars(substr buf, const char(&C4_RESTRICT v)[N])

Description

No description yet.

Mentioned in

Source

Lines 1495-1500 in src/c4/charconv.hpp.

template<size_t N>
inline size_t to_chars(substr buf, const char (& C4_RESTRICT v)[N])
{
    csubstr sp(v);
    return to_chars(buf, sp);
}

Synopsis

#include <src/c4/charconv.hpp>

size_t to_chars(substr buf, const char *C4_RESTRICT v)

Description

No description yet.

Mentioned in

Source

Lines 1502-1505 in src/c4/charconv.hpp.

inline size_t to_chars(substr buf, const char * C4_RESTRICT v)
{
    return to_chars(buf, to_csubstr(v));
}

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 14-32 in src/c4/format.cpp. Line 336 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 55-59 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 219-225 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 227-233 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 236-242 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 244-250 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 277-277 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 278-278 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 400-411 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;
    }
    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 413-425 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;
    }
    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