Function write

Summary

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

(1) template <class T>
    void write(NodeRef *n, T const &v)

#include <src/c4/yml/std/map.hpp>

(2) template <class K, class V, class Less, class Alloc>
    void write(c4::yml::NodeRef *n, std::map< K, V, Less, Alloc > const &m)

#include <src/c4/yml/std/vector.hpp>

(3) template <class V, class Alloc>
    void write(c4::yml::NodeRef *n, std::vector< V, Alloc > const &vec)

Function overload

Synopsis

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

template <class T>
void write(NodeRef *n, T const &v)

Description

No description yet.

Mentioned in

Source

Lines 786-790 in src/c4/yml/node.hpp. Line 26 in src/c4/yml/node.hpp.

template<class T>
inline void write(NodeRef *n, T const& v)
{
    n->set_val_serialized(v);
}

Synopsis

#include <src/c4/yml/std/map.hpp>

template <class K, class V, class Less, class Alloc>
void write(c4::yml::NodeRef *n, std::map< K, V, Less, Alloc > const &m)

Description

std::map requires child nodes in the data tree hierarchy (a MAP node in ryml parlance). So it should be serialized via write()/read().

Mentioned in

Source

Lines 16-26 in src/c4/yml/std/map.hpp.

template<class K, class V, class Less, class Alloc>
void write(c4::yml::NodeRef *n, std::map<K, V, Less, Alloc> const& m)
{
    *n |= c4::yml::MAP;
    for(auto const& p : m)
    {
        auto ch = n->append_child();
        ch << c4::yml::key(p.first);
        ch << p.second;
    }
}

Synopsis

#include <src/c4/yml/std/vector.hpp>

template <class V, class Alloc>
void write(c4::yml::NodeRef *n, std::vector< V, Alloc > const &vec)

Description

vector is a sequence-like type, and it requires child nodes in the data tree hierarchy (a SEQ node in ryml parlance). So it should be serialized via write()/read().

Mentioned in

Source

Lines 15-23 in src/c4/yml/std/vector.hpp.

template<class V, class Alloc>
void write(c4::yml::NodeRef *n, std::vector<V, Alloc> const& vec)
{
    *n |= c4::yml::SEQ;
    for(auto const& v : vec)
    {
        n->append_child() << v;
    }
}





Add Discussion as Guest

Log in