XmlScoped.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 } // ns CLAM
00256 
00257 #endif//_XmlScoped_hxx_
00258 
Generated by  doxygen 1.6.3