Public Member Functions | Private Member Functions | Private Attributes

schema_validation::class_source_parser Class Reference

#include <sourceparser.hpp>

Collaboration diagram for schema_validation::class_source_parser:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 class_source_parser ()
 ~class_source_parser ()
void set_input (const std::string &s)
void set_output (const std::string &s)
bool parse_source ()
 Parses file line-by-line, checking every line to open WIKI block Please, notice that main input work is made in check_*** methods.
bool save_schema ()
 Saves tag tree to schema file.
void expand ()
 Expands all tags.
const std::vector< class_tag > & see_orphans () const
const class_error_containersee_errors () const
 Grants access to error container.

Private Member Functions

bool parse_block ()
 Parses WIKI block line-by-line, checking every line to open annotation block.
bool parse_tag ()
 Parses lines inside tag block.
bool parse_keys ()
 Read key table and add keys to tag on the top of the stack.
bool check_valid (const std::string &s)
 check the input line with a template check if the line is valid (still in block)
bool getline (std::string &s)
 Gets a line from file and returns it.
void close_opened_tags (int i)
 Сhecks stack of opened tags.
void add_open_tag_error (int i)
 Generates errors for each opened tag.
bool check_wiki (const std::string &s)
 Read tag form the line and add it to stack.
bool check_tag_begin (const std::string &s)
 Checks line for tag annotation.
bool check_tag_end (const std::string &s)
 Puts closed tag to child list of previous tag.
bool check_parent_begin (const std::string &s)
 Opens parrent block.
bool check_parent_end (const std::string &s)
 Closes parent block.
bool check_keys_begin (const std::string &s)
 Checks beginning of keys.
bool check_keys_end (const std::string &s)
 Checks end of keys.
bool check_allow_link (const std::string &s)
 Checks links.
bool check_allow_global (const std::string &s)
 Checks allowed global tags.
bool check_allow_type (const std::string &s)
 Checks allowed types.
bool check_remove_type (const std::string &s)
 Checks removed types.
bool check_remove_key (const std::string &s)
 Checks removed keys.

Private Attributes

std::string input_
 name of input file to be parsed
std::string output_
 name of output file to print schema
std::fstream f_
int line_
 number of current read line.
std::vector< class_tagcurrent_
 Stack of opened tags.
class_tag root_
 Root of the schema tree.
std::string parent_name_
 Name of current parent.
std::vector< class_tagorphan_tags_
 List of tags without parents.
class_error_container errors_
 used to store errors
std::map< std::string,
std::string > 
types_
 Allowed types.
std::vector< std::string > forbidden_
 Types to remove.

Detailed Description

Definition at line 70 of file sourceparser.hpp.


Constructor & Destructor Documentation

schema_validation::class_source_parser::class_source_parser (  )  [inline]

Definition at line 72 of file sourceparser.hpp.

schema_validation::class_source_parser::~class_source_parser (  )  [inline]

Definition at line 87 of file sourceparser.hpp.


Member Function Documentation

void schema_validation::class_source_parser::add_open_tag_error ( int  i = INT_MAX  )  [private]

Generates errors for each opened tag.

Parameters:
i number of tags in stack to complain.

Definition at line 263 of file sourceparser.cpp.

References schema_validation::class_error_container::add_opened_entity_error(), current_, errors_, input_, and line_.

Referenced by check_tag_end(), parse_block(), parse_keys(), and parse_tag().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_allow_global ( const std::string &  s  )  [private]

Checks allowed global tags.

Definition at line 524 of file sourceparser.cpp.

References current_, and schema_validation::get_allow_global().

Referenced by parse_tag().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_allow_link ( const std::string &  s  )  [private]

Checks links.

Definition at line 508 of file sourceparser.cpp.

References schema_validation::class_error_container::add_link_error(), current_, errors_, schema_validation::get_allow_link(), input_, line_, and root_.

Referenced by parse_tag().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_allow_type ( const std::string &  s  )  [private]

Checks allowed types.

Definition at line 577 of file sourceparser.cpp.

References errors_, schema_validation::get_allow_type(), input_, line_, schema_validation::class_error_container::overriding_type_error(), schema_validation::class_error_container::remove_type_errors(), types_, and schema_validation::class_error_container::wrong_type_error().

