Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
Public Member Functions | Static Public Member Functions | Private Attributes
JSON::Node Class Reference

Inherits from JSON::Object, specialized in JSON Node. A Node owns a vector of Object. The Node's children can either be Leaf or other Node objects. This allows to store the tree structure of a .json file. More...

#include <jsonObject.h>

Inheritance diagram for JSON::Node:
[legend]

Public Member Functions

 Node (std::string const &specifier)
 Construtor with one paramter that initializes specifier. More...
 
bool isNode () const override
 Tells if the Object is a Node or not. More...
 
virtual void addChild (Child &child)
 Adds a child in the Node. More...
 
template<class T >
void addChild (std::unique_ptr< T > &child)
 Adds a child in the Node. More...
 
virtual void addChild (Child &&child)
 Adds a child in the Node. More...
 
template<class T >
void addChild (std::unique_ptr< T > &&child)
 Adds a child in the Node. More...
 
size_t size () const
 
bool empty () const
 Tells if the Node is empty. More...
 
std::vector< Child >::const_iterator begin () const
 
std::vector< Child >::const_iterator end () const
 
std::vector< Child >::iterator begin ()
 
std::vector< Child >::iterator end ()
 
ObjectgetChild (std::string const &spec) const
 Returns the first child that has a given specifier. More...
 
 Node (std::string const &specifier)
 Construtor with one paramter that initializes specifier. More...
 
bool isNode () const override
 Tells if the Object is a Node or not. More...
 
virtual void addChild (Child &child)
 Adds a child in the Node. More...
 
template<class T >
void addChild (std::unique_ptr< T > &child)
 Adds a child in the Node. More...
 
virtual void addChild (Child &&child)
 Adds a child in the Node. More...
 
template<class T >
void addChild (std::unique_ptr< T > &&child)
 Adds a child in the Node. More...
 
size_t size () const
 
bool empty () const
 Tells if the Node is empty. More...
 
std::vector< Child >::const_iterator begin () const
 
std::vector< Child >::const_iterator end () const
 
std::vector< Child >::iterator begin ()
 
std::vector< Child >::iterator end ()
 
ObjectgetChild (std::string const &spec) const
 Returns the first child that has a given specifier. More...
 
- Public Member Functions inherited from JSON::Object
 Object (std::string const &t_specifier)
 Construtor with one paramter that initializes specifier. More...
 
virtual ~Object ()
 Destructor.
 
std::string getSpecifier () const
 
 Object (std::string const &t_specifier)
 Construtor with one paramter that initializes specifier. More...
 
virtual ~Object ()
 Destructor.
 
std::string getSpecifier () const
 

Static Public Member Functions

static std::unique_ptr< Nodemake (std::string const &specifier)
 
static std::unique_ptr< Nodemake (std::string const &specifier)
 

Private Attributes

std::vector< Childchildren
 std::vector of Child owned by the Node. Each child is in the form of a unique_ptr to an Object, and can be either a Leaf or another Node.
 

Additional Inherited Members

- Protected Attributes inherited from JSON::Object
std::string specifier
 String that represents the specifier of the object. For example: "name": "electron" is an object of which the specifier is the string "name".
 

Detailed Description

Inherits from JSON::Object, specialized in JSON Node. A Node owns a vector of Object. The Node's children can either be Leaf or other Node objects. This allows to store the tree structure of a .json file.

Constructor & Destructor Documentation

◆ Node() [1/2]

JSON::Node::Node ( std::string const &  specifier)
inlineexplicit

Construtor with one paramter that initializes specifier.

Parameters
t_specifierName of the Node's specifier.

◆ Node() [2/2]

JSON::Node::Node ( std::string const &  specifier)
inlineexplicit

Construtor with one paramter that initializes specifier.

Parameters
t_specifierName of the Node's specifier.

Member Function Documentation

◆ addChild() [1/8]

virtual void JSON::Node::addChild ( Child child)
inlinevirtual

Adds a child in the Node.

Parameters
childNew child added in children.

Reimplemented in JSON::List, and JSON::List.

◆ addChild() [2/8]

