SSAGES  0.1
A MetaDynamics Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
AllOfRequirement.h
1 
26 #pragma once
27 
28 #include "Requirement.h"
29 #include "RequirementLoader.h"
30 #include <memory>
31 
32 namespace Json
33 {
35 
39  {
40  private:
42 
43  public:
46 
48  virtual void ClearErrors() override
49  {
50  for(auto& r : reqs_)
51  r->ClearErrors();
52 
54  }
55 
57  virtual void ClearNotices() override
58  {
59  for(auto& r : reqs_)
60  r->ClearNotices();
61 
63  }
64 
66  virtual void Reset() override
67  {
68  ClearErrors();
69  ClearNotices();
70  reqs_.clear();
71  }
72 
74 
81  virtual void Parse(Value json, const std::string& path) override
82  {
83  Reset();
84  RequirementLoader loader;
85 
86  auto& head = json.isMember("allOf") ? json["allOf"] : 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  }
96 
98 
102  virtual void Validate(const Value& json, const std::string& path) override
103  {
104  for(auto& r : reqs_)
105  {
106  r->Validate(json, path);
107 
108  if(r->HasErrors())
109  for(const auto& error : r->GetErrors())
110  PushError(error);
111 
112  if(r->HasNotices())
113  for(const auto& notice : r->GetNotices())
114  PushNotice(notice);
115  }
116  }
117  };
118 }
virtual void Reset() override
Reset all Requirements.
virtual void ClearErrors() override
Clear lists of errors for all Requirements.
void PushError(const std::string &error)
Add error to list of error messages.
Definition: Requirement.h:53
virtual void Parse(Value json, const std::string &path) override
Parse JSON value and add all loaded Requirements.
RequireList reqs_
List of Requirements.
virtual void ClearErrors()
Clear list of error messages.
Definition: Requirement.h:95
std::unique_ptr< Requirement > LoadRequirement(const Value &json)
Load specific requirement.
Requires that all of a list of Requirements hold.
virtual void ClearNotices() override
Clear lists of notices for all Requirements.
Helper class to load Requirement.
AllOfRequirement()
Constructor.
virtual void ClearNotices()
Clear list of notice messages.
Definition: Requirement.h:110
Requirements on input files.
Definition: Requirement.h:39
std::vector< std::unique_ptr< Requirement >> RequireList
List of Requirements.
Definition: Requirement.h:117
virtual void Validate(const Value &json, const std::string &path) override
Validate that all Requirements are met.
void PushNotice(const std::string &notice)
Add message to list of notices.
Definition: Requirement.h:62