pianod2
multisource multiuser scriptable networked music player
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Parsnip::ConjunctionSchema Class Reference

A meta-schema that determines if any, all, or exactly one or none of its subschemas are valid. More...

#include <parsnip_schema.h>

Inheritance diagram for Parsnip::ConjunctionSchema:
Inheritance graph
[legend]
Collaboration diagram for Parsnip::ConjunctionSchema:
Collaboration graph
[legend]

Public Types

enum class  Action { All , Any , ExactlyOne , Not }
 

Public Member Functions

 ConjunctionSchema (const ConjunctionSchema &)=default
 
 ConjunctionSchema (ConjunctionSchema &&)=default
 
ConjunctionSchemaoperator= (const ConjunctionSchema &)=default
 
ConjunctionSchemaoperator= (ConjunctionSchema &&)=default
 
 ConjunctionSchema (const Parsnip::Data &schema_spec)
 
virtual ConjunctionSchemacreateCopy () const override
 Create an identical, deep copy of the schema. More...
 
virtual void validate (const Parsnip::Data &entry) const override
 Verify that Data matches the schema. More...
 
virtual bool operator== (const SchemaBase &other) const override
 Check if two schemas perform the same validation. More...
 
virtual std::ostream & dump (std::ostream &target, int indent, bool suppress_ident=false) const override
 Render the schema in human-friendly text. More...
 
- Public Member Functions inherited from Parsnip::SchemaBase
virtual ~SchemaBase ()=default
 
bool operator!= (const SchemaBase &other) const
 
virtual void mergeSchemas (const SchemaBase &from)
 Merge elements into the current schema. More...
 

Static Public Member Functions

static bool is_conjunction (const Parsnip::Data &schema_spec)
 Checks a schema specification for a conjunction. More...
 

Private Types

using ChildrenList = std::vector< SchemaBaseRef >
 

Private Member Functions

Parsnip::Data merge_dictionaries (const Parsnip::Data &baseline, const Parsnip::Data &overrides)
 

Static Private Member Functions

static std::string get_action_name (const Parsnip::Data &schema_spec)
 Retrieve the conjunction action name from a dictionary. More...
 

Private Attributes

std::string action_name
 
Action action = Action::Any
 
ChildrenList children
 

Static Private Attributes

static const std::unordered_map< std::string, Actionkey_names
 Name-to-enumeration mappings for the various conjunctions. More...
 

Additional Inherited Members

- Protected Types inherited from Parsnip::SchemaBase
using StringType = Data::StringType
 
using SchemaRegex = std::basic_regex< StringType::value_type >
 
- Protected Member Functions inherited from Parsnip::SchemaBase
 SchemaBase ()=default
 
 SchemaBase (const SchemaBase &)=default
 
 SchemaBase (SchemaBase &&)=default
 
SchemaBaseoperator= (const SchemaBase &)=default
 
SchemaBaseoperator= (SchemaBase &&)=default
 
 SchemaBase (const Parsnip::Data &schema_spec)
 Construct a schema from a JSON specification. More...
 
void checkType (Data::Type expected, const Parsnip::Data &entry) const
 Check that Data item is an allowed type. More...
 
bool isValidlyNull (const Parsnip::Data &entry) const
 Determine if the data is Null and if that is allowed. More...
 
bool isType (Data::Type expected, const Parsnip::Data &entry) const
 Check if a data object is a particular type. More...
 
- Protected Attributes inherited from Parsnip::SchemaBase
bool nullable = false
 If true, element may be null. More...
 

Detailed Description

A meta-schema that determines if any, all, or exactly one or none of its subschemas are valid.

Also provides "not".

Member Typedef Documentation

◆ ChildrenList

Member Enumeration Documentation

◆ Action

Enumerator
All 
Any 
ExactlyOne 
Not 

Constructor & Destructor Documentation

◆ ConjunctionSchema() [1/3]

Parsnip::ConjunctionSchema::ConjunctionSchema ( const ConjunctionSchema )
default
Here is the caller graph for this function:

◆ ConjunctionSchema() [2/3]

Parsnip::ConjunctionSchema::ConjunctionSchema ( ConjunctionSchema &&  )
default

◆ ConjunctionSchema() [3/3]

Parsnip::ConjunctionSchema::ConjunctionSchema ( const Parsnip::Data schema_spec)
Here is the call graph for this function:

Member Function Documentation

◆ createCopy()

ConjunctionSchema * Parsnip::ConjunctionSchema::createCopy ( ) const
overridevirtual

Create an identical, deep copy of the schema.

Caller is responsible for deleting it.

Implements Parsnip::SchemaBase.

Here is the call graph for this function:

◆ dump()

std::ostream & Parsnip::ConjunctionSchema::dump ( std::ostream &  target,
int  indent,
bool  suppress_indent = false 
) const
overridevirtual

Render the schema in human-friendly text.

Parameters
targetWhere to write the schema.
indentAmount of indent to use.
suppress_indentFlag indicating indent was already performed.

Implements Parsnip::SchemaBase.

Here is the call graph for this function:

◆ get_action_name()

std::string Parsnip::ConjunctionSchema::get_action_name ( const Parsnip::Data schema_spec)
staticprivate

Retrieve the conjunction action name from a dictionary.

Parameters
schema_specThe schema specification.
Returns
The action name found.
Exceptions
SchemaConflictif the schema specifies multiple conjoining actions.
Here is the call graph for this function:

◆ is_conjunction()

bool Parsnip::ConjunctionSchema::is_conjunction ( const Parsnip::Data schema_spec)
static

Checks a schema specification for a conjunction.

Returns
True if a conjunction is present, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ merge_dictionaries()

Parsnip::Data Parsnip::ConjunctionSchema::merge_dictionaries ( const Parsnip::Data baseline,
const Parsnip::Data overrides 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

ConjunctionSchema& Parsnip::ConjunctionSchema::operator= ( ConjunctionSchema &&  )
default

◆ operator=() [2/2]

ConjunctionSchema& Parsnip::ConjunctionSchema::operator= ( const ConjunctionSchema )
default

◆ operator==()

bool Parsnip::ConjunctionSchema::operator== ( const SchemaBase other) const
overridevirtual

Check if two schemas perform the same validation.

Compare two schemas to see if they determine validity in the same manner.

Parameters
otherThe schema to compare to.
Returns
True if the schemas match, false otherwise.

Reimplemented from Parsnip::SchemaBase.

Here is the call graph for this function:

◆ validate()

void Parsnip::ConjunctionSchema::validate ( const Parsnip::Data entry) const
overridevirtual

Verify that Data matches the schema.

Parameters
entryThe data to validate.
Exceptions
Variousexceptions.

Implements Parsnip::SchemaBase.

Member Data Documentation

◆ action

Action Parsnip::ConjunctionSchema::action = Action::Any
private

◆ action_name

std::string Parsnip::ConjunctionSchema::action_name
private

◆ children

ChildrenList Parsnip::ConjunctionSchema::children
private

◆ key_names

const std::unordered_map< std::string, ConjunctionSchema::Action > Parsnip::ConjunctionSchema::key_names
staticprivate
Initial value:

Name-to-enumeration mappings for the various conjunctions.


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