Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

xmlconfiguration.cc

Go to the documentation of this file.
00001 #include "xmlconfiguration.hh"
00002 
00003 namespace anoid {
00004     namespace config {
00005         using namespace std;
00006 
00007         XMLConfiguration::XMLConfiguration(char *filename) {
00008             parser = new xmlpp::DomParser(filename);
00009 
00010             if (*parser) {
00011                 _xml = parser->get_root_node();
00012             } else {
00013                 cerr << "Could not load `" << filename << "', quitting." << endl;
00014             }
00015         }
00016 
00017         string XMLConfiguration::getString(const char *name) {
00018             xmlpp::Attribute *a;
00019             a = _xml->attribute(name);
00020 
00021             if (a)
00022                 return a->value();
00023             return string();
00024         }
00025 
00026         bool XMLConfiguration::hasElement(const char *name) {
00027             if (_xml->attribute(name))
00028                 return true;
00029             return false;
00030         }
00031 
00032         string XMLConfiguration::getName() {
00033             return _xml->name();
00034         }
00035 
00036         list<Configuration* > XMLConfiguration::getChildren() {
00037             list<Configuration *> children;
00038             xmlpp::Node::NodeList l = _xml->children();
00039             xmlpp::Node::NodeList::iterator i;
00040 
00041             for (i = l.begin(); i != l.end(); ++i)
00042                 children.push_back(new XMLConfiguration((*i)));
00043 
00044             return children;
00045         }
00046 
00047     };
00048 };

Anoid NG © Michael Westergaard, Martin Stig Stissing, Ronni Michael Laursen, and Kristian Bisgaard Lassen