CASM
1.1.0
A Clusters Approach to Statistical Mechanics
|
#include <InputParser.hh>
Use when the JSON document is not associated with a single resulting value but instead is parsed with multiple subparsers
Definition at line 371 of file InputParser.hh.
Public Types | |
typedef std::multimap< fs::path, std::shared_ptr< KwargsParser > > | map_type |
Public Member Functions | |
ParentInputParser (jsonParser const &input) | |
Construct so that the ParentInputParser owns the jsonParser object. More... | |
ParentInputParser (std::shared_ptr< jsonParser const > _parent_input) | |
Construct so that the ParentInputParser owns the jsonParser object. More... | |
std::unique_ptr< RequiredType > | require (fs::path option, Args &&... args) |
void | require (RequiredType &value, fs::path option, Args &&... args) |
std::unique_ptr< RequiredType > | optional (fs::path option, Args &&... args) |
void | optional (RequiredType &value, fs::path option, Args &&... args) |
RequiredType | optional_else (fs::path option, const RequiredType &_default, Args &&... args) |
void | optional_else (RequiredType &value, fs::path option, const RequiredType &_default, Args &&... args) |
std::shared_ptr< InputParser< RequiredType > > | subparse (fs::path option, Args &&... args) |
std::shared_ptr< InputParser< RequiredType > > | subparse_if (fs::path option, Args &&... args) |
std::shared_ptr< InputParser< RequiredType > > | subparse_else (fs::path option, const RequiredType &_default, Args &&... args) |
std::shared_ptr< InputParser< RequiredType > > | parse_as (Args &&... args) |
const jsonParser & | parent () const |
fs::path | parent_path () const |
std::string | name () const |
Name of this->self, equivalent to this->path.filename().string() More... | |
bool | exists () const |
fs::path | relpath (const fs::path &val) const |
Return this->path / val, ensuring the result is a relative path. More... | |
map_type::const_iterator | begin () const |
Begin iterator over subparsers. More... | |
map_type::const_iterator | end () const |
End iterator over subparsers. More... | |
bool | valid () const |
Return true if this and and all subparsers are valid. More... | |
std::map< fs::path, std::set< std::string > > | all_warnings () const |
Return warning messages from this and all subparsers. More... | |
std::map< fs::path, std::set< std::string > > | all_errors () const |
Return error messages from this and all subparsers. More... | |
void | insert (fs::path path, const std::shared_ptr< KwargsParser > &subparser) |
Validator & | insert (const Validator &other) |
Validator & | insert (const Validator &other) |
void | insert_error (fs::path option, std::string message) |
Insert a subparser at location option with a single error message More... | |
void | insert_warning (fs::path option, std::string message) |
Insert a subparser at location option with a single warning message More... | |
bool | warn_unnecessary (const std::set< std::string > &expected) |
Insert a warning if any unexpected JSON attributes are found in self. More... | |
void | clear () |
Public Attributes | |
std::shared_ptr< jsonParser const > | parent_input |
std::unique_ptr< std::nullptr_t > | value |
jsonParser const & | input |
Reference to the top of the JSON document being parsed. More... | |
fs::path | path |
jsonParser const & | self |
bool | required |
If this->input.at(this->path) is required to exist. More... | |
std::string | type_name |
std::set< std::string > | error |
std::set< std::string > | warning |
Private Types | |
typedef map_type::value_type | PairType |
Private Attributes | |
map_type | m_subparsers |
|
inherited |
Definition at line 134 of file InputParser.hh.
|
privateinherited |
Definition at line 172 of file InputParser.hh.
|
inline |
Construct so that the ParentInputParser owns the jsonParser object.
Definition at line 376 of file InputParser.hh.
|
inline |
Construct so that the ParentInputParser owns the jsonParser object.
Definition at line 380 of file InputParser.hh.
|
inherited |
Return error messages from this and all subparsers.
Definition at line 77 of file InputParser.cc.
|
inherited |
Return warning messages from this and all subparsers.
Definition at line 61 of file InputParser.cc.
|
inherited |
Begin iterator over subparsers.
Definition at line 48 of file InputParser.cc.
|
inlineinherited |
Definition at line 14 of file Validator.hh.
|
inherited |
End iterator over subparsers.
Definition at line 52 of file InputParser.cc.
|
inherited |
Check if this->input.find_at(this->path) exists
When KwargsParser is contructed with a path that does not exist, then this->self=this->input.
Definition at line 44 of file InputParser.cc.
|
inlineinherited |
Definition at line 19 of file Validator.hh.
Definition at line 19 of file Validator.hh.
|
inherited |
Insert a subparser
Subparsers are stored in a map of path (from this->input) to the subparser. After being inserted, the subparser's errors and warnings are included in validation checks (valid
) and in parser output (make_report
, print_warnings
, print_errors
, etc.).
Definition at line 92 of file InputParser.cc.
|
inherited |
Insert a subparser at location option
with a single error message
Definition at line 97 of file InputParser.cc.
|
inherited |
Insert a subparser at location option
with a single warning message
Definition at line 104 of file InputParser.cc.
|
inherited |
Name of this->self, equivalent to this->path.filename().string()
Definition at line 42 of file InputParser.cc.
|
inherited |
Check that if self.find_at(option) exists it can constructed as type RequiredType, returning result in unique_ptr
Failing to parse the component will result in errors of type:
If self.find_at(option) does not exist, return empty unique_ptr
Definition at line 288 of file InputParser_impl.hh.
|
inherited |
Check that if self.find_at(option) exists it can constructed as type RequiredType, assigning result to value
Failing to parse the component will result in errors of type:
If self.find_at(option) does not exist, do not change value
and do not insert an error.
Definition at line 301 of file InputParser_impl.hh.
|
inherited |
Check for self.find_at(option), return value or default, error if cannot be constructed
Failing to parse the component will result in errors of type:
If self.find_at(option) does not exist, return _default
and do not insert an error.
Definition at line 314 of file InputParser_impl.hh.
|
inherited |
Check for self.find_at(option), assign result or default, error if cannot be constructed
Failing to parse the component will result in errors of type:
If self.find(option) does not exist, assign _default
to value
and do not insert an error.
Definition at line 328 of file InputParser_impl.hh.
|
inherited |
Return a const reference to the parent JSON object of this->self
If self==input, returns self.
Definition at line 33 of file InputParser.cc.
|
inherited |
Return a fs::path from the top-level to the parent JSON object of this->self
The result satisfies: this->parent()==this->input.find_at(this->parent_path())
Definition at line 40 of file InputParser.cc.
|
inherited |
Parse this->self
as RequiredType
args | Arguments forwared to the parse method |
Definition at line 366 of file InputParser_impl.hh.
|
inlineinherited |
Return this->path / val, ensuring the result is a relative path.
Definition at line 128 of file InputParser.hh.
|
inherited |
Require self.find_at(option) of type RequiredType, returning result in unique_ptr
Failing to parse the component will result in errors of type:
Definition at line 265 of file InputParser_impl.hh.
|
inherited |
Require self.find_at(option) of type RequiredType, assigning result to value
Failing to parse the component will result in errors of type:
Definition at line 276 of file InputParser_impl.hh.
|
inherited |
Run an InputParser on the JSON subobject at this->path / option, collecting errors and warnings
Will:
Equivalent to:
Definition at line 345 of file InputParser_impl.hh.
|
inherited |
Subparse, if this->path / option
exists, else the result->value will be copy-constructed from _default
Definition at line 358 of file InputParser_impl.hh.
|
inherited |
Subparse, if this->path / option
exists
If the JSON subobject does not exist, the result->value will be empty
Definition at line 352 of file InputParser_impl.hh.
|
inherited |
Return true if this and and all subparsers are valid.
Definition at line 56 of file InputParser.cc.
|
inherited |
Insert a warning if any unexpected JSON attributes are found in self.
Definition at line 111 of file InputParser.cc.
|
inherited |
Definition at line 11 of file Validator.hh.
|
inherited |
Reference to the top of the JSON document being parsed.
Definition at line 68 of file InputParser.hh.
|
privateinherited |
Used to store sub-parsers. Allows code re-use w/ storage of all errors & warnings. Can use static_cast to get values from InputParser subparsers if they are included.
Definition at line 178 of file InputParser.hh.
std::shared_ptr<jsonParser const> CASM::ParentInputParser::parent_input |
Definition at line 373 of file InputParser.hh.
|
inherited |
Path to the JSON component to be parsed from the opt of the JSON document. If it exists, this->self = this->input.at(this->path))
Definition at line 72 of file InputParser.hh.
|
inherited |
If this->input.at(this->path) is required to exist.
Definition at line 84 of file InputParser.hh.
|
inherited |
Reference to the JSON component to be parsed, if it exists, otherwise set to this->input
Note:
Definition at line 81 of file InputParser.hh.
|
inherited |
Default empty, can be used to differentiate between parsers when multiple values are parsed from a single JSON object
Definition at line 88 of file InputParser.hh.
|
inherited |
Store the object being read from JSON, use unique_ptr so default constructor not necessary
Definition at line 234 of file InputParser.hh.
|
inherited |
Definition at line 12 of file Validator.hh.