Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
serialbox::SavepointImpl Class Reference

Shared implementation of the Savepoint. More...

#include <SavepointImpl.h>

Public Member Functions

template<class StringType , class = typename std::enable_if<!std::is_same<StringType, json::json>::value>::type>
 SavepointImpl (const StringType &name)
 Construct an empty savepoint (wihtout metaInfo i.e this->empty() == true)
 
template<class StringType , class MetainfoType >
 SavepointImpl (StringType &&name, MetainfoType &&metaInfo)
 Construct savepoint with name and metaInfo
 
 SavepointImpl (const SavepointImpl &other)
 Copy constructor.
 
 SavepointImpl (SavepointImpl &&)=default
 Move constructor.
 
 SavepointImpl (const json::json &jsonNode)
 Construct from JSON.
 
SavepointImploperator= (const SavepointImpl &other)
 Copy assignment.
 
SavepointImploperator= (SavepointImpl &&)=default
 Move assignment.
 
template<class StringType , class ValueType >
void addMetainfo (StringType &&key, ValueType &&value)
 Add a new key = value pair to the metaInfo of the Savepoint. More...
 
template<class T , class StringType >
getMetainfoAs (StringType &&key) const
 Query metaInfo for key key and retrieve value as type T More...
 
bool operator== (const SavepointImpl &right) const
 Test for equality.
 
bool operator!= (const SavepointImpl &right) const
 Test for inequality.
 
void swap (SavepointImpl &other) noexcept
 Swap with other.
 
const std::string & name () const noexcept
 Access name.
 
MetainfoMapImplmetaInfo () noexcept
 Access meta-info.
 
const MetainfoMapImplmetaInfo () const noexcept
 
bool empty () const noexcept
 Returns a bool value indicating whether the savepoint is empty (i.e has no meta-information attached)
 
json::json toJSON () const
 Convert to JSON.
 
void fromJSON (const json::json &jsonNode)
 Construct from JSON node. More...
 
std::string toString () const
 Convert savepoint to string.
 
std::shared_ptr< MetainfoMapImpl > & metaInfoPtr () noexcept
 Get meta-info pointer.
 
const std::shared_ptr< MetainfoMapImpl > & metaInfoPtr () const noexcept
 

Friends

std::ostream & operator<< (std::ostream &stream, const SavepointImpl &s)
 Convert to stream.
 

Detailed Description

Shared implementation of the Savepoint.

Savepoints have a specialization of std::hash and can thus be used in hash-maps such as std::unordered_map.

Direct usage of this class is discouraged, use the Savepoint classes provided by the Frontends instead.

Definition at line 38 of file SavepointImpl.h.

Member Function Documentation

◆ addMetainfo()

template<class StringType , class ValueType >
void serialbox::SavepointImpl::addMetainfo ( StringType &&  key,
ValueType &&  value 
)
inline

Add a new key = value pair to the metaInfo of the Savepoint.

Parameters
keyKey of the new element
valueObject to be copied to (or moved as) the value of the new element
Exceptions
ExceptionValue cannot be inserted as it already exists

Definition at line 74 of file SavepointImpl.h.

◆ fromJSON()

void serialbox::SavepointImpl::fromJSON ( const json::json &  jsonNode)

Construct from JSON node.

Exceptions
ExceptionJSON node is ill-formed

Definition at line 34 of file SavepointImpl.cpp.

◆ getMetainfoAs()

template<class T , class StringType >
T serialbox::SavepointImpl::getMetainfoAs ( StringType &&  key) const
inline

Query metaInfo for key key and retrieve value as type T

Parameters
keyKey of the requested element
Exceptions
ExceptionKey key does not exist in the metaInfo map or value cannot be converted to type T

Definition at line 86 of file SavepointImpl.h.


The documentation for this class was generated from the following files: