Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "tools/schema/error_container.hpp"
00022
00023 namespace schema_validation{
00024
00025 void class_error_container::add_simple_error(const std::string & message){
00026 list_.push_back(message);
00027 }
00028
00029 void class_error_container::add_read_error(const std::string & file,int line){
00030 std::ostringstream s;
00031 s << file << ":" << line <<": Read error at line "<< line <<".\n";
00032 list_.push_back(s.str());
00033 }
00034
00035 void class_error_container::add_opened_entity_error(
00036 const std::string & file,int line,const std::string & name){
00037 std::ostringstream s;
00038 s << file << ":" << line <<": Entity "<< name
00039 <<" is opened but not closed.\n";
00040 list_.push_back(s.str());
00041 }
00042
00043 void class_error_container::add_unopened_entity_error(
00044 const std::string & file,int line,const std::string & name){
00045 std::ostringstream s;
00046 s << file << ":" << line <<": Entity "<< name
00047 <<" is being closed but was not opened.\n";
00048 list_.push_back(s.str());
00049 }
00050
00051 void class_error_container::add_second_parent_error(
00052 const std::string & file,int line,const std::string & first,
00053 const std::string & second){
00054 std::ostringstream s;
00055 s << file << ":" << line <<": Parent "<< first <<" is closed due to parent"
00056 << second << "is opened here. \n";
00057 list_.push_back(s.str());
00058 }
00059
00060 void class_error_container::add_orphan_error(const std::string & file,int line,
00061 const std::string & name){
00062 std::ostringstream s;
00063 s << file << ":" << line <<": Tag "<< name <<" has no parent \n";
00064 list_.push_back(s.str());
00065 }
00066 void class_error_container::wrong_type_error(const std::string & file,int line,
00067 const std::string & name,
00068 const std::string & value){
00069 std::ostringstream s;
00070 s << file << ":" << line <<": Type "<< name <<" has wrong value:"<<
00071 value <<". Cannot create a regex\n";
00072 list_.push_back(s.str());
00073 }
00074
00075 void class_error_container::add_type_error(const std::string &file,int line,
00076 const std::string &type){
00077 types_[type].push_back(error_cache_element(file,line,type));
00078 }
00079
00080 void class_error_container::remove_type_errors(const std::string &type){
00081 types_.erase(type);
00082 }
00083 void class_error_container::overriding_type_error(const std::string &file,
00084 int line,
00085 const std::string &type){
00086 std::ostringstream s;
00087 s << file << ":" << line <<": Type "<< type <<" is overriding here \n";
00088 list_.push_back(s.str());
00089 }
00090 void class_error_container::add_link_error(const std::string &file,int line,
00091 const std::string &link){
00092 links_[link].push_back(error_cache_element(file,line,link));
00093 }
00094
00095 void class_error_container::remove_link_errors(const std::string &link){
00096 links_.erase(link);
00097 }
00098
00099
00100 void class_error_container::print_errors(std::ostream & s) const{
00101 for (std::vector<std::string>::const_iterator i = list_.begin();
00102 i!= list_.end(); ++i){
00103 s << *(i);
00104 }
00105 error_cache_map::const_iterator i = types_.begin() ;
00106 for ( ; i != types_.end(); ++i){
00107 for (std::vector<error_cache_element>::const_iterator ii=
00108 i->second.begin(); ii != i->second.end();++ii){
00109 s << ii->file << ":" << ii->line <<": Unknown type: "
00110 << ii->name <<"\n";
00111 }
00112 }
00113
00114 for (i = links_.begin() ; i != links_.end(); ++i){
00115 for (std::vector<error_cache_element>::const_iterator ii =
00116 i->second.begin(); ii != i->second.end();++ii){
00117 s << ii->file << ":" << ii->line <<": Failed link: "
00118 << ii->name <<"\n";
00119 }
00120 }
00121 }
00122
00123 }