Author: sytyi
Date: Sat Jul 30 22:23:27 2011
New Revision: 50502
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50502&view=rev
Log:
Changed namespace name to schema_validation. Created a config-based constructor
in class_tag and class_key
Modified:
trunk/src/tools/schema/error_container.cpp
trunk/src/tools/schema/error_container.hpp
trunk/src/tools/schema/schema_generator.cpp
trunk/src/tools/schema/sourceparser.cpp
trunk/src/tools/schema/sourceparser.hpp
trunk/src/tools/schema/tag.cpp
trunk/src/tools/schema/tag.hpp
Modified: trunk/src/tools/schema/error_container.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tools/schema/error_container.cpp?rev=50502&r1=50501&r2=50502&view=diff
==============================================================================
--- trunk/src/tools/schema/error_container.cpp (original)
+++ trunk/src/tools/schema/error_container.cpp Sat Jul 30 22:23:27 2011
@@ -20,7 +20,7 @@
#include "tools/schema/error_container.hpp"
-namespace schema_generator{
+namespace schema_validation{
void class_error_container::add_simple_error(const std::string & message){
list_.push_back(message);
Modified: trunk/src/tools/schema/error_container.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tools/schema/error_container.hpp?rev=50502&r1=50501&r2=50502&view=diff
==============================================================================
--- trunk/src/tools/schema/error_container.hpp (original)
+++ trunk/src/tools/schema/error_container.hpp Sat Jul 30 22:23:27 2011
@@ -29,7 +29,7 @@
#include <string>
#include <vector>
-namespace schema_generator{
+namespace schema_validation{
/**
* Container of errors, which are generated while schema generator tool
* is parsing source files.
Modified: trunk/src/tools/schema/schema_generator.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tools/schema/schema_generator.cpp?rev=50502&r1=50501&r2=50502&view=diff
==============================================================================
--- trunk/src/tools/schema/schema_generator.cpp (original)
+++ trunk/src/tools/schema/schema_generator.cpp Sat Jul 30 22:23:27 2011
@@ -33,7 +33,7 @@
std::string version = "0.6.0";
-using namespace schema_generator;
+using namespace schema_validation;
/**
* Parses the command line.
* @retval 0 Everything's OK!
Modified: trunk/src/tools/schema/sourceparser.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tools/schema/sourceparser.cpp?rev=50502&r1=50501&r2=50502&view=diff
==============================================================================
--- trunk/src/tools/schema/sourceparser.cpp (original)
+++ trunk/src/tools/schema/sourceparser.cpp Sat Jul 30 22:23:27 2011
@@ -21,7 +21,7 @@
#include "boost/regex.hpp"
-namespace schema_generator{
+namespace schema_validation{
/** Little parts of regex templates used to parse Wml annoations.
*For details, look http://wiki.wesnoth.org/WML_Annotation_Format , please
*/
Modified: trunk/src/tools/schema/sourceparser.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tools/schema/sourceparser.hpp?rev=50502&r1=50501&r2=50502&view=diff
==============================================================================
--- trunk/src/tools/schema/sourceparser.hpp (original)
+++ trunk/src/tools/schema/sourceparser.hpp Sat Jul 30 22:23:27 2011
@@ -33,7 +33,7 @@
#include <string>
#include <vector>
-namespace schema_generator{
+namespace schema_validation{
/** A few regex templates. Please notice, that adding any regex template,
* schould be called in test_regexes()
*/
Modified: trunk/src/tools/schema/tag.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tools/schema/tag.cpp?rev=50502&r1=50501&r2=50502&view=diff
==============================================================================
--- trunk/src/tools/schema/tag.cpp (original)
+++ trunk/src/tools/schema/tag.cpp Sat Jul 30 22:23:27 2011
@@ -20,7 +20,10 @@
#include "tools/schema/tag.hpp"
-namespace schema_generator{
+#include "config.hpp"
+#include "foreach.hpp"
+namespace schema_validation{
+
/*WIKI
* @begin{parent}{name="wml_schema/tag/"}
* @begin{tag}{name="key"}{min=0}{max=-1}
@@ -34,6 +37,17 @@
* @end{parent}{name="wml_schema/tag/"}
*/
+ class_key::class_key(const config & cfg){
+ name_ = cfg["name"].str();
+ type_ = cfg["type"].str();
+ if (cfg.has_attribute("mandatory")){
+ mandatory_ = cfg["mandatory"].to_bool();
+ }else{
+ if (cfg.has_attribute("default")){
+ default_= cfg["default"].str();
+ }
+ }
+ }
void class_key::print(std::ostream& os,int level) const {
std::string s;
for (int j=0;j<level;j++){
@@ -49,6 +63,26 @@
}
os << s << "[/key]\n";
}
+class_tag::class_tag(const config & cfg){
+ name_ = cfg["name"].str();
+ min_ = cfg["min"].to_int();
+ max_ = cfg["max"].to_int();
+ if (cfg.has_attribute("super")){
+ super_ = cfg["super"].str();
+ }
+ foreach (const config &child, cfg.child_range("tag")) {
+ class_tag child_tag (child);
+ add_tag(child_tag);
+ }
+ foreach (const config &child, cfg.child_range("key")) {
+ class_key child_key (child);
+ add_key(child_key);
+ }
+ foreach (const config &link, cfg.child_range("link")) {
+ std::string link_name = link["name"].str();
+ add_link(link_name);
+ }
+}
void class_tag::print(std::ostream& os){
printl(os,4,4);
@@ -57,7 +91,7 @@
void class_tag::add_link(const std::string &link){
std::string::size_type pos_last = link.rfind('/');
//if (pos_last == std::string::npos) return;
- std::string name_link = link.substr(++pos_last,link.length());
+ std::string name_link = link.substr(pos_last+1,link.length());
links_.insert(std::pair<std::string,std::string>(name_link,link));
}
@@ -85,7 +119,7 @@
std::string next_path;
if (pos != std::string::npos) {
name = fullpath.substr(0,pos);
- next_path = fullpath.substr(++pos,fullpath.length());
+ next_path = fullpath.substr(pos+1,fullpath.length());
}else{
name = fullpath;
}
@@ -137,6 +171,7 @@
* @end{parent}{name="wml_schema/"}
*/
void class_tag::printl(std::ostream &os,int level, int step){
+
std::string s;
for (int j=0;j<level;j++){
s.append(" ");
@@ -173,7 +208,7 @@
std::string next_path;
if (pos != std::string::npos) {
name = fullpath.substr(0,pos);
- next_path = fullpath.substr(++pos,fullpath.length());
+ next_path = fullpath.substr(pos+1,fullpath.length());
}else{
name = fullpath;
}
@@ -212,7 +247,7 @@
}
std::string::size_type pos = path.find('/');
std::string name = path.substr(0,pos);
- std::string next_path = path.substr(++pos,path.length());
+ std::string next_path = path.substr(pos+1,path.length());
link_map::const_iterator it_links= links_.find(name);
if (it_links != links_.end()){
Modified: trunk/src/tools/schema/tag.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tools/schema/tag.hpp?rev=50502&r1=50501&r2=50502&view=diff
==============================================================================
--- trunk/src/tools/schema/tag.hpp (original)
+++ trunk/src/tools/schema/tag.hpp Sat Jul 30 22:23:27 2011
@@ -28,7 +28,9 @@
#include <sstream>
#include <string>
-namespace schema_generator{
+class config;
+
+namespace schema_validation{
/**
* class_key is used to save the information about one key.
* Key has next info: name, type, default value or key is mandatory.
@@ -46,6 +48,7 @@
, mandatory_(def.empty())
{
}
+ class_key(const config&);
const std::string & get_name() const{
return name_ ;
@@ -167,6 +170,7 @@
, links_()
{
}
+ class_tag(const config&);
~class_tag(){ }
/** Prints information about tag to outputstream, recursively
@@ -306,7 +310,7 @@
* @param level current level of indentation
* @param step step to next indent
*/
- void printl(std::ostream &os,int level, int step);
+ void printl(std::ostream &os,int level, int step = 4);
class_tag * find_tag(const std::string & fullpath,
class_tag &
root) ;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits