mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-17 11:28:16 +00:00
Add simple validation of type value.
This commit is contained in:
parent
a587e7feb3
commit
5b69da4026
@ -63,6 +63,14 @@ void class_error_container::add_orphan_error(const std::string & file,int line,
|
||||
s << file << ":" << line <<": Tag "<< name <<" has no parent \n";
|
||||
list_.push_back(s.str());
|
||||
}
|
||||
void class_error_container::wrong_type_error(const std::string & file,int line,
|
||||
const std::string & name,
|
||||
const std::string & value){
|
||||
std::ostringstream s;
|
||||
s << file << ":" << line <<": Type "<< name <<" has wrong value:"<<
|
||||
value <<". Cannot create a regex\n";
|
||||
list_.push_back(s.str());
|
||||
}
|
||||
|
||||
void class_error_container::add_type_error(const std::string &file,int line,
|
||||
const std::string &type){
|
||||
|
@ -95,7 +95,15 @@ public:
|
||||
*/
|
||||
void add_orphan_error(const std::string & file,int line,
|
||||
const std::string & name);
|
||||
|
||||
/**
|
||||
* Generate and put GCC-style error message about wrong type value
|
||||
* @param file Filename
|
||||
* @param line Number with error
|
||||
* @param name Name of type
|
||||
* @param value Name of value
|
||||
*/
|
||||
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 unknown type to type cache
|
||||
* @param file Filename
|
||||
|
@ -545,10 +545,17 @@ bool class_source_parser::check_allow_type(const std::string &s){
|
||||
bool res = boost::regex_match(s,sub,allow_type);
|
||||
if (res){
|
||||
std::string name = sub[1];
|
||||
std::string value = sub[2];
|
||||
try{
|
||||
boost::regex tmp (value);
|
||||
}catch(std::exception ){
|
||||
errors_.wrong_type_error(input_,line_,name,value);
|
||||
return true;
|
||||
}
|
||||
if(types_.find(name)!=types_.end()){
|
||||
errors_.overriding_type_error(input_,line_,name);
|
||||
}
|
||||
types_[name]=sub[2];
|
||||
types_[name]=value;
|
||||
errors_.remove_type_errors(name);
|
||||
}
|
||||
return res;
|
||||
|
Loading…
x
Reference in New Issue
Block a user