Referenced by parse_block().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_keys_begin ( const std::string &  s  )  [private]

Checks beginning of keys.

Definition at line 565 of file sourceparser.cpp.

References schema_validation::get_table_key_begin().

Referenced by parse_tag().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_keys_end ( const std::string &  s  )  [private]

Checks end of keys.

Definition at line 571 of file sourceparser.cpp.

References schema_validation::get_table_end().

Referenced by parse_keys().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_parent_begin ( const std::string &  s  )  [private]

Opens parrent block.

Definition at line 536 of file sourceparser.cpp.

References schema_validation::class_error_container::add_second_parent_error(), errors_, schema_validation::get_parent_begin(), input_, line_, parent, and parent_name_.

Referenced by parse_block().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_parent_end ( const std::string &  s  )  [private]

Closes parent block.

Definition at line 550 of file sourceparser.cpp.

References schema_validation::class_error_container::add_unopened_entity_error(), errors_, schema_validation::get_parent_end(), input_, line_, parent, and parent_name_.

Referenced by parse_block().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_remove_key ( const std::string &  s  )  [private]

Checks removed keys.

Definition at line 610 of file sourceparser.cpp.

References current_, and schema_validation::get_remove_key().

Referenced by parse_tag().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_remove_type ( const std::string &  s  )  [private]

Checks removed types.

Definition at line 598 of file sourceparser.cpp.

References errors_, forbidden_, schema_validation::get_remove_type(), schema_validation::class_error_container::remove_type_errors(), and types_.

Referenced by parse_block().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_tag_begin ( const std::string &  s  )  [private]

Checks line for tag annotation.

Reads tag and puts in into stack.

Definition at line 460 of file sourceparser.cpp.

References schema_validation::class_error_container::add_link_error(), current_, errors_, schema_validation::get_tag_begin(), input_, line_, root_, schema_validation::class_tag::set_max(), schema_validation::class_tag::set_min(), schema_validation::class_tag::set_name(), and schema_validation::class_tag::set_super().

Referenced by parse_block(), and parse_tag().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_tag_end ( const std::string &  s  )  [private]

Puts closed tag to child list of previous tag.

Also closes all opened child tags, if they are, and generates warnings.

Definition at line 482 of file sourceparser.cpp.

References add_open_tag_error(), schema_validation::class_error_container::add_unopened_entity_error(), close_opened_tags(), current_, errors_, schema_validation::get_tag_end(), input_, and line_.

Referenced by parse_tag().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_valid ( const std::string &  s  )  [private]

check the input line with a template check if the line is valid (still in block)

Definition at line 449 of file sourceparser.cpp.

References schema_validation::get_valid(), and schema_validation::valid.

Referenced by parse_block(), parse_keys(), and parse_tag().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::check_wiki ( const std::string &  s  )  [private]

Read tag form the line and add it to stack.

Definition at line 455 of file sourceparser.cpp.

References schema_validation::get_wiki().

Referenced by parse_source().

Here is the call graph for this function:

Here is the caller graph for this function:

void schema_validation::class_source_parser::close_opened_tags ( int  i = INT_MAX  )  [private]

Сhecks stack of opened tags.

If any tags is opened - closes it and adds to sublist of next tag in stack. Add last tag in stack to parent

Parameters:
i number of tags in stack to close.

Definition at line 271 of file sourceparser.cpp.

References schema_validation::class_error_container::add_orphan_error(), schema_validation::class_tag::add_tag(), current_, errors_, input_, line_, orphan_tags_, parent_name_, schema_validation::class_error_container::remove_link_errors(), and root_.

Referenced by check_tag_end(), parse_block(), parse_keys(), parse_source(), and parse_tag().

Here is the call graph for this function:

Here is the caller graph for this function:

void schema_validation::class_source_parser::expand (  )  [inline]

Expands all tags.

While expanding tag copies list of keys and links from super-tag And adds links to super-tag children to links list. Useful when debugging the schema_markup

Definition at line 116 of file sourceparser.hpp.

References schema_validation::class_tag::expand_all(), and root_.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::getline ( std::string &  s  )  [private]

Gets a line from file and returns it.

Is used to manage exceptions while IO.

Definition at line 247 of file sourceparser.cpp.

References schema_validation::class_error_container::add_read_error(), errors_, f_, input_, and line_.

