00001
00002 #ifndef vsl_basic_xml_element_h_
00003 #define vsl_basic_xml_element_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <vcl_vector.h>
00015 #include <vcl_utility.h>
00016 #include <vcl_string.h>
00017 #include <vcl_sstream.h>
00018 #include <vcl_iostream.h>
00019 #include <vcl_iomanip.h>
00020
00021 template<typename T> vcl_string toString(const T& t)
00022 {
00023 vcl_stringstream strm;
00024
00025 strm << vcl_fixed << t;
00026 vcl_string str(strm.str());
00027 return str;
00028 }
00029
00030 class vsl_basic_xml_element
00031 {
00032 public:
00033
00034 vsl_basic_xml_element(vcl_string tag)
00035 : tag_(tag) {}
00036
00037
00038 vsl_basic_xml_element(vcl_string tag, vcl_vector<vcl_pair<vcl_string, vcl_string> > attrs)
00039 : tag_(tag), attrs_(attrs) {}
00040
00041
00042 ~vsl_basic_xml_element() {}
00043
00044
00045 void add_attribute(vcl_string attr_name, double value);
00046 void add_attribute(vcl_string attr_name, int value);
00047 void add_attribute(vcl_string attr_name, unsigned long value);
00048 void add_attribute(vcl_string attr_name, vcl_string value);
00049 #if 0
00050 void add_attribute(vcl_pair<vcl_string, vcl_string> attr);
00051 #endif
00052
00053 void add_attribute_list(vcl_vector<vcl_pair<vcl_string, vcl_string> > attrs);
00054
00055 bool delete_attribute(vcl_string attr_name);
00056
00057 void append_cdata(vcl_string cdata);
00058 void append_cdata(double cdata);
00059 void append_cdata(int cdata);
00060
00061 void x_write(vcl_ostream& ostr);
00062
00063 void x_write_open(vcl_ostream& ostr);
00064
00065
00066 void x_write_close(vcl_ostream& ostr);
00067
00068 protected:
00069 vcl_string tag_;
00070 vcl_vector<vcl_pair<vcl_string, vcl_string> > attrs_;
00071 vcl_string cdata_;
00072 };
00073
00074 #endif // vsl_basic_xml_element_h_