inicpp
C++ parser of INI files with schema validation.
inicpp::schema Class Reference

#include <schema.h>

Public Member Functions

 schema ()
 
 schema (const schema &source)
 
schemaoperator= (const schema &source)
 
 schema (schema &&source)
 
schemaoperator= (schema &&source)
 
void add_section (const section_schema &sect_schema)
 
void add_section (const section_schema_params &arguments)
 
void add_option (const std::string &section_name, const option_schema &opt_schema)
 
template<typename ArgType >
void add_option (const std::string &section_name, option_schema_params< ArgType > &arguments)
 
size_t size () const
 
section_schemaoperator[] (size_t index)
 
const section_schemaoperator[] (size_t index) const
 
section_schemaoperator[] (const std::string &section_name)
 
const section_schemaoperator[] (const std::string &section_name) const
 
bool contains (const std::string &section_name) const
 
void validate_config (config &cfg, schema_mode mode) const
 

Friends

INICPP_API friend std::ostream & operator<< (std::ostream &os, const schema &schm)
 

Detailed Description

Represents base point of schema validation. Object of config class is validated against this one. Can contain schemes of sections and in them schemes for options.

Definition at line 24 of file schema.h.

Constructor & Destructor Documentation

inicpp::schema::schema ( )

Default constructor.

Definition at line 5 of file schema.cpp.

inicpp::schema::schema ( const schema source)

Copy constructor.

Definition at line 9 of file schema.cpp.

inicpp::schema::schema ( schema &&  source)

Move constructor.

Definition at line 33 of file schema.cpp.

Member Function Documentation

void inicpp::schema::add_option ( const std::string &  section_name,
const option_schema opt_schema 
)

Adds option to the section_schema with specified name.

Parameters
section_namename of existing section
opt_schemaoptions_schema which will be added to section
Exceptions
not_found_exceptionif section_name does not exist
ambiguity_exceptionif option_schema with given name exists

Definition at line 72 of file schema.cpp.

template<typename ArgType >
void inicpp::schema::add_option ( const std::string &  section_name,
option_schema_params< ArgType > &  arguments 
)
inline

Creates option_schema from given arguments and adds it to specified section.

Parameters
section_name
argumentsoption_schema creation parameters
Exceptions
not_found_exceptionif section_name does not exist
ambiguity_exceptionif option_schema with given name exists

Definition at line 89 of file schema.h.

void inicpp::schema::add_section ( const section_schema sect_schema)

Adds section from given attribute to internal container.

Parameters
sect_schemaconstant reference to section_schema object
Exceptions
ambiguity_exceptionif section_schema with given name exists

Definition at line 48 of file schema.cpp.

void inicpp::schema::add_section ( const section_schema_params arguments)

From given section_schema_params structure section_schema is created and added to this scheme.

Parameters
argumentsnon-editable reference to input arguments
Exceptions
ambiguity_exceptionif section_schema with given name exists

Definition at line 60 of file schema.cpp.

bool inicpp::schema::contains ( const std::string &  section_name) const

Tries to find section_schema with specified name inside this config.

Parameters
section_namename which is searched
Returns
true if section_schema with this name is present, false otherwise

Definition at line 127 of file schema.cpp.

schema & inicpp::schema::operator= ( const schema source)

Copy assignment.

Definition at line 23 of file schema.cpp.

schema & inicpp::schema::operator= ( schema &&  source)

Move assignment.

Definition at line 38 of file schema.cpp.

section_schema & inicpp::schema::operator[] ( size_t  index)

Access section_schema on specified index.

Parameters
indexindex of requested value
Returns
modifiable reference to stored section_schema
Exceptions
not_found_exceptionif index is out of range

Definition at line 87 of file schema.cpp.

const section_schema & inicpp::schema::operator[] ( size_t  index) const

Access constant reference on section_schema on specified index.

Parameters
indexindex of requested value
Returns
constant reference to stored section_schema
Exceptions
not_found_exceptionif index is out of range

Definition at line 96 of file schema.cpp.

section_schema & inicpp::schema::operator[] ( const std::string &  section_name)

Access section_schema with specified name.

Parameters
section_namename of requested section_schema
Returns
modifiable reference to stored section_schema
Exceptions
not_found_exceptionif section_schema with given name does not exist

Definition at line 105 of file schema.cpp.

const section_schema & inicpp::schema::operator[] ( const std::string &  section_name) const

Access constant reference on section_schema with specified name.

Parameters
section_namename of requested section_schema
Returns
constant reference to stored section_schema
Exceptions
not_found_exceptionif section_schema with given name does not exist

Definition at line 116 of file schema.cpp.

size_t inicpp::schema::size ( ) const

Returns size of section schemas list

Returns
unsigned integer

Definition at line 82 of file schema.cpp.

void inicpp::schema::validate_config ( config cfg,
schema_mode  mode 
) const

Validate cfg against this schema in specified mode.

Parameters
cfgconfiguration which will be validated
modevalidation mode
Exceptions
validation_exceptionif schema cannot be validated

Definition at line 137 of file schema.cpp.

Friends And Related Function Documentation

INICPP_API friend std::ostream& operator<< ( std::ostream &  os,
const schema schm 
)
friend

Classic stream operator for printing this instance to output stream.

Parameters
osoutput stream
schmreference to schema instance to be written
Returns
reference to output stream which allows chaining

Definition at line 184 of file schema.cpp.


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