casa
$Rev:20696$
|
00001 //# XMLtoken.h: Representation of a single XML token. 00002 //# Copyright (C) 2005 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: $ 00027 #ifndef XMLTOKEN_H_ 00028 #define XMLTOKEN_H_ 00029 00030 #include <vector> 00031 #include <map> 00032 00033 #include <casa/BasicSL/String.h> 00034 00035 #include <casa/namespace.h> 00036 using namespace std; 00037 00038 namespace casa { 00039 00040 // <summary> 00041 // Representation of a single XML token. 00042 // </summary> 00043 // 00044 // <synopsis> 00045 // XMLtoken encapsulates an XML token which includes a name, zero or more 00046 // attributes, and optional content which can be a String or one or more 00047 // XMLtokens. 00048 // </synopsis> 00049 00050 class XMLtoken { 00051 public: 00052 // Constructor that takes the tag name. 00053 XMLtoken(String n); 00054 00055 ~XMLtoken(); 00056 00057 00058 // Returns the attributes for this tag. 00059 map<String, String>* getAttributes(); 00060 00061 // Returns the list of content tags, or an empty list if there are none. 00062 vector<XMLtoken*>* getTags(); 00063 00064 // Returns this tag's name. 00065 const String getName(); 00066 00067 // Sets the String content of this tag to the given value. 00068 void setContent(String c); 00069 00070 // Returns the String content of this tag, or blank if there is none. 00071 const String getContent(); 00072 00073 00074 // Returns the value for the given attribute, or blank if the attribute 00075 // is invalid. 00076 String getAttribute(String attr); 00077 00078 private: 00079 // Tag name. 00080 const String name; 00081 00082 // String content (or blank for none). 00083 String content; 00084 00085 // Token content (empty list for none). 00086 vector<XMLtoken*> tags; 00087 00088 // Tag attributes. 00089 map<String, String> attributes; 00090 }; 00091 00092 } 00093 00094 #endif /* XMLTOKEN_H_ */