Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

/home/tommi/cxxtools/include/cxxtools/xml/startelement.h

00001 /*
00002  * This library is free software; you can redistribute it and/or
00003  * modify it under the terms of the GNU Lesser General Public
00004  * License as published by the Free Software Foundation; either
00005  * version 2.1 of the License, or (at your option) any later version.
00006  * 
00007  * As a special exception, you may use this file as part of a free
00008  * software library without restriction. Specifically, if other files
00009  * instantiate templates or use macros or inline functions from this
00010  * file, or you compile this file and link it with other files to
00011  * produce an executable, this file does not by itself cause the
00012  * resulting executable to be covered by the GNU General Public
00013  * License. This exception does not however invalidate any other
00014  * reasons why the executable file might be covered by the GNU Library
00015  * General Public License.
00016  * 
00017  * This library is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  * Lesser General Public License for more details.
00021  * 
00022  * You should have received a copy of the GNU Lesser General Public
00023  * License along with this library; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00025  */
00026 #ifndef cxxtools_xml_StartElement_h
00027 #define cxxtools_xml_StartElement_h
00028 
00029 #include <cxxtools/xml/api.h>
00030 #include <cxxtools/xml/node.h>
00031 #include <cxxtools/xml/namespace.h>
00032 #include <cxxtools/xml/namespacecontext.h>
00033 #include <cxxtools/string.h>
00034 #include <list>
00035 
00036 namespace cxxtools {
00037 
00038 namespace xml {
00039 
00051     class CXXTOOLS_XML_API Attribute
00052     {
00053         public:
00055             Attribute();
00056 
00063             Attribute(const String& name, const String& value);
00064 
00066             virtual ~Attribute();
00067 
00072             const String& name() const
00073             {return _name;}
00074 
00075             String& name()
00076             {return _name;}
00077 
00082             void setName(const String name)
00083             {_name = name;}
00084 
00089             const String& value() const
00090             {return _value;}
00091 
00092             String& value()
00093             {return _value;}
00094 
00099             void setValue(const String value)
00100             {_value = value;}
00101 
00102             void clear()
00103             { _name.clear(); _value.clear(); }
00104 
00105         private:
00107             String _name;
00108 
00110             String _value;
00111     };
00112 
00113 
00132     class CXXTOOLS_XML_API StartElement : public Node
00133     {
00134         public:
00136             StartElement();
00137 
00144             StartElement(const String& name);
00145 
00147             ~StartElement();
00148 
00153             StartElement* clone() const
00154             {return new StartElement(*this);}
00155 
00156 
00157             void clear()
00158             {
00159                 _name.clear();
00160                 _attributes.clear();
00161             }
00162 
00172             String& name() {return _name;}
00173 
00183             const String& name() const
00184             {return _name;}
00185 
00190             void setName(const String name)
00191             {_name = name;}
00192 
00201             void addAttribute(const Attribute& attribute)
00202             {_attributes.push_back(attribute);}
00203 
00214             const std::list<Attribute>& attributes() const
00215             {return _attributes;}
00216 
00230             const String& attribute(const String attributeName) const;
00231 
00241             bool hasAttribute(const String attributeName) const;
00242 
00249             const NamespaceContext& namespaceContext() const
00250             {return _namespaceContext;}
00251 
00258             void setNamespaceContext(const NamespaceContext& conText)
00259             {_namespaceContext = conText;}
00260 
00271             const String& namespaceUri(const String& prefix) const
00272             {return _namespaceContext.namespaceUri(prefix);}
00273 
00283             virtual bool operator==(const Node& node) const;
00284 
00285         private:
00287             String _name;
00288 
00290             std::list<Attribute> _attributes;
00291 
00293             NamespaceContext _namespaceContext;
00294     };
00295 
00296 }
00297 
00298 }
00299 
00300 #endif
Copyright © 2008 The Tntnet Development Team
Tntnet 1.6