pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src entrance_data.cxx,1.6,1.7 exit_data.c


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src entrance_data.cxx,1.6,1.7 exit_data.cxx,1.5,1.6 groundpiece_data.cxx,1.8,1.9 hotspot_data.cxx,1.4,1.5 liquid_data.cxx,1.6,1.7 plt_xml.cxx,1.6,1.7 worldobj_data_factory.cxx,1.6,1.7 worldobj_group_data.cxx,1.7,1.8 xml_helper.cxx,1.14,1.15 xml_helper.hxx,1.8,1.9 xml_plf.cxx,1.13,1.14
Date: 10 Sep 2002 21:03:34 -0000

Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv9330

Modified Files:
        entrance_data.cxx exit_data.cxx groundpiece_data.cxx 
        hotspot_data.cxx liquid_data.cxx plt_xml.cxx 
        worldobj_data_factory.cxx worldobj_group_data.cxx 
        xml_helper.cxx xml_helper.hxx xml_plf.cxx 
Log Message:
added and applied to XMLhelper methods


Index: entrance_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/entrance_data.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- entrance_data.cxx   23 Aug 2002 15:49:48 -0000      1.6
+++ entrance_data.cxx   10 Sep 2002 21:03:32 -0000      1.7
@@ -30,7 +30,7 @@
   clean ();
 
   cur = cur->children;  
