⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attributesimpl.h

📁 This software aims to create an applet and panel tools to manage a wireless interface card, such as
💻 H
字号:
//
// AttributesImpl.h
//
// $Id: //poco/Main/XML/include/SAX/AttributesImpl.h#5 $
//
// Implementation of the SAX2 Attributes Interface.
//
// Copyright (c) 2004, Guenter Obiltschnig/Applied Informatics.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//
// 3. Redistributions in any form must be accompanied by information on
//    how to obtain complete source code for this software and any
//    accompanying software that uses this software.  The source code
//    must either be included in the distribution or be available for no
//    more than the cost of distribution plus a nominal fee, and must be
//    freely redistributable under reasonable conditions.  For an
//    executable file, complete source code means the source code for all
//    modules it contains.  It does not include source code for modules or
//    files that typically accompany the major components of the operating
//    system on which the executable file runs.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//


#ifndef SAX_AttributesImpl_INCLUDED
#define SAX_AttributesImpl_INCLUDED


#ifndef XML_XML_INCLUDED
#include "XML/XML.h"
#endif
#ifndef SAX_Attributes_INCLUDED
#include "SAX/Attributes.h"
#endif
#ifndef STD_VECTOR_INCLUDED
#include <vector>
#define STD_VECTOR_INCLUDED
#endif


XML_BEGIN


class XML_API AttributesImpl: public Attributes
	/// This class provides a default implementation of the SAX2 Attributes interface, 
	/// with the addition of manipulators so that the list can be modified or reused.
	/// 
	/// There are two typical uses of this class:
	/// 
	///     1. to take a persistent snapshot of an Attributes object in a startElement event; or
	///     2. to construct or modify an Attributes object in a SAX2 driver or filter.
{
public:
	AttributesImpl();
		/// Creates the AttributesImpl.
		
	AttributesImpl(const Attributes& attributes);
		/// Creates the AttributesImpl by copying another one.

	AttributesImpl(const AttributesImpl& attributes);
		/// Creates the AttributesImpl by copying another one.

	~AttributesImpl();
		/// Destroys the AttributesImpl.

	AttributesImpl& operator = (const AttributesImpl& attributes);
		/// Assignment operator.

	int getIndex(const XMLString& name) const;
	int getIndex(const XMLString& namespaceURI, const XMLString& localName) const;
	int getLength() const;
	XMLString getLocalName(int i) const;
	XMLString getQName(int i) const;
	XMLString getType(int i) const;
	XMLString getType(const XMLString& qname) const;
	XMLString getType(const XMLString& namespaceURI, const XMLString& localName) const;
	XMLString getValue(int i) const;
	XMLString getValue(const XMLString& qname) const;
	XMLString getValue(const XMLString& namespaceURI, const XMLString& localName) const;
	XMLString getURI(int i) const;

	bool isSpecified(int i) const;
		/// Returns true unless the attribute value was provided by DTD defaulting.
		/// Extension from Attributes2 interface.

	bool isSpecified(const XMLString& qname) const;
		/// Returns true unless the attribute value was provided by DTD defaulting.
		/// Extension from Attributes2 interface.

	bool isSpecified(const XMLString& namespaceURI, const XMLString& localName) const;
		/// Returns true unless the attribute value was provided by DTD defaulting.
		/// Extension from Attributes2 interface.

	void setValue(int i, const XMLString& value);
		/// Sets the value of an attribute.

	void setValue(const XMLString& qname, const XMLString& value);
		/// Sets the value of an attribute.

	void setValue(const XMLString& namespaceURI, const XMLString& localName, const XMLString& value);
		/// Sets the value of an attribute.

	void setAttributes(const Attributes& attributes);
		/// Copies the attributes from another Attributes object.

	void setAttribute(int i, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value);
		/// Sets an attribute.

	void addAttribute(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value);
		/// Adds an attribute to the end of the list.

	void addAttribute(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value, bool specified);
		/// Adds an attribute to the end of the list.

	void addAttribute(const XMLChar* namespaceURI, const XMLChar* localName, const XMLChar* qname, const XMLChar* type, const XMLChar* value, bool specified);
		/// Adds an attribute to the end of the list.

	void removeAttribute(int i);
		/// Removes an attribute.

	void removeAttribute(const XMLString& qname);
		/// Removes an attribute.

	void removeAttribute(const XMLString& namespaceURI, const XMLString& localName);
		/// Removes an attribute.

	void clear();
		/// Removes all attributes.

	void setLocalName(int i, const XMLString& localName);
		/// Sets the local name of an attribute.

	void setQName(int i, const XMLString& qname);
		/// Sets the qualified name of an attribute.

	void setType(int i, const XMLString& type);
		/// Sets the type of an attribute.

	void setURI(int i, const XMLString& namespaceURI);
		/// Sets the namespace URI of an attribute.

	struct Attribute
	{
		XMLString localName;
		XMLString namespaceURI;
		XMLString qname;
		XMLString value;
		XMLString type;
		bool      specified;
	};
	typedef std::vector<Attribute> AttributeVec;
	typedef AttributeVec::const_iterator iterator;

	iterator begin() const;
		/// Iterator support.
		
	iterator end() const;
		/// Iterator support.

protected:	
	Attribute* find(const XMLString& qname) const;
	Attribute* find(const XMLString& namespaceURI, const XMLString& localName) const;

private:
	AttributeVec _attributes;
};


//
// inlines
//
inline AttributesImpl::iterator AttributesImpl::begin() const
{
	return _attributes.begin();
}


inline AttributesImpl::iterator AttributesImpl::end() const
{
	return _attributes.end();
}


XML_END


#endif // SAX_AttributesImpl_INCLUDED

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -