24 #include <boost/graph/adjacency_list.hpp>
60 virtual void open_tag(
const std::string& name,
const config& parent,
int start_line = 0,
const std::string& file =
"",
bool addition =
false)
override;
62 virtual void validate(
const config& cfg,
const std::string& name,
int start_line,
const std::string& file)
override;
78 typedef std::map<std::string, counter>
cnt_map;
155 template<
typename... T>
158 cache_.top()[&cfg].emplace_back(std::forward<T>(args)...);
171 std::pair<const wml_tag*, std::string>,
172 std::tuple<config, std::string, int>>;
186 const wml_tag*
tag,
const config& cfg, std::vector<const wml_tag*>& visited)
const;
192 const wml_tag*
tag,
const config& cfg,
const std::string& name,
int start_line,
const std::string& file);
196 const std::string& name,
198 const std::string& file,
199 std::vector<const wml_tag*>& visited);
207 link_graph_t::vertex_descriptor>;
220 virtual void open_tag(
const std::string& name,
const config& parent,
int start_line = 0,
const std::string& file =
"",
bool addition =
false)
override;
222 virtual void validate(
const config& cfg,
const std::string& name,
int start_line,
const std::string& file)
override;
226 reference(
const std::string& value,
const std::string& file,
int line,
const std::string&
tag)
234 bool match(
const std::set<std::string>& with)
const;
242 std::map<std::string, std::string>
links_;
247 static bool name_matches(
const std::string& pattern,
const std::string& name);
253 = boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, std::string, std::pair<config, reference>>;
Used in parsing config file.
Variant for storing WML attributes.
A config object defines a single node in a WML file, with access to child nodes.
virtual void open_tag(const std::string &name, const config &parent, int start_line=0, const std::string &file="", bool addition=false) override
Is called when parser opens tag.
virtual void validate(const config &cfg, const std::string &name, int start_line, const std::string &file) override
Validates config.
virtual void close_tag() override
As far as parser is built on stack, some realizations can store stack too.
std::stack< std::string > tag_stack_
std::multimap< std::string, std::string > derivations_
std::vector< reference > referenced_tag_paths_
std::map< std::string, std::string > links_
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, std::string, std::pair< config, reference > > schema_derivation_graph_t
bool tag_path_exists(const config &cfg, const reference &ref)
schema_derivation_graph_t schema_derivation_graph_
void detect_schema_derivation_cycles()
void print(message_info &message) override
void check_for_duplicates(const std::string &name, std::vector< std::string > &seen, const config &cfg, message_type type, const std::string &file, int line, const std::string &tag)
std::string current_path() const
std::vector< reference > referenced_types_
std::map< std::string, schema_derivation_graph_t::vertex_descriptor > schema_derivation_map_
std::set< std::string > defined_tag_paths_
static bool name_matches(const std::string &pattern, const std::string &name)
std::set< std::string > defined_types_
virtual void validate_key(const config &cfg, const std::string &name, const config_attribute_value &value, int start_line, const std::string &file) override
Checks if key is allowed and if its value is valid What exactly is validated depends on validator rea...
Realization of serialization/validator.hpp abstract validator.
bool read_config_file(const std::string &filename)
Reads config from input.
void set_create_exceptions(bool value)
const std::vector< std::string > & get_errors() const
wml_type::map types_
Type validators.
wml_tag root_
Root of schema information.
std::vector< std::string > errors_
virtual void validate(const config &cfg, const std::string &name, int start_line, const std::string &file) override
Validates config.
schema_validator(const std::string &filename, bool validate_schema=false)
Initializes validator from file.
bool create_exceptions_
Controls the way to print errors.
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, std::string > link_graph_t
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, std::pair< const wml_tag *, std::string >, std::tuple< config, std::string, int > > derivation_graph_t
utils::optional< std::map< std::string, wml_key > > find_mandatory_keys(const wml_tag *tag, const config &cfg) const
Collects all mandatory keys for a tag, including the super keys and overrides.
wml_type::ptr find_type(const std::string &type) const
void collect_link_source(link_graph_t &link_graph, link_graph_map_t &link_map, const std::string &type_name, const wml_type *type)
std::stack< message_map > cache_
Caches error messages.
std::map< const config *, message_list > message_map
derivation_graph_t derivation_graph_
void queue_message(const config &cfg, T &&... args)
cnt_stack counter_
Contains number of children.
virtual void validate_key(const config &cfg, const std::string &name, const config_attribute_value &value, int start_line, const std::string &file) override
Checks if key is allowed and if its value is valid What exactly is validated depends on validator rea...
std::stack< cnt_map > cnt_stack
And counter maps are organize in stack.
void detect_derivation_cycles()
std::deque< message_info > message_list
virtual ~schema_validator()
std::map< const wml_type_alias *, link_graph_t::vertex_descriptor > link_graph_map_t
bool config_read_
Shows, if validator is initialized with schema file.
void detect_link_cycles(const std::string &filename)
virtual void close_tag() override
As far as parser is built on stack, some realizations can store stack too.
std::string active_tag_path() const
void validate_mandatory_keys(const wml_tag *tag, const config &cfg, const std::string &name, int start_line, const std::string &file)
Validates that all mandatory keys for a tag are present.
const wml_tag & active_tag() const
void collect_link_target(link_graph_t &link_graph, link_graph_map_t &link_map, const std::string &type_name, const wml_type *type, const wml_type_alias *alias)
std::map< const wml_tag *, derivation_graph_t::vertex_descriptor > derivation_map_
virtual void open_tag(const std::string &name, const config &parent, int start_line=0, const std::string &file="", bool addition=false) override
Is called when parser opens tag.
std::stack< const wml_tag * > stack_
std::map< std::string, counter > cnt_map
Counters are mapped by tag name.
virtual void print(message_info &)
bool have_active_tag() const
Stores information about tag.
Stores information about a schema type.
Stores information about a schema type.
std::map< std::string, ptr > map
std::shared_ptr< wml_type > ptr
void line(int from_x, int from_y, int to_x, int to_y)
Draw a line.
std::string tag(const std::string &tag_name, Args &&... contents)
std::string filename
Filename.
bool match(const std::set< std::string > &with) const
bool can_find(const wml_tag &root, const config &cfg) const
reference(const std::string &value, const std::string &file, int line, const std::string &tag)
bool operator<(const reference &other) const
message_info(message_type t, const std::string &file, int line=0, int n=0, const std::string &tag="", const std::string &key="", const std::string &value="", const std::string &expected="")
This file contains object "tag", which is used to store information about tags while annotation parsi...
This file contains object "type", which is used to store information about types while annotation par...
This file contains information about validation abstract level interface.