The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
error_container.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2016 by Sytyi Nick <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * This file contains implementation of error_container.hpp.
18  */
19 
21 
22 namespace schema_validation{
23 
25  list_.push_back(message);
26 }
27 
29  std::ostringstream s;
30  s << file << ":" << line <<": Read error at line "<< line <<".\n";
31  list_.push_back(s.str());
32 }
33 
35  const std::string & file,int line,const std::string & name){
36  std::ostringstream s;
37  s << file << ":" << line <<": Entity "<< name
38  <<" is opened but not closed.\n";
39  list_.push_back(s.str());
40 }
41 
43  const std::string & file,int line,const std::string & name){
44  std::ostringstream s;
45  s << file << ":" << line <<": Entity "<< name
46  <<" is being closed but was not opened.\n";
47  list_.push_back(s.str());
48 }
49 
51  const std::string & file,int line,const std::string & first,
52  const std::string & second){
53  std::ostringstream s;
54  s << file << ":" << line <<": Parent "<< first <<" is closed due to parent"
55  << second << "is opened here. \n";
56  list_.push_back(s.str());
57 }
58 
60  const std::string & name){
61  std::ostringstream s;
62  s << file << ":" << line <<": Tag "<< name <<" has no parent \n";
63  list_.push_back(s.str());
64 }
66  const std::string & name,
67  const std::string & value){
68  std::ostringstream s;
69  s << file << ":" << line <<": Type "<< name <<" has wrong value:"<<
70  value <<". Cannot create a regex\n";
71  list_.push_back(s.str());
72 }
73 
75  const std::string &type){
76  types_[type].push_back(error_cache_element(file,line,type));
77 }
78 
80  types_.erase(type);
81 }
83  int line,
84  const std::string &type){
85  std::ostringstream s;
86  s << file << ":" << line <<": Type "<< type <<" is overriding here \n";
87  list_.push_back(s.str());
88 }
90  const std::string &link){
91  links_[link].push_back(error_cache_element(file,line,link));
92 }
93 
95  links_.erase(link);
96 }
97 
98 
99 void class_error_container::print_errors(std::ostream & s) const{
100  for (std::vector<std::string>::const_iterator i = list_.begin();
101  i!= list_.end(); ++i){
102  s << *(i);
103  }
104  error_cache_map::const_iterator i = types_.begin() ;
105  for ( ; i != types_.end(); ++i){
106  for (std::vector<error_cache_element>::const_iterator ii=
107  i->second.begin(); ii != i->second.end();++ii){
108  s << ii->file << ":" << ii->line <<": Unknown type: "
109  << ii->name <<"\n";
110  }
111  }
112 
113  for (i = links_.begin() ; i != links_.end(); ++i){
114  for (std::vector<error_cache_element>::const_iterator ii =
115  i->second.begin(); ii != i->second.end();++ii){
116  s << ii->file << ":" << ii->line <<": Failed link: "
117  << ii->name <<"\n";
118  }
119  }
120 }
121 
122 }
void remove_link_errors(const std::string &link)
Clears link cache.
void add_orphan_error(const std::string &file, int line, const std::string &name)
Generate and put GCC-style error message about tag without parent.
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1221
This file contains object "error_container", which are used to store error messages while annotation ...
void add_second_parent_error(const std::string &file, int line, const std::string &first, const std::string &second)
Generate and put GCC-style error message about opening parent block before before closing previous bl...
GLsizei const GLfloat * value
Definition: glew.h:1817
void add_link_error(const std::string &file, int line, const std::string &link)
Generate and put GCC-style error message about failed link to link cache.
void add_opened_entity_error(const std::string &file, int line, const std::string &name)
Generate and put GCC-style error message about annotation block somebody missed to close...
void add_type_error(const std::string &file, int line, const std::string &type)
Generate and put GCC-style error message about unknown type to type cache.
void overriding_type_error(const std::string &file, int line, const std::string &type)
Generate and put GCC-style error message about overriding type Overriding means that that type was de...
void add_simple_error(const std::string &message)
Puts simple error message in container.
void remove_type_errors(const std::string &type)
Clears type cache.
size_t i
Definition: function.cpp:1057
void print_errors(std::ostream &s) const
Prints errors to output stream.
GLuint const GLchar * name
Definition: glew.h:1782
std::vector< std::string > list_
Container to store error messages.
GLint * first
Definition: glew.h:1496
GLsizei GLenum GLuint GLuint GLsizei char * message
Definition: glew.h:2499
void wrong_type_error(const std::string &file, int line, const std::string &name, const std::string &value)
Generate and put GCC-style error message about wrong type value.
GLdouble s
Definition: glew.h:1358
void add_unopened_entity_error(const std::string &file, int line, const std::string &name)
Generate and put GCC-style error message about closing block that wasn't opened.
GLsizei const GLcharARB ** string
Definition: glew.h:4503
void add_read_error(const std::string &file, int line)
Generate and put GCC-style error message about error read file error.