SSAGES  0.9.3
Software Suite for Advanced General Ensemble Simulations
EnumRequirement.h
1 
26 #pragma once
27 
28 #include "Requirement.h"
29 
30 namespace Json
31 {
33 
37  {
38  private:
39  std::vector<Value> enum_;
40 
41  public:
44 
46  virtual void Reset()
47  {
48  enum_.clear();
49  }
50 
52 
55  virtual void Parse(Value json, const std::string&)
56  {
57  if(json.isArray())
58  for(auto& val : json)
59  enum_.push_back(val);
60  }
61 
63 
67  virtual void Validate(const Value& json, const std::string& path)
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  }
78  };
79 }
Requires entry to be member of an enum.
virtual void Reset()
Clear enum value.
virtual void Parse(Value json, const std::string &)
Parse JSON input value to generate enum.
EnumRequirement()
Constructor.
virtual void Validate(const Value &json, const std::string &path)
Validate that JSON value is member of the parsed enum.
std::vector< Value > enum_
Enum value.
Requirements on input files.
Definition: Requirement.h:40
void PushError(const std::string &error)
Add error to list of error messages.
Definition: Requirement.h:53