XmlScoped.hxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _XmlScoped_hxx_
00023 #define _XmlScoped_hxx_
00024
00025 #include <iosfwd>
00026 #include "XmlWriteContext.hxx"
00027
00028 namespace CLAM
00029 {
00121 class XmlFragment
00122 {
00123 public:
00124 XmlFragment(std::ostream & os) :
00125 context(os)
00126 {
00127 }
00128 private:
00129 XmlWriteContext context;
00130 };
00131
00140 class XmlContent
00141 {
00142 public:
00150 template <typename T>
00151 XmlContent(const T & content) :
00152 context(XmlWriteContext::CurrentContext())
00153 {
00154 context.InsertContent(content);
00155 }
00156
00157 private:
00158
00159 XmlWriteContext & context;
00160
00161 };
00162
00168 class XmlElement
00169 {
00170 public:
00177 XmlElement(const std::string & name) :
00178 context(XmlWriteContext::CurrentContext()),
00179 mName(name)
00180 {
00181 context.OpenElement(mName);
00182 }
00189 ~XmlElement()
00190 {
00191 context.CloseElement(mName);
00192 }
00193
00194 private:
00195 XmlWriteContext & context;
00196 const std::string mName;
00197
00198 };
00199
00200 #ifdef NEVER_DEFINED
00201 class XmlHeader
00202 { public:
00209 XmlHeader(const std::string & name) :
00210 context(XmlWriteContext::CurrentContext())
00211 {
00212 context.InsertHeader(name);
00213 }
00214 private:
00215 XmlWriteContext & context;
00216
00217 };
00218 #endif//NEVER_DEFINED
00219
00228 class XmlAttribute
00229 {
00230 public:
00242 template <typename T>
00243 XmlAttribute(const std::string & name, const T & content) :
00244 context(XmlWriteContext::CurrentContext())
00245 {
00246 context.InsertAttribute(name,content);
00247 }
00248
00249 private:
00250
00251 XmlWriteContext & context;
00252
00253 };
00254
00255 }
00256
00257 #endif//_XmlScoped_hxx_
00258