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

Requires entry to be member of an enum. More...

#include <EnumRequirement.h>

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

Public Member Functions

 EnumRequirement ()
 Constructor.
 
virtual void Reset ()
 Clear enum value.
 
virtual void Parse (Value json, const std::string &)
 Parse JSON input value to generate enum. More...
 
virtual void Validate (const Value &json, const std::string &path)
 Validate that JSON value is member of the parsed enum. 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 void ClearErrors ()
 Clear list of error messages.
 
virtual bool HasNotices ()
 Check if notices have been queued. More...
 
std::vector< std::string > GetNotices ()
 Get list of notices. More...
 
virtual void ClearNotices ()
 Clear list of notice messages.
 
virtual ~Requirement ()
 Destructor.
 

Private Attributes

std::vector< Value > enum_
 Enum value.
 

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 entry to be member of an enum.

Definition at line 36 of file EnumRequirement.h.

Member Function Documentation

virtual void Json::EnumRequirement::Parse ( Value  json,
const std::string &   
)
inlinevirtual

Parse JSON input value to generate enum.

Parameters
jsonJSON input value.

Implements Json::Requirement.

Definition at line 55 of file EnumRequirement.h.

56  {
57  if(json.isArray())
58  for(auto& val : json)
59  enum_.push_back(val);
60  }
std::vector< Value > enum_
Enum value.
virtual void Json::EnumRequirement::Validate ( const Value &  json,
const std::string &  path 
)
inlinevirtual

Validate that JSON value is member of the parsed enum.

Parameters
jsonJSON value to be validated.
pathPath for JSON path specification.

Implements Json::Requirement.

Definition at line 67 of file EnumRequirement.h.

References Json::Requirement::PushError().

68  {
69  bool found = false;
70 
71  for(auto& val : enum_)
72  if(json == val)
73  found = true;
74 
75  if(!found)
76  PushError(path + ": Value is not a valid entry.");
77  }
void PushError(const std::string &error)
Add error to list of error messages.
Definition: Requirement.h:53
std::vector< Value > enum_
Enum value.

Here is the call graph for this function:


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