CLAM-Development
1.4.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
Storage
XML
XMLAdapter.hxx
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2001-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
23
// Class XMLAdapter
24
//
25
26
#ifndef _XMLAdapter_
27
#define _XMLAdapter_
28
29
#include "
BasicXMLable.hxx
"
30
#include <sstream>
31
#include <string>
32
33
namespace
CLAM {
34
57
template
<
class
T>
class
XMLAdapter
:
public
BasicXMLable
{
58
// Internal Types
59
public
:
60
typedef
BasicXMLable
super
;
61
typedef
T
t_adaptee
;
62
// Attributes
63
private
:
64
t_adaptee
& mAdaptee;
65
// Construction/Destruction
66
public
:
82
XMLAdapter
(
t_adaptee
& anAdaptee,
const
char
* name=
NULL
,
bool
isXMLElement=
false
)
83
:
BasicXMLable
(name, isXMLElement), mAdaptee(anAdaptee)
84
{
85
}
86
XMLAdapter
(
const
t_adaptee
& anAdaptee,
const
char
* name=
NULL
,
bool
isXMLElement=
false
)
87
:
BasicXMLable
(name, isXMLElement), mAdaptee(const_cast<T&>(anAdaptee))
88
{
89
}
90
virtual
~XMLAdapter
()
91
{
92
};
93
94
// Accessors
95
public
:
96
//* @return A string with the extracted XML content
97
std::string
XMLContent
()
const
98
{
99
100
std::stringstream str;
101
str << mAdaptee << std::ends;
102
return
str.str();
103
}
104
105
//* Extracts the content from the stream.
106
bool
XMLContent
(std::istream & str)
107
{
108
str >> mAdaptee;
109
return
str!=
NULL
;
110
}
111
// Testing
112
public
:
113
//* Check the internal status for a class instance is valid
114
bool
FulfilsInvariant
()
115
{
116
return
super::FulfilsInvariant
();
117
}
118
};
119
120
}
121
#endif//_XMLAdapter_
122
Generated by
1.8.1