00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #ifndef XIMOL_XML_OPEN_STAG_HPP_
00056 #define XIMOL_XML_OPEN_STAG_HPP_
00057
00058 #include <ximol/qname.hpp>
00059 #include <ximol/parser/utils.hpp>
00060
00061 XIMOL_XML_BEGIN_NAMESPACE
00062
00063
00064
00065
00066 template < typename Qname, typename Attributes >
00067 struct manipulator_open_stag
00068 {
00069 manipulator_open_stag(Qname qname):qname_(new Qname(qname)),att_(NULL){};
00070 manipulator_open_stag(Qname qname, Attributes & att):qname_(new Qname(qname)),att_(&att){};
00071 manipulator_open_stag(const manipulator_open_stag<Qname, Attributes> & x):qname_(new Qname(*x.qname_)),att_(x.att_){};
00072 ~manipulator_open_stag(){ delete qname_; };
00073
00074 Qname * qname_;
00075 Attributes * att_;
00076 private:
00077 manipulator_open_stag<Qname, Attributes> & operator=(const manipulator_open_stag<Qname, Attributes> & x);
00078 };
00079
00080
00081
00082
00083 template < typename Qname, typename Attributes >
00084 xostream& operator<<(xostream& xos, const manipulator_open_stag<Qname,Attributes>& m)
00085 {
00086 XIMOL_PARSER_USING_NAMESPACE;
00087 if (m.att_==NULL) {
00088 if (m.qname_->is_prefix_set())
00089 write_open_stag(xos,m.qname_->get_local(),m.qname_->get_prefix());
00090 else
00091 write_open_stag(xos,m.qname_->get_local());
00092 } else {
00093 if (m.qname_->is_prefix_set())
00094 write_open_stag(xos,m.qname_->get_local(),*(m.att_),m.qname_->get_prefix());
00095 else {
00096 write_open_stag(xos,m.qname_->get_local(),*(m.att_));
00097 };
00098 };
00099 return xos;
00100 };
00101
00102
00103
00104
00105 template < typename Qname, typename Attributes >
00106 xistream& operator>>(xistream& xis, manipulator_open_stag<Qname,Attributes>& m)
00107 {
00108 XIMOL_PARSER_USING_NAMESPACE;
00109 xstring prefix, local;
00110
00111 if (has_skip_whitespace(xis))
00112 read_optionnal_space(xis);
00113
00114 if (m.att_==NULL) {
00115 read_open_stag(xis, local, prefix);
00116 } else {
00117 read_open_stag(xis, local, *(m.att_), prefix);
00118 };
00119 m.qname_->set_local(local);
00120
00121 if (m.qname_->is_prefix_set())
00122 {
00123 try {
00124 m.qname_->set_prefix(prefix);
00125 } catch (std::exception&) {
00126 m.qname_->set_prefix(xis.context.get_short_namespace(prefix));
00127 };
00128 };
00129
00130 return xis;
00131 };
00132
00133
00134 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type2, type3) \
00135 XIMOL_EXPORT manipulator_open_stag< qualified_name<type1, type2>, type3> open_stag(type1 & prefix, type2 & local, type3 & att);
00136 #include <ximol/config/define_functions_prefix_local_attributes.hpp>
00137
00138
00139 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type2) \
00140 XIMOL_EXPORT manipulator_open_stag< qualified_name<type1, type2>, xml::attributes> open_stag(type1 & prefix, type2 & local);
00141 #include <ximol/config/define_functions_prefix_local.hpp>
00142
00143
00144 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type3) \
00145 XIMOL_EXPORT manipulator_open_stag< qualified_name<type1, type1>, type3> open_stag(type1 & local, type3 & att);
00146 #include <ximol/config/define_functions_local_attributes.hpp>
00147
00148
00149 #define XIMOL_HEADER_DEFINE_FUNCTION(type1) \
00150 XIMOL_EXPORT manipulator_open_stag< qualified_name<type1, type1>, xml::attributes> open_stag(type1 & local);
00151 #include <ximol/config/define_functions_local.hpp>
00152
00153 XIMOL_XML_END_NAMESPACE
00154
00155 #endif // #ifndef XIMOL_XML_OPEN_STAG_HPP_