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

#include <section_schema.h>

Public Member Functions

 section_schema ()=delete
 
 section_schema (const section_schema &source)
 
section_schemaoperator= (const section_schema &source)
 
 section_schema (section_schema &&source)
 
section_schemaoperator= (section_schema &&source)
 
 section_schema (const section_schema_params &arguments)
 
const std::string & get_name () const
 
bool is_mandatory () const
 
const std::string & get_comment () const
 
void add_option (const option_schema &opt)
 
template<typename ArgType >
void add_option (const option_schema_params< ArgType > &arguments)
 
void remove_option (const std::string &name)
 
size_t size () const
 
option_schemaoperator[] (size_t index)
 
const option_schemaoperator[] (size_t index) const
 
option_schemaoperator[] (const std::string &option_name)
 
const option_schemaoperator[] (const std::string &option_name) const
 
bool contains (const std::string &option_name) const
 
void validate_section (section &sect, schema_mode mode) const
 
std::ostream & write_additional_info (std::ostream &os) const
 
std::ostream & write_section_name (std::ostream &os) const
 

Friends

INICPP_API friend std::ostream & operator<< (std::ostream &os, const section_schema &sect_schema)
 

Detailed Description

In section_schema are defined rules which ini section should fulfil. Section can be validated against section_schema objects.

Definition at line 37 of file section_schema.h.

Constructor & Destructor Documentation

inicpp::section_schema::section_schema ( )
delete

Default constructor is deleted.

inicpp::section_schema::section_schema ( const section_schema source)

Copy constructor.

Definition at line 6 of file section_schema.cpp.

inicpp::section_schema::section_schema ( section_schema &&  source)

Move constructor.

Definition at line 31 of file section_schema.cpp.

inicpp::section_schema::section_schema ( const section_schema_params arguments)

Construct section_schema from given arguments.

Parameters
argumentscreation parameters

Definition at line 49 of file section_schema.cpp.

Member Function Documentation

void inicpp::section_schema::add_option ( const option_schema opt)

Add option_schema to options list from given parameter.

Parameters
optoption_schema which will be added to this instance
Exceptions
ambiguity_exceptionif option_schema with given name exists

Definition at line 69 of file section_schema.cpp.

template<typename ArgType >
void inicpp::section_schema::add_option ( const option_schema_params< ArgType > &  arguments)
inline

Creates option_schema from given arguments and add it to options list.

Parameters
argumentscreation paramaters
Exceptions
ambiguity_exceptionif option_schema with given name exists

Definition at line 111 of file section_schema.h.

bool inicpp::section_schema::contains ( const std::string &  option_name) const

Tries to find option_schema with specified name inside this section.

Parameters
option_namename which is searched
Returns
true if option_schema with this name is present, false otherwise

Definition at line 140 of file section_schema.cpp.

const std::string & inicpp::section_schema::get_comment ( ) const

Get textual description of section.

Returns
constant reference

Definition at line 59 of file section_schema.cpp.

const std::string & inicpp::section_schema::get_name ( ) const

Gets name of section.

Returns
constant reference

Definition at line 54 of file section_schema.cpp.

bool inicpp::section_schema::is_mandatory ( ) const

Determines whether this section is mandatory.

Returns
true if section has to be in configuration

Definition at line 64 of file section_schema.cpp.

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

Copy assignment.

Definition at line 21 of file section_schema.cpp.

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

Move assignment.

Definition at line 36 of file section_schema.cpp.

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

Access option_schema on specified index.

Parameters
index
Returns
modifiable reference to stored option_schema
Exceptions
not_found_exceptionin case of out of range

Definition at line 104 of file section_schema.cpp.

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

Access constant reference on option_schema specified index.

Parameters
index
Returns
constant reference to stored option_schema
Exceptions
not_found_exceptionin case of out of range

Definition at line 113 of file section_schema.cpp.

option_schema & inicpp::section_schema::operator[] ( const std::string &  option_name)

Access option_schema with specified name

Parameters
option_name
Returns
modifiable reference to stored option_schema
Exceptions
not_found_exceptionif option_schema with given name does not exist

Definition at line 122 of file section_schema.cpp.

const option_schema & inicpp::section_schema::operator[] ( const std::string &  option_name) const

Access constant reference on option_schema with specified name

Parameters
option_name
Returns
constant reference to stored option_schema
Exceptions
not_found_exceptionif option_schema with given name does not exist

Definition at line 129 of file section_schema.cpp.

void inicpp::section_schema::remove_option ( const std::string &  name)

Remove containing option schema of given name.

Parameters
namename of option schema to be removed
Exceptions
not_found_exceptionif given option does not exist

Definition at line 81 of file section_schema.cpp.

size_t inicpp::section_schema::size ( ) const

Returns size of option schemas list

Returns
unsigned integer

Definition at line 99 of file section_schema.cpp.

void inicpp::section_schema::validate_section ( section sect,
schema_mode  mode 
) const

Validate given section againts this section_schema.

Parameters
sectvalidated section
modevalidation mode
Exceptions
validation_exceptionif schema cannot be validated

Definition at line 150 of file section_schema.cpp.

std::ostream & inicpp::section_schema::write_additional_info ( std::ostream &  os) const

To given output stream writes additional information about section. Written info is in ini comment format.

Parameters
osoutput stream
Returns
reference to output stream for better chaining

Definition at line 196 of file section_schema.cpp.

std::ostream & inicpp::section_schema::write_section_name ( std::ostream &  os) const

To given output stream writes name of this section. Written name is in ini format.

Parameters
osoutput stream
Returns
reference to output stream for better chaining

Definition at line 211 of file section_schema.cpp.

Friends And Related Function Documentation

INICPP_API friend std::ostream& operator<< ( std::ostream &  os,
const section_schema sect_schema 
)
friend

Classic stream operator for printing this instance to output stream.

Parameters
osoutput stream
sect_schemareference to section_schema instance to be written
Returns
reference to output stream which allows chaining

Definition at line 217 of file section_schema.cpp.


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