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

Requires that at least one of a list of Requirements hold. More...

#include <AnyOfRequirement.h>

Inheritance diagram for Json::AnyOfRequirement:
Inheritance graph
[legend]

Public Member Functions

 AnyOfRequirement ()
 Constructor.
 
virtual void ClearErrors () override
 Clear list of error messages for all Requirements.
 
virtual void ClearNotices () override
 Clear list of notices for all Requirements.
 
virtual void Reset () override
 Reset all Requirements.
 
virtual void Parse (Value json, const std::string &path) override
 Parse JSON value and create list of Requirements. More...
 
virtual void Validate (const Value &json, const std::string &path) override
 Validate that at least one Requirement holds. More...
 
- Public Member Functions inherited from Json::Requirement
bool HasErrors ()
 Check if errors have occured. More...
 
std::vector< std::string > GetErrors ()
 Get list of error messages. More...
 
virtual bool HasNotices ()
 Check if notices have been queued. More...
 
std::vector< std::string > GetNotices ()
 Get list of notices. More...
 
virtual ~Requirement ()
 Destructor.
 

Private Attributes

RequireList reqs_
 List of Requirements.
 

Additional Inherited Members

- Protected Member Functions inherited from Json::Requirement
void PushError (const std::string &error)
 Add error to list of error messages. More...
 
void PushNotice (const std::string &notice)
 Add message to list of notices. More...
 

Detailed Description

Requires that at least one of a list of Requirements hold.

Definition at line 37 of file AnyOfRequirement.h.

Member Function Documentation

◆ Parse()

virtual void Json::AnyOfRequirement::Parse ( Value  json,
const std::string &  path 
)
inlineoverridevirtual

Parse JSON value and create list of Requirements.

Parameters
jsonJSON input value.
pathPath for JSON path specification.

This function parses the given JSON value and creates a new Requirement for each value in the "anyOf" branch. The new Requirements are appended to the list of Requirements.

Implements Json::Requirement.

Definition at line 81 of file AnyOfRequirement.h.

82  {
83  Reset();
84  RequirementLoader loader;
85 
86  auto& head = json.isMember("anyOf") ? json["anyOf"] : json;
87 
88  for(auto& val : head)
89  if(auto req = loader.LoadRequirement(val))
90  {
91  reqs_.push_back(std::move(req));
92  reqs_.back()->Parse(val, path);
93  }
94 
95  }
RequireList reqs_
List of Requirements.
virtual void Reset() override
Reset all Requirements.

References Json::RequirementLoader::LoadRequirement(), reqs_, and Reset().

Here is the call graph for this function:

◆ Validate()

virtual void Json::AnyOfRequirement::Validate ( const Value &  json,
const std::string &  path 
)
inlineoverridevirtual

Validate that at least one Requirement holds.

Parameters
jsonJSON value to validate.
pathPath for JSON path specification.

Implements Json::Requirement.

Definition at line 102 of file AnyOfRequirement.h.

103  {
104  for(auto& r : reqs_)
105  {
106  r->Validate(json, path);
107  if(!r->HasErrors())
108  return;
109  }
110 
111  // Collect errors.
112  for(auto& r : reqs_)
113  {
114  if(r->HasErrors())
115  for(const auto& error : r->GetErrors())
116  PushError(error);
117 
118  if(r->HasNotices())
119  for(const auto& notice : r->GetNotices())
120  PushNotice(notice);
121  }
122  }
void PushNotice(const std::string &notice)
Add message to list of notices.
Definition: Requirement.h:62
void PushError(const std::string &error)
Add error to list of error messages.
Definition: Requirement.h:53

References Json::Requirement::PushError(), Json::Requirement::PushNotice(), and reqs_.

Here is the call graph for this function:

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