Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
Static Public Member Functions
JSON::Parser Class Reference

Class for static purpose only (i.e. not constructible) that gather data from a tree (JSON::Node object) read by JSON::Reader in a .json file. More...

#include <jsonLoader.h>

Static Public Member Functions

template<typename Targ >
static std::optional< Targ > parseArgument (Node *node, std::string const &specifier, bool mandatory=false)
 Allows to get arguments of a node, given the specifier and the type of the desired object. This function is not recursive: We search in children only, not grand-children. More...
 
template<typename Targ >
static std::optional< Targ > parseArgument (std::unique_ptr< Object > const &object, std::string const &specifier, bool mandatory=false)
 Allows to get arguments of a node, given the specifier and the type of the desired object. This function is not recursive: We search in children only, not grand-children. More...
 
static NodeparseNode (Node *parent, std::string const &specifier, bool mandatory=false)
 Allows to get a subNode of a node, given the specifier. This function is not recursive: We search in children only, not grand-children. More...
 
static NodeparseNode (std::unique_ptr< Object > const &parent, std::string const &specifier, bool mandatory=false)
 Allows to get a subNode of a node, given the specifier. This function is not recursive: We search in children only, not grand-children. More...
 
template<typename Targ >
static Targ interpretObject (Object *object)
 Returns the argument with the correct type from an Object that must be a Leaf. More...
 
static Nodeconvert (const std::unique_ptr< Object > &node)
 
template<typename Targ >
static std::optional< Targ > parseArgument (Node *node, std::string const &specifier, bool mandatory=false)
 Allows to get arguments of a node, given the specifier and the type of the desired object. This function is not recursive: We search in children only, not grand-children. More...
 
template<typename Targ >
static std::optional< Targ > parseArgument (std::unique_ptr< Object > const &object, std::string const &specifier, bool mandatory=false)
 Allows to get arguments of a node, given the specifier and the type of the desired object. This function is not recursive: We search in children only, not grand-children. More...
 
static NodeparseNode (Node *parent, std::string const &specifier, bool mandatory=false)
 Allows to get a subNode of a node, given the specifier. This function is not recursive: We search in children only, not grand-children. More...
 
static NodeparseNode (std::unique_ptr< Object > const &parent, std::string const &specifier, bool mandatory=false)
 Allows to get a subNode of a node, given the specifier. This function is not recursive: We search in children only, not grand-children. More...
 
template<typename Targ >
static Targ interpretObject (Object *object)
 Returns the argument with the correct type from an Object that must be a Leaf. More...
 
static Nodeconvert (const std::unique_ptr< Object > &node)
 

Detailed Description

Class for static purpose only (i.e. not constructible) that gather data from a tree (JSON::Node object) read by JSON::Reader in a .json file.

Member Function Documentation

◆ interpretObject() [1/2]

template<typename Targ >
static Targ JSON::Parser::interpretObject ( Object object)
inlinestatic

Returns the argument with the correct type from an Object that must be a Leaf.

Template Parameters
TargType of the argument to get (int, double, string, ...).
Parameters
objectunique_ptr to the Object. Must be a Leaf a type Targ, else this function raises an error.
Returns
The argument of the correct type.

◆ interpretObject() [2/2]

template<typename Targ >
static Targ JSON::Parser::interpretObject ( Object object)
inlinestatic

Returns the argument with the correct type from an Object that must be a Leaf.

Template Parameters
TargType of the argument to get (int, double, string, ...).
Parameters
objectunique_ptr to the Object. Must be a Leaf a type Targ, else this function raises an error.
Returns
The argument of the correct type.

◆ parseArgument() [1/4]

template<typename Targ >
static std::optional<Targ> JSON::Parser::parseArgument ( Node node,
std::string const &  specifier,
bool  mandatory = false 
)
inlinestatic

Allows to get arguments of a node, given the specifier and the type of the desired object. This function is not recursive: We search in children only, not grand-children.

Template Parameters
TargType of the considered Leaf (int, double, string, ...).
Parameters
nodePointer to the Node in which we search the Leaf.
specifierSpecifier to search.
mandatoryTells if the presence of the argument is mandatory. If true and not found, this function raises an error.
Returns
A std::optional<Targ> contaning the argument if found.
nullopt else.