Referenced by parse_block(), parse_keys(), parse_source(), and parse_tag().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::parse_block (  )  [private]

Parses WIKI block line-by-line, checking every line to open annotation block.

Definition at line 358 of file sourceparser.cpp.

References add_open_tag_error(), check_allow_type(), check_parent_begin(), check_parent_end(), check_remove_type(), check_tag_begin(), check_valid(), close_opened_tags(), current_, f_, getline(), and parse_tag().

Referenced by parse_source().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::parse_keys (  )  [private]

Read key table and add keys to tag on the top of the stack.

Definition at line 423 of file sourceparser.cpp.

References add_open_tag_error(), schema_validation::class_error_container::add_opened_entity_error(), schema_validation::class_error_container::add_type_error(), check_keys_end(), check_valid(), close_opened_tags(), current_, errors_, schema_validation::get_key_value(), getline(), input_, line_, type, and types_.

Referenced by parse_tag().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::parse_source (  ) 

Parses file line-by-line, checking every line to open WIKI block Please, notice that main input work is made in check_*** methods.

Methods parse_*** are used to organize alhoritm and set which regex template can be used in this context. The only exception is parse_keys, where table of keys is read and add to top of stack tags.

Definition at line 312 of file sourceparser.cpp.

References schema_validation::class_error_container::add_simple_error(), check_wiki(), close_opened_tags(), errors_, f_, getline(), in, input_, line_, parent_name_, and parse_block().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::parse_tag (  )  [private]

Parses lines inside tag block.

Calls checkers that are allowed in tag block

Definition at line 388 of file sourceparser.cpp.

References add_open_tag_error(), check_allow_global(), check_allow_link(), check_keys_begin(), check_remove_key(), check_tag_begin(), check_tag_end(), check_valid(), close_opened_tags(), current_, f_, getline(), and parse_keys().

Referenced by parse_block().

Here is the call graph for this function:

Here is the caller graph for this function:

bool schema_validation::class_source_parser::save_schema (  ) 

Saves tag tree to schema file.

Definition at line 214 of file sourceparser.cpp.

References schema_validation::class_error_container::add_simple_error(), errors_, forbidden_, output_, schema_validation::class_tag::print(), schema_validation::class_tag::remove_keys_by_type(), root_, and types_.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

const class_error_container& schema_validation::class_source_parser::see_errors (  )  const [inline]

Grants access to error container.

Definition at line 125 of file sourceparser.hpp.

References errors_.

Referenced by main().

Here is the caller graph for this function:

const std::vector<class_tag>& schema_validation::class_source_parser::see_orphans (  )  const [inline]

Definition at line 121 of file sourceparser.hpp.

References orphan_tags_.

void schema_validation::class_source_parser::set_input ( const std::string &  s  )  [inline]

Definition at line 90 of file sourceparser.hpp.

References input_.

Referenced by main().

Here is the caller graph for this function:

void schema_validation::class_source_parser::set_output ( const std::string &  s  )  [inline]

Definition at line 93 of file sourceparser.hpp.

References output_.

Referenced by main().

Here is the caller graph for this function:


Member Data Documentation

Definition at line 133 of file sourceparser.hpp.

Referenced by getline(), parse_block(), parse_source(), and parse_tag().

std::vector<std::string> schema_validation::class_source_parser::forbidden_ [private]

Types to remove.

Definition at line 151 of file sourceparser.hpp.

Referenced by check_remove_type(), and save_schema().

List of tags without parents.

Definition at line 145 of file sourceparser.hpp.

Referenced by close_opened_tags(), and see_orphans().

name of output file to print schema

Definition at line 132 of file sourceparser.hpp.

Referenced by save_schema(), and set_output().

Name of current parent.

Definition at line 143 of file sourceparser.hpp.

Referenced by check_parent_begin(), check_parent_end(), close_opened_tags(), and parse_source().

Root of the schema tree.

Definition at line 141 of file sourceparser.hpp.

Referenced by check_allow_link(), check_tag_begin(), close_opened_tags(), expand(), and save_schema().

std::map<std::string,std::string> schema_validation::class_source_parser::types_ [private]

Allowed types.

Definition at line 149 of file sourceparser.hpp.

Referenced by check_allow_type(), check_remove_type(), parse_keys(), and save_schema().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:25:49 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs