00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00031 #ifndef S3_CONFIG_NODE_H
00032 #define S3_CONFIG_NODE_H
00033
00034 #include <vector>
00035 #include <list>
00036 #include <string>
00037 #include <map>
00038 #include <iostream>
00039 #include <sstream>
00040 #include <s3fc/s3_conversion.h>
00041
00089 class s3_config_node
00090 {
00091 public:
00095 static s3_config_node empty_node;
00099 static s3_config_node at_end;
00100 #if 0
00101 void dump() const;
00102 #endif
00103 protected:
00107 std::string a_name;
00111 std::string a_value;
00115 s3_config_node* a_parent;
00119 std::map<std::string, std::string> a_attributes;
00123 std::vector<s3_config_node> a_children;
00124 public:
00125
00126 typedef std::map<std::string, std::string> map_type;
00127
00136 s3_config_node(const std::string& n_name = "",
00137 const std::string& n_value = "",
00138 const s3_config_node* n_parent = &empty_node,
00139 const std::map<std::string, std::string>& n_attributes = map_type(),
00140 const std::vector<s3_config_node>& n_children = std::vector<s3_config_node>() );
00141
00177 s3_config_node(const s3_config_node& src);
00192 s3_config_node& operator=(const s3_config_node& src);
00198 bool empty() const;
00204 bool is_rootnode() const;
00209 s3_config_node*& parent();
00213 std::string& name();
00217 std::string& value();
00222 std::map<std::string, std::string>& attributes();
00227 std::vector<s3_config_node>& children();
00236 s3_config_node* insert_child(const s3_config_node& child = empty_node,
00237 const s3_config_node& before = at_end);
00243 void remove_child(const s3_config_node& child);
00244 protected:
00251 std::vector<s3_config_node>::iterator find_child(const s3_config_node& child);
00252
00253 public:
00258 const s3_config_node& get_parent() const;
00263 s3_config_node& get_parent();
00268 void set_parent(s3_config_node& n_parent);
00273 const std::string& get_name() const;
00278 void set_name(const std::string& n_name);
00287 const std::string& get_value() const;
00292 void set_value(const std::string& n_value);
00303 template <typename T>
00304 T get_value() const;
00305
00310 template <typename T>
00311 void set_value( const T& n_value );
00312
00318 const std::map<std::string, std::string>& get_attributes() const;
00324 std::map<std::string, std::string>& get_attributes();
00329 unsigned int get_num_children() const;
00335 const s3_config_node& get_child(unsigned int i) const;
00341 s3_config_node& get_child(unsigned int i);
00351 const std::vector<const s3_config_node*>
00352 get_children(const std::string& name_filter = "") const;
00362 std::vector<s3_config_node*>
00363 get_children(const std::string& name_filter = "");
00372 bool node_exists(const std::string& path) const;
00382 const s3_config_node& get_node_at(const std::string& path) const;
00392 s3_config_node& get_node_at(const std::string& path);
00401 template<typename T>
00402 T get_value_at(const std::string& path) const;
00403
00411 template<typename T>
00412 T get_attribute_at( const std::string& attr_name ) const;
00413 protected:
00414
00415
00416 const s3_config_node* gna_helper(const std::string& path) const;
00417
00418 };
00419
00420 #include <s3fc/s3_config_node.tcc>
00421
00422 #endif
00423