Google
Web alhem.net

RobotXMLFile Class Reference

#include <RobotXMLFile.h>

Inheritance diagram for RobotXMLFile:

Inheritance graph
[legend]
Collaboration diagram for RobotXMLFile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RobotXMLFile (const std::string &filename)
 ~RobotXMLFile ()
std::string GetString (const std::string &path, const std::string &property="value")
void GetMethods (std::map< std::string, int > &)
void GetVariables (std::vector< VARIABLE * > &)

Private Member Functions

xmlNodePtr Find (xmlNodePtr base, const std::string &path)

Detailed Description

Definition at line 10 of file RobotXMLFile.h.


Constructor & Destructor Documentation

RobotXMLFile::RobotXMLFile ( const std::string &  filename  ) 

Definition at line 10 of file RobotXMLFile.cpp.

00011 :BaseXMLFile(filename, "", "robot")
00012 {
00013 }

RobotXMLFile::~RobotXMLFile (  ) 

Definition at line 16 of file RobotXMLFile.cpp.

00017 {
00018 }


Member Function Documentation

std::string RobotXMLFile::GetString ( const std::string &  path,
const std::string &  property = "value" 
)

Definition at line 35 of file RobotXMLFile.cpp.

References Find(), BaseXMLFile::GetProperty(), BaseXMLFile::GetRootElement(), and BaseXMLFile::SetCurrent().

Referenced by CodeTool::CodeTool().

00036 {
00037         xmlNodePtr p = Find(GetRootElement(),path);
00038         if (p)
00039         {
00040                 SetCurrent(p);
00041                 std::string str = GetProperty(property);
00042                 return str;
00043         }
00044         fprintf(stderr,"config path not found: %s\n",path.c_str());
00045         return "";
00046 }

void RobotXMLFile::GetMethods ( std::map< std::string, int > &   ) 

Definition at line 49 of file RobotXMLFile.cpp.

References BaseXMLFile::GetChildrenNode(), BaseXMLFile::GetFirstElement(), BaseXMLFile::GetNextNode(), BaseXMLFile::GetProperty(), and BaseXMLFile::SetCurrent().

Referenced by CodeTool::CodeTool().

00050 {
00051         xmlNodePtr p = GetFirstElement("methods");
00052         if (p)
00053         {
00054                 SetCurrent(p);
00055                 p = GetChildrenNode();
00056                 while (p)
00057                 {
00058                         std::string name = GetProperty("name");
00059                         std::string entry = GetProperty("entry");
00060                         if (name.size())
00061                                 mmap[name] = atoi(entry.c_str());
00062                         //
00063                         p = GetNextNode();
00064                 }
00065         }
00066 }

void RobotXMLFile::GetVariables ( std::vector< VARIABLE * > &   ) 

Definition at line 69 of file RobotXMLFile.cpp.

References BaseXMLFile::GetChildrenNode(), BaseXMLFile::GetFirstElement(), BaseXMLFile::GetNextNode(), BaseXMLFile::GetProperty(), and BaseXMLFile::SetCurrent().

Referenced by CodeTool::CodeTool().

00070 {
00071         xmlNodePtr p = GetFirstElement("variables");
00072         if (p)
00073         {
00074                 SetCurrent(p);
00075                 p = GetChildrenNode();
00076                 while (p)
00077                 {
00078                         std::string name = GetProperty("name");
00079                         std::string type = GetProperty("type");
00080                         std::string index = GetProperty("index");
00081                         if (name.size())
00082                         {
00083                                 VARIABLE *p = new VARIABLE(name, atoi(type.c_str()), atoi(index.c_str()));
00084                                 ref.push_back(p);
00085                         }
00086                         //
00087                         p = GetNextNode();
00088                 }
00089         }
00090 }

xmlNodePtr RobotXMLFile::Find ( xmlNodePtr  base,
const std::string &  path 
) [private]

Definition at line 21 of file RobotXMLFile.cpp.

References BaseXMLFile::GetFirstElement().

Referenced by GetString().

00022 {
00023         Parse pa(path,"/");
00024         std::string ord = pa.getword();
00025         std::string str = pa.getrest();
00026         xmlNodePtr p = GetFirstElement(base,ord);
00027         if (p && str.size())
00028         {
00029                 return Find(p,str);
00030         }
00031         return p;
00032 }


The documentation for this class was generated from the following files:
Generated for Robot World by doxygen 1.3.6

Page, code, and content Copyright (C) 2004 by Anders Hedström