CLAM-Development  1.4.0
XmlScoped.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #ifndef _XmlScoped_hxx_
23 #define _XmlScoped_hxx_
24 
25 #include <iosfwd>
26 #include "XmlWriteContext.hxx"
27 
28 namespace CLAM
29 {
122 {
123  public:
124  XmlFragment(std::ostream & os) :
125  context(os)
126  {
127  }
128  private:
129  XmlWriteContext context;
130 };
131 
141 {
142  public:
150  template <typename T>
151  XmlContent(const T & content) :
152  context(XmlWriteContext::CurrentContext())
153  {
154  context.InsertContent(content);
155  }
156 
157  private:
158 
159  XmlWriteContext & context;
160 
161 };
162 
169 {
170  public:
177  XmlElement(const std::string & name) :
178  context(XmlWriteContext::CurrentContext()),
179  mName(name)
180  {
181  context.OpenElement(mName);
182  }
190  {
191  context.CloseElement(mName);
192  }
193 
194  private:
195  XmlWriteContext & context;
196  const std::string mName;
197 
198 };
199 
200 #ifdef NEVER_DEFINED
201 class XmlHeader
202 { public:
209  XmlHeader(const std::string & name) :
210  context(XmlWriteContext::CurrentContext())
211  {
212  context.InsertHeader(name);
213  }
214  private:
215  XmlWriteContext & context;
216 
217 };
218 #endif//NEVER_DEFINED
219 
229 {
230  public:
242  template <typename T>
243  XmlAttribute(const std::string & name, const T & content) :
244  context(XmlWriteContext::CurrentContext())
245  {
246  context.InsertAttribute(name,content);
247  }
248 
249  private:
250 
251  XmlWriteContext & context;
252 
253 };
254 
255 } // ns CLAM
256 
257 #endif//_XmlScoped_hxx_
258