Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1. /*
  2.  *
  3.  *  Copyright (C) 2010  Mattias Runge
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License along
  16.  *  with this program; if not, write to the Free Software Foundation, Inc.,
  17.  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18.  *
  19.  */
  20.  
  21. #ifndef XML_NODE_H
  22. #define XML_NODE_H
  23.  
  24. #include <string>
  25. #include <vector>
  26. #include <map>
  27.  
  28. #include <boost/shared_ptr.hpp>
  29.  
  30. namespace atom {
  31. namespace xml {
  32.        
  33. class Node
  34. {
  35. public:
  36.     typedef boost::shared_ptr<Node> Pointer;
  37.    
  38.     typedef std::map<std::string, std::string> AttributeList;
  39.     typedef std::vector<Node> NodeList;
  40.    
  41.     Node();
  42.     virtual ~Node();
  43.    
  44.     void LoadFile(std::string filename);
  45.    
  46.     std::string GetTagName();
  47.     AttributeList GetAttributes();
  48.     NodeList GetChildren();
  49.    
  50.     Node FindChild(std::string tag_name);
  51.     Node SelectChild(std::string attribute_name, std::string attribute_value);
  52.     Node SelectChild(std::string attribute_name1, std::string attribute_value1, std::string attribute_name2, std::string attribute_value2);
  53.     std::string GetAttributeValue(std::string attribute_name);
  54.    
  55.    
  56. private:
  57.     std::string tag_name_;
  58.     AttributeList attributes_;
  59.     NodeList children_;
  60.    
  61.     void Parse(std::string data);
  62.     int ParseTag(std::string data, int position);
  63. };
  64.  
  65. }; // namespace xml
  66. }; // namespace atom
  67.  
  68. #endif // XML_NODE_H
  69.