◆ parseArgument() [2/4]

template<typename Targ >
static std::optional<Targ> JSON::Parser::parseArgument ( Node node,
std::string const &  specifier,
bool  mandatory = false 
)
inlinestatic

Allows to get arguments of a node, given the specifier and the type of the desired object. This function is not recursive: We search in children only, not grand-children.

Template Parameters
TargType of the considered Leaf (int, double, string, ...).
Parameters
nodePointer to the Node in which we search the Leaf.
specifierSpecifier to search.
mandatoryTells if the presence of the argument is mandatory. If true and not found, this function raises an error.
Returns
A std::optional<Targ> contaning the argument if found.
nullopt else.

◆ parseArgument() [3/4]

template<typename Targ >
static std::optional<Targ> JSON::Parser::parseArgument ( std::unique_ptr< Object > const &  object,
std::string const &  specifier,
bool  mandatory = false 
)
inlinestatic

Allows to get arguments of a node, given the specifier and the type of the desired object. This function is not recursive: We search in children only, not grand-children.

Template Parameters
TargType of the considered Leaf (int, double, string, ...).
Parameters
objectunique_ptr to the Object in which we search the Leaf.
specifierSpecifier to search.
mandatoryTells if the presence of the argument is mandatory. If true and not found, this function raises an error.
Returns
A std::optional<Targ> contaning the argument if found.
nullopt else.

◆ parseArgument() [4/4]

template<typename Targ >
static std::optional<Targ> JSON::Parser::parseArgument ( std::unique_ptr< Object > const &  object,
std::string const &  specifier,
bool  mandatory = false 
)
inlinestatic

Allows to get arguments of a node, given the specifier and the type of the desired object. This function is not recursive: We search in children only, not grand-children.

Template Parameters
TargType of the considered Leaf (int, double, string, ...).
Parameters
objectunique_ptr to the Object in which we search the Leaf.
specifierSpecifier to search.
mandatoryTells if the presence of the argument is mandatory. If true and not found, this function raises an error.
Returns
A std::optional<Targ> contaning the argument if found.
nullopt else.

◆ parseNode() [1/4]

static Node* JSON::Parser::parseNode ( Node parent,
std::string const &  specifier,
bool  mandatory = false 
)
static

Allows to get a subNode of a node, given the specifier. This function is not recursive: We search in children only, not grand-children.

Parameters
parentPointer to the Node in which we search the sub-Node.
specifierSpecifier to search.
mandatoryTells if the presence of the sub-Node is mandatory. If true and not found, this function raises an error.
Returns
A pointer to the sub-Node if found.
nullptr else.

◆ parseNode() [2/4]

Node * JSON::Parser::parseNode ( Node parent,
std::string const &  specifier,
bool  mandatory = false 
)
static

Allows to get a subNode of a node, given the specifier. This function is not recursive: We search in children only, not grand-children.

Parameters
parentPointer to the Node in which we search the sub-Node.
specifierSpecifier to search.
mandatoryTells if the presence of the sub-Node is mandatory. If true and not found, this function raises an error.
Returns
A pointer to the sub-Node if found.
nullptr else.

◆ parseNode() [3/4]

static Node* JSON::Parser::parseNode ( std::unique_ptr< Object > const &  parent,
std::string const &  specifier,
bool  mandatory = false 
)
static

Allows to get a subNode of a node, given the specifier. This function is not recursive: We search in children only, not grand-children.

Parameters
parentunique_ptr to the Object in which we search the sub-Node.
specifierSpecifier to search.
mandatoryTells if the presence of the sub-Node is mandatory. If true and not found, this function raises an error.
Returns
A pointer to the sub-Node if found.
nullptr else.

◆ parseNode() [4/4]

static Node* JSON::Parser::parseNode ( std::unique_ptr< Object > const &  parent,
std::string const &  specifier,
bool  mandatory = false 
)
static

Allows to get a subNode of a node, given the specifier. This function is not recursive: We search in children only, not grand-children.

Parameters
parentunique_ptr to the Object in which we search the sub-Node.
specifierSpecifier to search.
mandatoryTells if the presence of the sub-Node is mandatory. If true and not found, this function raises an error.
Returns
A pointer to the sub-Node if found.
nullptr else.

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