SSAGES  0.9.3
Software Suite for Advanced General Ensemble Simulations
Public Member Functions | List of all members
Json::RequirementLoader Class Reference

Helper class to load Requirement. More...

#include <RequirementLoader.h>

Public Member Functions

std::unique_ptr< RequirementLoadRequirement (const Value &json)
 Load specific requirement. More...
 
std::unique_ptr< RequirementLoadExtended (const Value &json)
 Extended Requirement loader. More...
 
std::unique_ptr< RequirementLoadRequirement (const ValueType &type)
 Load Requirement based on Value Type. More...
 

Detailed Description

Helper class to load Requirement.

Definition at line 38 of file RequirementLoader.h.

Member Function Documentation

◆ LoadExtended()

std::unique_ptr< Requirement > Json::RequirementLoader::LoadExtended ( const Value &  json)

Extended Requirement loader.

Parameters
jsonJSON value specifying the type of Requirement.
Returns
Unique pointer to the Requirement.

Definition at line 77 of file RequirementLoader.cpp.

78  {
79  std::unique_ptr<Requirement> item = nullptr;
80  if(json.isObject() && json.isMember("allOf") && json["allOf"].isArray())
81  item = std::unique_ptr<Requirement>(new AllOfRequirement());
82  else if(json.isObject() && json.isMember("anyOf") && json["anyOf"].isArray())
83  item = std::unique_ptr<Requirement>(new AnyOfRequirement());
84  else if(json.isObject() && json.isMember("oneOf") && json["oneOf"].isArray())
85  item = std::unique_ptr<Requirement>(new OneOfRequirement());
86 
87  return item;
88  }

Referenced by Json::ObjectRequirement::Parse().

Here is the caller graph for this function:

◆ LoadRequirement() [1/2]

std::unique_ptr< Requirement > Json::RequirementLoader::LoadRequirement ( const Value &  json)

Load specific requirement.

Parameters
jsonJSON value specifying the type of Requirement.
Returns
Unique pointer to the Requirement.

Definition at line 42 of file RequirementLoader.cpp.

43  {
44  std::unique_ptr<Requirement> item = nullptr;
45  // Load up apitemriate requirement type.
46  if(json["type"].asString() == "string")
47  item = std::unique_ptr<Requirement>(new StringRequirement());
48  else if(json["type"].asString() == "integer")
49  item = std::unique_ptr<Requirement>(new IntegerRequirement());
50  else if(json["type"].asString() == "number")
51  item = std::unique_ptr<Requirement>(new NumberRequirement());
52  else if(json["type"].asString() == "object")
53  item = std::unique_ptr<Requirement>(new ObjectRequirement());
54  else if(json["type"].asString() == "array")
55  item = std::unique_ptr<Requirement>(new ArrayRequirement());
56  else if(json["type"].asString() == "boolean")
57  item = std::unique_ptr<Requirement>(new BooleanRequirement());
58  else if(json["type"].asString() == "null")
59  item = std::unique_ptr<Requirement>(new NullRequirement());
60  else if(json["allOf"].isArray())
61  item = std::unique_ptr<Requirement>(new AllOfRequirement());
62  else if(json["anyOf"].isArray())
63  item = std::unique_ptr<Requirement>(new AnyOfRequirement());
64  else if(json["oneOf"].isArray())
65  item = std::unique_ptr<Requirement>(new OneOfRequirement());
66  else if(json["enum"].isArray())
67  item = std::unique_ptr<Requirement>(new EnumRequirement());
68  else if(json["not"].isObject())
69  item = std::unique_ptr<Requirement>(new NotRequirement());
70  // last resort.
71  else if(json.isObject())
72  item = std::unique_ptr<Requirement>(new ObjectRequirement());
73 
74  return item;
75  }

Referenced by Json::AllOfRequirement::Parse(), Json::AnyOfRequirement::Parse(), Json::ArrayRequirement::Parse(), Json::NotRequirement::Parse(), Json::ObjectRequirement::Parse(), and Json::OneOfRequirement::Parse().

Here is the caller graph for this function:

◆ LoadRequirement() [2/2]

std::unique_ptr< Requirement > Json::RequirementLoader::LoadRequirement ( const ValueType &  type)

Load Requirement based on Value Type.

Parameters
typeValue Type specifying the Requirement.
Returns
Unique pointer to the Requirement.

Return a Requirement based on the given Value Type.

Definition at line 90 of file RequirementLoader.cpp.

91  {
92  std::unique_ptr<Requirement> item = nullptr;
93 
94  switch(type)
95  {
96  case nullValue:
97  item = std::unique_ptr<Requirement>(new NullRequirement());
98  break;
99  case intValue:
100  item = std::unique_ptr<Requirement>(new IntegerRequirement());
101  break;
102  case realValue:
103  item = std::unique_ptr<Requirement>(new NumberRequirement());
104  break;
105  case stringValue:
106  item = std::unique_ptr<Requirement>(new StringRequirement());
107  break;
108  case booleanValue:
109  item = std::unique_ptr<Requirement>(new BooleanRequirement());
110  break;
111  case arrayValue:
112  item = std::unique_ptr<Requirement>(new ArrayRequirement());
113  break;
114  case objectValue:
115  item = std::unique_ptr<Requirement>(new ObjectRequirement());
116  break;
117  default:
118  item = nullptr;
119  }
120 
121  return item;
122  }

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