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
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 #ifndef XIMOL_XML_STAG_HPP_
00088 #define XIMOL_XML_STAG_HPP_
00089
00090 #include <ximol/qname.hpp>
00091 #include <ximol/parser/utils.hpp>
00092
00093
00094 XIMOL_XML_BEGIN_NAMESPACE
00095
00096
00097
00098
00099 template < typename Qname, typename Attributes >
00100 struct manipulator_stag
00101 {
00102 manipulator_stag(Qname qname):qname_(new Qname(qname)),att_(NULL){};
00103 manipulator_stag(Qname qname, Attributes & att):qname_(new Qname(qname)),att_(&att){};
00104 manipulator_stag(const manipulator_stag<Qname, Attributes> & x):qname_(new Qname(*x.qname_)),att_(x.att_){};
00105 ~manipulator_stag(){ delete qname_; };
00106
00107 Qname * qname_;
00108 Attributes * att_;
00109 private:
00110 manipulator_stag<Qname, Attributes> & operator=(const manipulator_stag<Qname, Attributes> & x);
00111 };
00112
00113
00114
00115
00116 template < typename Qname, typename Attributes >
00117 xostream& operator<<(xostream& xos, const manipulator_stag<Qname,Attributes>& m)
00118 {
00119 XIMOL_PARSER_USING_NAMESPACE;
00120 if (m.att_==NULL) {
00121 if (m.qname_->is_prefix_set())
00122 write_stag(xos,m.qname_->get_local(),m.qname_->get_prefix());
00123 else
00124 write_stag(xos,m.qname_->get_local());
00125 } else {
00126 if (m.qname_->is_prefix_set())
00127 write_stag(xos,m.qname_->get_local(),*(m.att_),m.qname_->get_prefix());
00128 else {
00129 write_stag(xos,m.qname_->get_local(),*(m.att_));
00130 };
00131 };
00132 return xos;
00133 };
00134
00135
00136
00137
00138 template < typename Qname, typename Attributes >
00139 xistream& operator>>(xistream& xis, manipulator_stag<Qname,Attributes> m)
00140 {
00141 XIMOL_PARSER_USING_NAMESPACE;
00142
00143 if (has_skip_whitespace(xis))
00144 read_optionnal_space(xis);
00145
00146 xstring prefix, local;
00147 bool has_an_open_stag=xis.context.is_open_stag();
00148 if (m.att_==NULL) {
00149 read_stag(xis, local, prefix);
00150 } else {
00151 read_stag(xis, local, *(m.att_), prefix);
00152 };
00153
00154 try {
00155 m.qname_->set_local(local);
00156 } catch ( std::exception & ) {
00157 if (!has_an_open_stag) throw;
00158 };
00159
00160 try {
00161 if (m.qname_->is_prefix_set())
00162 {
00163 try {
00164 m.qname_->set_prefix(prefix);
00165 } catch (std::exception&) {
00166 m.qname_->set_prefix(xis.context.get_short_namespace(prefix));
00167 };
00168 };
00169 } catch (std::exception&) {
00170 if (!has_an_open_stag) throw;
00171 };
00172
00173 return xis;
00174 };
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type2, type3) \
00215 XIMOL_EXPORT manipulator_stag< qualified_name<type1, type2>, type3> stag(type1 & prefix, type2 & local, type3 & att);
00216 #include <ximol/config/define_functions_prefix_local_attributes.hpp>
00217
00218
00219 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type2) \
00220 XIMOL_EXPORT manipulator_stag< qualified_name<type1, type2>, xml::attributes> stag(type1 & prefix, type2 & local);
00221 #include <ximol/config/define_functions_prefix_local.hpp>
00222
00223
00224 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type3) \
00225 XIMOL_EXPORT manipulator_stag< qualified_name<type1, type1>, type3> stag(type1 & local, type3 & att);
00226 #include <ximol/config/define_functions_local_attributes.hpp>
00227
00228
00229 #define XIMOL_HEADER_DEFINE_FUNCTION(type1) \
00230 XIMOL_EXPORT manipulator_stag< qualified_name<type1, type1>, xml::attributes> stag(type1 & local);
00231 #include <ximol/config/define_functions_local.hpp>
00232
00233 XIMOL_XML_END_NAMESPACE
00234
00235 #endif // #ifndef XIMOL_XML_STAG_HPP_