virtual void JSON::Node::addChild ( Child child)
inlinevirtual

Adds a child in the Node.

Parameters
childNew child added in children.

Reimplemented in JSON::List, and JSON::List.

◆ addChild() [3/8]

template<class T >
void JSON::Node::addChild ( std::unique_ptr< T > &  child)
inline

Adds a child in the Node.

Parameters
childNew child added in children.

◆ addChild() [4/8]

template<class T >
void JSON::Node::addChild ( std::unique_ptr< T > &  child)
inline

Adds a child in the Node.

Parameters
childNew child added in children.

◆ addChild() [5/8]

virtual void JSON::Node::addChild ( Child &&  child)
inlinevirtual

Adds a child in the Node.

Parameters
childNew child added in children.

Reimplemented in JSON::List, and JSON::List.

◆ addChild() [6/8]

virtual void JSON::Node::addChild ( Child &&  child)
inlinevirtual

Adds a child in the Node.

Parameters
childNew child added in children.

Reimplemented in JSON::List, and JSON::List.

◆ addChild() [7/8]

template<class T >
void JSON::Node::addChild ( std::unique_ptr< T > &&  child)
inline

Adds a child in the Node.

Parameters
childNew child added in children.

◆ addChild() [8/8]

template<class T >
void JSON::Node::addChild ( std::unique_ptr< T > &&  child)
inline

Adds a child in the Node.

Parameters
childNew child added in children.

◆ begin() [1/4]

std::vector<Child>::const_iterator JSON::Node::begin ( ) const
inline
Returns
A const_iterator to the begining of children.

◆ begin() [2/4]

std::vector<Child>::const_iterator JSON::Node::begin ( ) const
inline
Returns
A const_iterator to the begining of children.

◆ begin() [3/4]

std::vector<Child>::iterator JSON::Node::begin ( )
inline
Returns
An iterator to the begining of children.

◆ begin() [4/4]

std::vector<Child>::iterator JSON::Node::begin ( )
inline
Returns
An iterator to the begining of children.

◆ empty() [1/2]

bool JSON::Node::empty ( ) const
inline

Tells if the Node is empty.

Returns
True if the node has no child.
False else.

◆ empty() [2/2]

bool JSON::Node::empty ( ) const
inline

Tells if the Node is empty.

Returns
True if the node has no child.
False else.

◆ end() [1/4]

std::vector<Child>::const_iterator JSON::Node::end ( ) const
inline
Returns
A const_iterator to the end of children.

◆ end() [2/4]

std::vector<Child>::const_iterator JSON::Node::end ( ) const
inline
Returns
A const_iterator to the end of children.

◆ end() [3/4]

std::vector<Child>::iterator JSON::Node::end ( )
inline
Returns
An iterator to the end of children.

◆ end() [4/4]

std::vector<Child>::iterator JSON::Node::end ( )
inline
Returns
An iterator to the end of children.

◆ getChild() [1/2]

Object* JSON::Node::getChild ( std::string const &  spec) const
inline

Returns the first child that has a given specifier.

Parameters
specString of the specifier to search.
Returns
An Object* pointing to the first child specified by spec in children.
nullptr if no child has been found.

◆ getChild() [2/2]

Object* JSON::Node::getChild ( std::string const &  spec) const
inline

Returns the first child that has a given specifier.

Parameters
specString of the specifier to search.
Returns
An Object* pointing to the first child specified by spec in children.
nullptr if no child has been found.

◆ isNode() [1/2]

bool JSON::Node::isNode ( ) const
inlineoverridevirtual

Tells if the Object is a Node or not.

Returns
True.

Reimplemented from JSON::Object.

◆ isNode() [2/2]

bool JSON::Node::isNode ( ) const
inlineoverridevirtual

Tells if the Object is a Node or not.

Returns
True.

Reimplemented from JSON::Object.

◆ size() [1/2]

size_t JSON::Node::size ( ) const
inline
Returns
children.size(), the number of children.

◆ size() [2/2]

size_t JSON::Node::size ( ) const
inline
Returns
children.size(), the number of children.

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