-  while (cur != NULL)
+  while (cur)
     {
       if (xmlIsBlankNode(cur)) 
        {
@@ -38,27 +38,27 @@
          continue;
        }
 
-      if (strcmp((char*)cur->name, "type") == 0)
+      if (XMLhelper::equal_str(cur->name, "type"))
        {
          char* name = (char*)xmlNodeListGetString(doc, cur->children, 1); 
          type = name;
          xmlFree(name);
        }
-      else if (strcmp((char*)cur->name, "owner-id") == 0)
+      else if (XMLhelper::equal_str(cur->name, "owner-id"))
        {
          owner_id = XMLhelper::parse_int(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "position") == 0)
+      else if (XMLhelper::equal_str(cur->name, "position"))
        {
          pos = XMLhelper::parse_vector(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "release-rate") == 0)
+      else if (XMLhelper::equal_str(cur->name, "release-rate"))
        {
          char* release_rate_str = (char*)xmlNodeListGetString(doc, 
cur->children, 1);
          release_rate = StringConverter::to_int(release_rate_str);
          xmlFree(release_rate_str);
        }
-      else if (strcmp((char*)cur->name, "direction") == 0)
+      else if (XMLhelper::equal_str(cur->name, "direction"))
        {
          char* direction_str = (char*)xmlNodeListGetString(doc, cur->children, 
1);
 

Index: exit_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/exit_data.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- exit_data.cxx       23 Aug 2002 15:49:48 -0000      1.5
+++ exit_data.cxx       10 Sep 2002 21:03:32 -0000      1.6
@@ -27,7 +27,7 @@
 {
   clean ();
 
-  char* pos_handling = (char*)xmlGetProp(cur, 
(xmlChar*)"use-old-pos-handling");
+  char* pos_handling = XMLhelper::get_prop(cur, "use-old-pos-handling");
   if (pos_handling)
     {
       std::cout << "XMLPLF: Use Old Pos Handling: " << pos_handling << 
std::endl;
@@ -40,7 +40,7 @@
     }
 
   cur = cur->children;
-  while (cur != NULL)
+  while (cur)
     {
       if (xmlIsBlankNode(cur)) 
        {
@@ -48,15 +48,15 @@
          continue;
        }
       
-      if (strcmp((char*)cur->name, "position") == 0)
+      if (XMLhelper::equal_str(cur->name, "position"))
        {
          pos = XMLhelper::parse_vector(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "surface") == 0)
+      else if (XMLhelper::equal_str(cur->name, "surface"))
        {
          desc = XMLhelper::parse_surface(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "owner-id") == 0)
+      else if (XMLhelper::equal_str(cur->name, "owner-id"))
        {
          owner_id = XMLhelper::parse_int(doc, cur);
        }

Index: groundpiece_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/groundpiece_data.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- groundpiece_data.cxx        24 Aug 2002 11:37:48 -0000      1.8
+++ groundpiece_data.cxx        10 Sep 2002 21:03:32 -0000      1.9
@@ -31,7 +31,7 @@
 {
   gptype = GroundpieceData::GP_GROUND;
 
-  char* gptype_c_str = (char*)xmlGetProp(cur, (xmlChar*)"type");
+  char* gptype_c_str = XMLhelper::get_prop(cur, "type");
   if (gptype_c_str)
     {
       gptype = GroundpieceData::string_to_type (gptype_c_str);
@@ -42,7 +42,7 @@
 
   cur = cur->children;
 
-  while (cur != NULL)
+  while (cur)
     {
       if (xmlIsBlankNode(cur)) 
        {
@@ -50,11 +50,11 @@
          continue;
        }
       
-      if (strcmp((char*)cur->name, "position") == 0)
+      if (XMLhelper::equal_str(cur->name, "position"))
        {
          pos = XMLhelper::parse_vector(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "surface") == 0)
+      else if (XMLhelper::equal_str(cur->name, "surface"))
        {
          desc = XMLhelper::parse_surface(doc, cur);
        }

Index: hotspot_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/hotspot_data.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- hotspot_data.cxx    23 Aug 2002 15:49:49 -0000      1.4
+++ hotspot_data.cxx    10 Sep 2002 21:03:32 -0000      1.5
@@ -37,7 +37,7 @@
 HotspotData::HotspotData (xmlDocPtr doc, xmlNodePtr cur)
 {
   cur = cur->children;
-  while (cur != NULL)
+  while (cur)
     {
       if (xmlIsBlankNode(cur)) 
        {
@@ -45,19 +45,19 @@
          continue;
        }
       
-      if (strcmp((char*)cur->name, "surface") == 0)
+      if (XMLhelper::equal_str(cur->name, "surface"))
        {
          desc = XMLhelper::parse_surface(doc, cur);
        } 
-      else if (strcmp((char*)cur->name, "position") == 0) 
+      else if (XMLhelper::equal_str(cur->name, "position")) 
        {
          pos = XMLhelper::parse_vector(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "speed") == 0) 
+      else if (XMLhelper::equal_str(cur->name, "speed")) 
        {
          speed = XMLhelper::parse_int(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "parallax") == 0) 
+      else if (XMLhelper::equal_str(cur->name, "parallax"))
        {
          para = XMLhelper::parse_int(doc, cur);
        }

Index: liquid_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/liquid_data.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- liquid_data.cxx     23 Aug 2002 15:49:49 -0000      1.6
+++ liquid_data.cxx     10 Sep 2002 21:03:32 -0000      1.7
@@ -39,7 +39,7 @@
 {
   std::cout << "LiquidData::create(xmlDocPtr doc, xmlNodePtr cur)" << 
std::endl;
   
-  char* width_handling = (char*)xmlGetProp(cur, 
(xmlChar*)"use-old-width-handling");
+  char* width_handling = XMLhelper::get_prop(cur, "use-old-width-handling");
   if (width_handling)
     {
       std::cout << "XMLPLF: Use Old Width Handling: " << width_handling << 
std::endl;
@@ -53,7 +53,7 @@
     }
 
   cur = cur->children;
-  while (cur != NULL)
+  while (cur)
     {
       if (xmlIsBlankNode(cur)) 
        {
@@ -61,13 +61,13 @@
          continue;
        }
 
-      if (strcmp((char*)cur->name, "position") == 0)
+      if (XMLhelper::equal_str(cur->name, "position"))
        pos = XMLhelper::parse_vector(doc, cur);
-      else if (strcmp((char*)cur->name, "surface") == 0)
+      else if (XMLhelper::equal_str(cur->name, "surface"))
        desc = XMLhelper::parse_surface(doc, cur);
-      else if (strcmp((char*)cur->name, "speed") == 0)
+      else if (XMLhelper::equal_str(cur->name, "speed"))
        speed = XMLhelper::parse_int(doc, cur);
-      else if (strcmp((char*)cur->name, "width") == 0)
+      else if (XMLhelper::equal_str(cur->name, "width"))
        width = XMLhelper::parse_int(doc, cur);
       else
        {

Index: plt_xml.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/plt_xml.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- plt_xml.cxx 23 Aug 2002 15:49:50 -0000      1.6
+++ plt_xml.cxx 10 Sep 2002 21:03:32 -0000      1.7
@@ -22,18 +22,17 @@
 #include "xml_helper.hxx"
 #include "plt_xml.hxx"
 
-PLTXML::PLTXML()
+PLTXML::PLTXML ()
 {
 }
 
-PLTXML::~PLTXML()
+PLTXML::~PLTXML ()
 {
 }
 
 
-///
 void
-PLTXML::parse(std::string filename)
+PLTXML::parse (std::string filename)
 {
   doc = xmlParseFile(filename.c_str());
   if (doc)
@@ -48,41 +47,41 @@
 }
 
 void 
-PLTXML::parse_background(xmlNodePtr cur)
+PLTXML::parse_background (xmlNodePtr cur)
 {
   cur = cur->children;
 
-  while (cur != NULL)
+  while (cur)
     {
-      if (strcmp((char*)cur->name, "surface") == 0)
+      if (XMLhelper::equal_str(cur->name, "surface"))
        {
          background.desc = XMLhelper::parse_surface(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "color") == 0)
+      else if (XMLhelper::equal_str(cur->name, "color"))
        {
          background.color = XMLhelper::parse_color(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "para-x") == 0)
+      else if (XMLhelper::equal_str(cur->name, "para-x"))
        {
          background.para_x = XMLhelper::parse_float(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "para-y") == 0)
+      else if (XMLhelper::equal_str(cur->name, "para-y"))
        {
          background.para_y = XMLhelper::parse_float(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "scroll-x") == 0)
+      else if (XMLhelper::equal_str(cur->name, "scroll-x"))
        {
          background.scroll_x = XMLhelper::parse_float(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "scroll-y") == 0)
+      else if (XMLhelper::equal_str(cur->name, "scroll-y"))
        {
          background.scroll_y = XMLhelper::parse_float(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "stretch-x") == 0)
+      else if (XMLhelper::equal_str(cur->name, "stretch-x"))
        {
          background.stretch_x = XMLhelper::parse_float(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "stretch-y") == 0)
+      else if (XMLhelper::equal_str(cur->name, "stretch-y"))
        {
          background.stretch_y = XMLhelper::parse_float(doc, cur);
        }
@@ -98,7 +97,7 @@
 PLTXML::parse_description(xmlNodePtr cur)
 {
   char* desc = (char*)xmlNodeListGetString(doc, cur->children, 1);
-  char* lang = (char*)xmlGetProp(cur, (xmlChar*)"lang");
+  char* lang = XMLhelper::get_prop(cur, "lang");
 
   if (desc) {
     if (lang)              
@@ -112,10 +111,10 @@
 }
 
 void 
-PLTXML::parse_world_name(xmlNodePtr cur)
+PLTXML::parse_world_name (xmlNodePtr cur)
 {
   char* name = (char*)xmlNodeListGetString(doc, cur->children, 1);
-  char* lang = (char*)xmlGetProp(cur, (xmlChar*)"lang");
+  char* lang = XMLhelper::get_prop(cur, "lang");
 
   if (name) 
     {
@@ -130,13 +129,13 @@
 }
 
 void
-PLTXML::parse_level_list(xmlNodePtr cur)
+PLTXML::parse_level_list (xmlNodePtr cur)
 {
   cur = cur->children;
 
-  while (cur != NULL)
+  while (cur)
     {
-      if (strcmp((char*)cur->name, "level") == 0)
+      if (XMLhelper::equal_str(cur->name, "level"))
        {
          char* name = (char*)xmlNodeListGetString(doc, cur->children, 1);
          if (name)
@@ -158,25 +157,25 @@
 {
   xmlNodePtr cur = doc->ROOT;
 
-  if (cur != NULL && strcmp((const char*)cur->name, "pingus-world") == 0)
+  if (cur && XMLhelper::equal_str(cur->name, "pingus-world"))
     {
       cur = cur->children;
 
-      while (cur != NULL)
+      while (cur)
        {
-         if (strcmp((char*)cur->name, "description") == 0)
+         if (XMLhelper::equal_str(cur->name, "description"))
            {
              parse_description(cur);
            }
-         else if (strcmp((char*)cur->name, "background") == 0)
+         else if (XMLhelper::equal_str(cur->name, "background"))
            {
              parse_background(cur);
            }
-         else if (strcmp((char*)cur->name, "world-name") == 0)
+         else if (XMLhelper::equal_str(cur->name, "world-name"))
            {
              parse_world_name(cur);
            }
-         else if (strcmp((char*)cur->name, "level-list") == 0)
+         else if (XMLhelper::equal_str(cur->name, "level-list"))
            {
              parse_level_list(cur);
            }
@@ -190,26 +189,26 @@
 }
 
 std::vector<std::string> 
-PLTXML::get_levels()
+PLTXML::get_levels ()
 {
   return level_list;
 }
 
 std::map<std::string,std::string> 
-PLTXML::get_name()
+PLTXML::get_name ()
 {
   return world_name;
 }
 
 std::map<std::string,std::string> 
-PLTXML::get_description()
+PLTXML::get_description ()
 {
 
   return description;
 }
 
 SurfaceBackgroundData
-PLTXML::get_background()
+PLTXML::get_background ()
 {
   return background;
 }

Index: worldobj_data_factory.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobj_data_factory.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- worldobj_data_factory.cxx   9 Sep 2002 16:13:44 -0000       1.6
+++ worldobj_data_factory.cxx   10 Sep 2002 21:03:32 -0000      1.7
@@ -97,7 +97,7 @@
 WorldObjDataFactory::create (xmlDocPtr doc, xmlNodePtr cur)
 {
   std::cout << "WorldObjDataFactory::create (xmlDocPtr doc, xmlNodePtr cur)" 
<< std::endl;
-  char* type = (char*)xmlGetProp(cur, (xmlChar*)"type");
+  char* type = XMLhelper::get_prop(cur, "type");
   if (type)
     {
       return create (type, doc, cur);

Index: worldobj_group_data.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobj_group_data.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- worldobj_group_data.cxx     6 Sep 2002 17:33:29 -0000       1.7
+++ worldobj_group_data.cxx     10 Sep 2002 21:03:32 -0000      1.8
@@ -42,7 +42,7 @@
 
   std::cout << "WorldObjGroupData::WorldObjGroupData (xmlDocPtr doc, 
xmlNodePtr cur)" << std::endl;
 
-  while (cur != NULL)
+  while (cur)
     {
       if (xmlIsBlankNode(cur)) 
        {
@@ -52,31 +52,31 @@
       
       std::cout << "Obj: " << cur->name << std::endl;
 
-      if (strcmp((char*)cur->name, "exit") == 0)
+      if (XMLhelper::equal_str(cur->name, "exit"))
        {
          add (new ExitData (doc, cur));
        }
-      else if (strcmp((char*)cur->name, "entrance") == 0)
+      else if (XMLhelper::equal_str(cur->name, "entrance"))
        {
          add (new EntranceData (doc, cur));
        }
-      //else if (strcmp((char*)cur->name, "trap") == 0)
+      //else if (XMLhelper::equal_str(cur->name, "trap") == 0)
        //{
          //add (new TrapData (doc, cur));
        //}
-      else if (strcmp((char*)cur->name, "hotspot") == 0)
+      else if (XMLhelper::equal_str(cur->name, "hotspot"))
        {
          add(new HotspotData (doc, cur));
        }
-      else if (strcmp((char*)cur->name, "liquid") == 0)
+      else if (XMLhelper::equal_str(cur->name, "liquid"))
        {
          add(new LiquidData (doc, cur));
        }
-      else if (strcmp((char*)cur->name, "group") == 0)
+      else if (XMLhelper::equal_str(cur->name, "group"))
        {
          add(new WorldObjGroupData (doc, cur));
        }
-      else if (strcmp ((char*)cur->name, "worldobj") == 0)
+      else if (strcmp ((char*)cur->name, "worldobj"))
        {
          add(WorldObjDataFactory::instance ()->create (doc, cur));
        }

Index: xml_helper.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/xml_helper.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- xml_helper.cxx      6 Sep 2002 17:33:29 -0000       1.14
+++ xml_helper.cxx      10 Sep 2002 21:03:32 -0000      1.15
@@ -34,7 +34,7 @@
 using namespace Pingus;
 
 xmlNodePtr
-XMLhelper::skip_blank(xmlNodePtr cur)
+XMLhelper::skip_blank (xmlNodePtr cur)
 {
   if (xmlIsBlankNode(cur))
     return cur->next;
@@ -42,8 +42,20 @@
     return cur;
 }
 
+bool
+XMLhelper::equal_str (const xmlChar* comp, const char* orig)
+{
+  return ! strcmp(reinterpret_cast<const char*>(comp), orig);
+}
+
+char*
+XMLhelper::get_prop (xmlNodePtr cur, const char* name)
+{
+  return reinterpret_cast<char*>(xmlGetProp(cur, reinterpret_cast<const 
xmlChar*>(name)));
+}
+
 std::string
-XMLhelper::encode_entities(const std::string& arg_str)
+XMLhelper::encode_entities (const std::string& arg_str)
 {
   ///xmlEncodeEntitiesReentrant()
   std::string str = arg_str;
@@ -68,7 +80,7 @@
 {
   CL_Vector pos;
   cur = cur->children;  
-  while (cur != NULL)
+  while (cur)
     {
       if (xmlIsBlankNode(cur)) 
        {
@@ -81,11 +93,11 @@
       if (ident)
        {
          //std::cout << "parse_position: ident = " << ident << std::endl;
-         if (strcmp((char*)cur->name, "x-pos") == 0) {
+         if (XMLhelper::equal_str(cur->name, "x-pos")) {
            pos.x = StringConverter::to_float(ident);
-         } else if (strcmp((char*)cur->name, "y-pos") == 0) {
+         } else if (XMLhelper::equal_str(cur->name, "y-pos")) {
            pos.y = StringConverter::to_float(ident);
-         } else if (strcmp((char*)cur->name, "z-pos") == 0) {
+         } else if (XMLhelper::equal_str(cur->name, "z-pos")) {
            pos.z = StringConverter::to_float(ident);
          } else {
            std::cout << "Unhandled position ident: " << ident << std::endl;
@@ -135,7 +147,7 @@
   Color color;
   cur = cur->children;
 
-  while (cur != NULL)
+  while (cur)
     {  
       if (xmlIsBlankNode(cur)) 
        {
@@ -143,19 +155,19 @@
          continue;
        }
 
-      if (strcmp((char*)cur->name, "red") == 0)
+      if (XMLhelper::equal_str(cur->name, "red"))
        {
          color.red = parse_float(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "green") == 0)
+      else if (XMLhelper::equal_str(cur->name, "green"))
        {
          color.green = parse_float(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "blue") == 0)
+      else if (XMLhelper::equal_str(cur->name, "blue"))
        {
          color.blue = parse_float(doc, cur);
        }
-      else if (strcmp((char*)cur->name, "alpha") == 0)
+      else if (XMLhelper::equal_str(cur->name, "alpha"))
        {
          color.alpha = parse_float(doc, cur);
        }
@@ -173,7 +185,7 @@
 {
   ResDescriptor desc;
   cur = cur->children;  
-  while (cur != NULL)
+  while (cur)
     {
       if (xmlIsBlankNode(cur)) 
        {
@@ -181,7 +193,7 @@
          continue;
        }
       
-      char* type = (char*)xmlGetProp(cur, (xmlChar*)"type");
+      char* type = get_prop(cur, "type");
       
       if (type)
        {
@@ -198,7 +210,7 @@
                      continue;
                    }
 
-                 if (strcmp((char*)ccur->name, "resource-file") == 0)
+                 if (XMLhelper::equal_str(ccur->name, "resource-file"))
                    {
                      char* filename = (char*)xmlNodeListGetString(doc, 
ccur->children, 1);
                      if (filename) 
@@ -208,7 +220,7 @@
                          xmlFree(filename);
                        }       
                    }
-                 else if (strcmp((char*) ccur->name, "modifier") == 0)
+                 else if (XMLhelper::equal_str(ccur->name, "modifier"))
                    {
                      char* ident = (char*)xmlNodeListGetString(doc, 
ccur->children, 1);
                      if (ident) 
@@ -239,7 +251,7 @@
                      continue;
                    }
 
-                 if (strcmp((char*)ccur->name, "resource-datafile") == 0)
+                 if (XMLhelper::equal_str(ccur->name, "resource-datafile"))
                    {
                      char* datafile = (char*)xmlNodeListGetString(doc, 
ccur->children, 1);
                      if (datafile) 
@@ -252,7 +264,7 @@
                          std::cout << "XMLhelper: parse_surface() Empty" << 
std::endl;
                        }
                    }
-                 else if (strcmp((char*)ccur->name, "resource-ident") == 0)
+                 else if (XMLhelper::equal_str(ccur->name, "resource-ident"))
                    {
                      char* ident = (char*)xmlNodeListGetString(doc, 
ccur->children, 1);
                      if (ident) 
@@ -261,7 +273,7 @@
                          xmlFree(ident);                 
                        }
                    }
-                 else if (strcmp((char*)ccur->name, "modifier") == 0)
+                 else if (XMLhelper::equal_str(ccur->name, "modifier"))
                    {
                      //std::cout << "Modifier!!!!!" << std::endl;
                      char* ident = (char*)xmlNodeListGetString(doc, 
ccur->children, 1);

Index: xml_helper.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/xml_helper.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- xml_helper.hxx      6 Sep 2002 17:33:29 -0000       1.8
+++ xml_helper.hxx      10 Sep 2002 21:03:32 -0000      1.9
@@ -64,6 +64,10 @@
   static std::string encode_entities (const std::string& arg_str);
 
   static xmlNodePtr skip_blank (xmlNodePtr cur);
+  
+  static bool equal_str (const xmlChar* comp, const char* orig);
+  
+  static char* get_prop (xmlNodePtr cur, const char* name);
 
   /// A set of function to parse an xml file
   //@{

Index: xml_plf.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/xml_plf.cxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- xml_plf.cxx 8 Sep 2002 18:13:04 -0000       1.13
+++ xml_plf.cxx 10 Sep 2002 21:03:32 -0000      1.14
@@ -73,7 +73,7 @@
 
   cur = XMLhelper::skip_blank(cur);
 
-  if (cur && !strcmp(reinterpret_cast<const char*>(cur->name), "pingus-level"))
+  if (cur && XMLhelper::equal_str(cur->name, "pingus-level"))
     {
       //std::cout << "parse_file...." << std::endl;
 
@@ -94,55 +94,55 @@
            }
 
          //puts("global loop");
-         if (!strcmp(reinterpret_cast<const char*>(cur->name), "global"))
+         if (XMLhelper::equal_str(cur->name, "global"))
            {
              parse_global(cur);
            }
-         else if (!strcmp(reinterpret_cast<const char*>(cur->name), 
"action-list"))
+         else if (XMLhelper::equal_str(cur->name, "action-list"))
            {
              parse_actions(cur);
            }
-         else if (!strcmp(reinterpret_cast<const char*>(cur->name), 
"background"))
+         else if (XMLhelper::equal_str(cur->name, "background"))
            {
              parse_background(cur);
            }
-         else if (!strcmp(reinterpret_cast<const char*>(cur->name), 
"groundpiece"))
+         else if (XMLhelper::equal_str(cur->name, "groundpiece"))
            {
              parse_groundpiece(cur);
            }
-         else if (!strcmp(reinterpret_cast<const char*>(cur->name), "exit"))
+         else if (XMLhelper::equal_str(cur->name, "exit"))
            {
              worldobjs_data.push_back (new ExitData (doc, cur));
            }
-         else if (!strcmp(reinterpret_cast<const char*>(cur->name), 
"entrance"))
+         else if (XMLhelper::equal_str(cur->name, "entrance"))
            {
              worldobjs_data.push_back (new EntranceData (doc, cur));
            }
-         else if (!strcmp(reinterpret_cast<const char*>(cur->name), "trap"))
+         else if (XMLhelper::equal_str(cur->name, "trap"))
            {
              parse_traps(cur);
            }
-         else if (!strcmp(reinterpret_cast<const char*>(cur->name), "hotspot"))
+         else if (XMLhelper::equal_str(cur->name, "hotspot"))
            {
              worldobjs_data.push_back(new HotspotData (doc, cur));
            }
-         else if (!strcmp(reinterpret_cast<const char*>(cur->name), "liquid"))
+         else if (XMLhelper::equal_str(cur->name, "liquid"))
            {
              worldobjs_data.push_back(new LiquidData (doc, cur));
            }
-         else if (!strcmp (reinterpret_cast<const char*>(cur->name), 
"worldobj"))
+         else if (XMLhelper::equal_str(cur->name, "worldobj"))
            {
              worldobjs_data.push_back(WorldObjDataFactory::instance()->create 
(doc, cur));
            }
-         else if (!strcmp(reinterpret_cast<const char*>(cur->name), "group"))
+         else if (XMLhelper::equal_str(cur->name, "group"))
            {
              parse_group(cur);
            }
-         else if (!strcmp (reinterpret_cast<const char*>(cur->name), 
"start-position"))
+         else if (XMLhelper::equal_str(cur->name, "start-position"))
            {
              parse_start_pos(cur);
            }
-         else if (!strcmp (reinterpret_cast<const char*>(cur->name), 
"weather"))
+         else if (XMLhelper::equal_str(cur->name, "weather"))
            {
              parse_weather(cur);
            }     
@@ -171,7 +171,7 @@
          continue;
        }
       
-      if (!strcmp(reinterpret_cast<const char*>(cur->name), "position"))
+      if (XMLhelper::equal_str(cur->name, "position"))
        {
          CL_Vector pos = XMLhelper::parse_vector(doc, cur);
          start_x_pos = static_cast<int>(pos.x);
@@ -199,7 +199,7 @@
          continue;
        }
       
-      if (!strcmp(reinterpret_cast<const char*>(cur->name), "type"))
+      if (XMLhelper::equal_str(cur->name, "type"))
        {
          weather.type = XMLhelper::parse_string(doc, cur);
        }
@@ -228,35 +228,35 @@
          continue;
        }
       
-      if (!strcmp(reinterpret_cast<const char*>(cur->name), "groundpiece"))
+      if (XMLhelper::equal_str(cur->name, "groundpiece"))
        {
          parse_groundpiece(cur);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "exit"))
+      else if (XMLhelper::equal_str(cur->name, "exit"))
        {
          group->add (new ExitData (doc, cur));
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "entrance"))
+      else if (XMLhelper::equal_str(cur->name, "entrance"))
        {
          group->add (new EntranceData (doc, cur));
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "trap"))
+      else if (XMLhelper::equal_str(cur->name, "trap"))
        {
          parse_traps (cur);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "hotspot"))
+      else if (XMLhelper::equal_str(cur->name, "hotspot"))
        {
          group->add(new HotspotData (doc, cur));
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "liquid"))
+      else if (XMLhelper::equal_str(cur->name, "liquid"))
        {
          group->add(new LiquidData (doc, cur));
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "group"))
+      else if (XMLhelper::equal_str(cur->name, "group"))
        {
          parse_group(cur);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "worldobj"))
+      else if (XMLhelper::equal_str(cur->name, "worldobj"))
        {
          group->add(WorldObjDataFactory::instance ()->create(doc, cur));
        }
@@ -275,7 +275,7 @@
 {
   // The allocated objects are delete'd in the destructor
   //FIXME: Repair me backgrounds.push_back(BackgroundData::create (doc, cur));
-  char* type_cstr = reinterpret_cast<char*>(xmlGetProp(cur, 
reinterpret_cast<const xmlChar*>("type")));
+  char* type_cstr = XMLhelper::get_prop(cur, "type");
 
   if (type_cstr)
     {
@@ -309,7 +309,7 @@
       ActionData button;
       button.name = action_from_string(reinterpret_cast<const 
char*>(cur->name));
 
-      char* count = reinterpret_cast<char*>(xmlGetProp(cur, 
reinterpret_cast<const xmlChar*>("count")));
+      char* count = XMLhelper::get_prop(cur, "count");
       if (count)
        {
          from_string(count, button.number_of);
@@ -346,10 +346,10 @@
          continue;
        }
 
-      if (!strcmp(reinterpret_cast<const char*>(cur->name), "levelname"))
+      if (XMLhelper::equal_str(cur->name, "levelname"))
        {
          char* name = reinterpret_cast<char*>(xmlNodeListGetString(doc, 
cur->children, 1));
-         char* lang = reinterpret_cast<char*>(xmlGetProp(cur, 
reinterpret_cast<const xmlChar*>("lang")));
+         char* lang = XMLhelper::get_prop(cur, "lang");
 
          if (name) {
            if (lang)
@@ -363,10 +363,10 @@
          if (lang)
            xmlFree(lang);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), 
"description"))
+      else if (XMLhelper::equal_str(cur->name, "description"))
        {
          char* desc = reinterpret_cast<char*>(xmlNodeListGetString(doc, 
cur->children, 1));
-         char* lang = reinterpret_cast<char*>(xmlGetProp(cur, 
reinterpret_cast<const xmlChar*>("lang")));
+         char* lang = XMLhelper::get_prop(cur, "lang");
 
          if (desc) {
            if (lang)               
@@ -380,7 +380,7 @@
          if (lang)
            xmlFree(lang);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "author"))
+      else if (XMLhelper::equal_str(cur->name, "author"))
        {
          char* tmp_author = reinterpret_cast<char*>(xmlNodeListGetString(doc, 
cur->children, 1));
          if (tmp_author) {
@@ -389,35 +389,35 @@
          }
          //std::cout << "Author: " << author << " -----------------------" << 
std::endl;
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), 
"number-of-pingus"))
+      else if (XMLhelper::equal_str(cur->name, "number-of-pingus"))
        {
          number_of_pingus = XMLhelper::parse_int(doc, cur);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "difficulty"))
+      else if (XMLhelper::equal_str(cur->name, "difficulty"))
        {
          difficulty = XMLhelper::parse_int(doc, cur);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "playable"))
+      else if (XMLhelper::equal_str(cur->name, "playable"))
        {
          playable = XMLhelper::parse_int(doc, cur);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "comment"))
+      else if (XMLhelper::equal_str(cur->name, "comment"))
        {
          comment = XMLhelper::parse_string(doc, cur);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), 
"number-to-save"))
+      else if (XMLhelper::equal_str(cur->name, "number-to-save"))
        {
          number_to_save = XMLhelper::parse_int(doc, cur);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "time"))
+      else if (XMLhelper::equal_str(cur->name, "time"))
        {
          max_time = XMLhelper::parse_int(doc, cur);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "height"))
+      else if (XMLhelper::equal_str(cur->name, "height"))
        {
          height = XMLhelper::parse_int(doc, cur);
        }
-      else if (!strcmp(reinterpret_cast<const char*>(cur->name), "width"))
+      else if (XMLhelper::equal_str(cur->name, "width"))
        {
          width = XMLhelper::parse_int(doc, cur);
        }
@@ -441,7 +441,7 @@
 {
   xmlNodePtr cur_ = XMLhelper::skip_blank(cur->children);
   
-  if (!strcmp(reinterpret_cast<const char*>(cur_->name), "type"))
+  if (XMLhelper::equal_str(cur_->name, "type"))
     {
       char* name = reinterpret_cast<char*>(xmlNodeListGetString(doc, 
cur_->children, 1));
       if (name)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]