casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XMLtoken.h
Go to the documentation of this file.
1 //# XMLtoken.h: Representation of a single XML token.
2 //# Copyright (C) 2005
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef XMLTOKEN_H_
28 #define XMLTOKEN_H_
29 
30 #include <vector>
31 #include <map>
32 
33 #include <casa/BasicSL/String.h>
34 
35 namespace casa {
36 
37 // <summary>
38 // Representation of a single XML token.
39 // </summary>
40 //
41 // <synopsis>
42 // XMLtoken encapsulates an XML token which includes a name, zero or more
43 // attributes, and optional content which can be a casacore::String or one or more
44 // XMLtokens.
45 // </synopsis>
46 
47 class XMLtoken {
48 public:
49  // Constructor that takes the tag name.
51 
52  ~XMLtoken();
53 
54 
55  // Returns the attributes for this tag.
56  std::map<casacore::String, casacore::String>* getAttributes();
57 
58  // Returns the list of content tags, or an empty list if there are none.
59  std::vector<XMLtoken*>* getTags();
60 
61  // Returns this tag's name.
62  const casacore::String getName();
63 
64  // Sets the casacore::String content of this tag to the given value.
66 
67  // Returns the casacore::String content of this tag, or blank if there is none.
69 
70 
71  // Returns the value for the given attribute, or blank if the attribute
72  // is invalid.
74 
75 private:
76  // Tag name.
78 
79  // casacore::String content (or blank for none).
81 
82  // Token content (empty list for none).
83  std::vector<XMLtoken*> tags;
84 
85  // Tag attributes.
86  std::map<casacore::String, casacore::String> attributes;
87 };
88 
89 }
90 
91 #endif /* XMLTOKEN_H_ */
std::vector< XMLtoken * > * getTags()
Returns the list of content tags, or an empty list if there are none.
std::map< casacore::String, casacore::String > * getAttributes()
Returns the attributes for this tag.
const casacore::String name
Tag name.
Definition: XMLtoken.h:77
casacore::String content
casacore::String content (or blank for none).
Definition: XMLtoken.h:80
const casacore::String getContent()
Returns the casacore::String content of this tag, or blank if there is none.
XMLtoken(casacore::String n)
Constructor that takes the tag name.
Representation of a single XML token.
Definition: XMLtoken.h:47
void setContent(casacore::String c)
Sets the casacore::String content of this tag to the given value.
std::map< casacore::String, casacore::String > attributes
Tag attributes.
Definition: XMLtoken.h:86
std::vector< XMLtoken * > tags
Token content (empty list for none).
Definition: XMLtoken.h:83
casacore::String getAttribute(casacore::String attr)
Returns the value for the given attribute, or blank if the attribute is invalid.
const Double c
Fundamental physical constants (SI units):
String: the storage and methods of handling collections of characters.
Definition: String.h:223
const casacore::String getName()
Returns this tag&#39;s name.