class mrpt::serialization::CSchemeArchiveBase

Overview

Virtual base class for “schematic archives” (JSON, XML,…)

#include <mrpt/serialization/CSchemeArchiveBase.h>

class CSchemeArchiveBase
{
public:
    // typedefs

    typedef std::shared_ptr<CSchemeArchiveBase> Ptr;

    // construction

    CSchemeArchiveBase(std::unique_ptr<CSchemeArchiveBase_impl> ptr);
    CSchemeArchiveBase(CSchemeArchiveBase&& o);

    // methods

    CSchemeArchiveBase& operator = (const int32_t val);
    CSchemeArchiveBase& operator = (const uint32_t val);
    CSchemeArchiveBase& operator = (const int64_t val);
    CSchemeArchiveBase& operator = (const uint64_t val);
    CSchemeArchiveBase& operator = (const float val);
    CSchemeArchiveBase& operator = (const double val);
    CSchemeArchiveBase& operator = (std::string val);
    CSchemeArchiveBase& operator = (bool val);
    operator int32_t () const;
    operator uint32_t () const;
    operator int64_t () const;
    operator uint64_t () const;
    operator float () const;
    operator double () const;
    operator bool () const;
    operator std::string () const;
    void readTo(CSerializable& obj);
    CSchemeArchiveBase& operator = (const mrpt::serialization::CSerializable& obj);
    CSchemeArchiveBase operator [] (size_t val);
    CSchemeArchiveBase operator [] (std::string val);
    size_t size() const;
    void resize(size_t n);
};

Methods

size_t size() const

Number of elements of a list, or of entries of a dict.

It is 0 for a missing entry or a scalar, so lists need no separate count field:

const auto list = in["items"];
items.resize(list.size());
void resize(size_t n)

Makes this entry a list of n elements, to be written next with operator[](size_t).

Call it before writing a list, so an empty one is still written (as [] in JSON) instead of being left out.