CLAM-Development  1.4.0
BasicXMLable.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 BasicXMLable
24 // Abstract class that defines some common implementation issues for
25 // many XMLables that contains as member variables the XML name and
26 // whether is an XML element or not.
27 
28 #ifndef _BasicXMLable_h
29 #define _BasicXMLable_h
30 
31 #include "XMLable.hxx"
32 #include "Assert.hxx"
33 #include <ctype.h>
34 #include <string>
35 
36 namespace CLAM {
37 
46 class BasicXMLable : public XMLable {
47 // Attributes
48 private:
49  const char * myXMLName;
50  bool amIXMLElement;
51 // Construction/Destruction
52 public:
66  BasicXMLable (const char * name=0, bool isXMLElement=false);
67 
68  virtual ~BasicXMLable();
69 // Accessors
70 public:
71  //* @return A pointer to the XMLName
72  const char * XMLName() const
73  {
74  return myXMLName;
75  }
76  //* @return Whether the object represents an XML element or not
77  bool IsXMLElement() const
78  {
79  return myXMLName && amIXMLElement;
80  }
81  //* @return Whether the object represents an XML attribute or not
82  bool IsXMLAttribute() const
83  {
84  return myXMLName && !amIXMLElement;
85  }
86  bool IsXMLText() const
87  {
88  return myXMLName==0;
89  }
90  //* @return A string with the XML content
91  virtual std::string XMLContent() const=0;
92 // Testing
93 public:
94  //* Check the internal status for a class instance is valid
95  bool FulfilsInvariant();
96 };
97 
98 }
99 
100 #endif//_BasicXMLable_h
101