Function to_arena

Summary

#include <src/c4/yml/tree.hpp>

(1) template <class T>
    std::enable_if<!std::is_floating_point< T >::value, csubstr >::type to_arena(T const &C4_RESTRICT a)

(2) template <class T>
    std::enable_if< std::is_floating_point< T >::value, csubstr >::type to_arena(T const &C4_RESTRICT a)

Function overload

Synopsis

#include <src/c4/yml/tree.hpp>

template <class T>
std::enable_if<!std::is_floating_point< T >::value, csubstr >::type to_arena(T const &C4_RESTRICT a)

Description

serialize the given non-floating-point variable to the tree's arena, growing it as needed to accomodate the serialization.

Note
Growing the arena may cause relocation of the entire existing arena, and thus change the contents of individual nodes.
See
alloc_arena()

Source

Lines 906-920 in src/c4/yml/tree.hpp.

template<class T>
typename std::enable_if<!std::is_floating_point<T>::value, csubstr>::type
to_arena(T const& C4_RESTRICT a)
{
    substr rem(m_arena.sub(m_arena_pos));
    size_t num = to_chars(rem, a);
    if(num > rem.len)
    {
        rem = _grow_arena(num);
        num = to_chars(rem, a);
        RYML_ASSERT(num <= rem.len);
    }
    rem = _request_span(num);
    return rem;
}

Synopsis

#include <src/c4/yml/tree.hpp>

template <class T>
std::enable_if< std::is_floating_point< T >::value, csubstr >::type to_arena(T const &C4_RESTRICT a)

Description

serialize the given floating-point variable to the tree's arena, growing it as needed to accomodate the serialization.

Note
Growing the arena may cause relocation of the entire existing arena, and thus change the contents of individual nodes.
See
alloc_arena()

Source

Lines 927-941 in src/c4/yml/tree.hpp.

template<class T>
typename std::enable_if<std::is_floating_point<T>::value, csubstr>::type
to_arena(T const& C4_RESTRICT a)
{
    substr rem(m_arena.sub(m_arena_pos));
    size_t num = to_chars_float(rem, a);
    if(num > rem.len)
    {
        rem = _grow_arena(num);
        num = to_chars_float(rem, a);
        RYML_ASSERT(num <= rem.len);
    }
    rem = _request_span(num);
    return rem;
}





Add Discussion as Guest

Log in