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