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

📄 tinyxml.h

📁 otl简单包装实现类,对数据库进行操作的,简单易用.
💻 H
📖 第 1 页 / 共 3 页
字号:
    #ifdef TIXML_USE_STL	TiXmlNode* FirstChild( const std::string& _value ) const	{	return FirstChild (_value.c_str ());	}	///< STL std::string form.	TiXmlNode* LastChild( const std::string& _value ) const		{	return LastChild (_value.c_str ());	}	///< STL std::string form.	#endif	/** An alternate way to walk the children of a node.		One way to iterate over nodes is:		@verbatim			for( child = parent->FirstChild(); child; child = child->NextSibling() )		@endverbatim		IterateChildren does the same thing with the syntax:		@verbatim			child = 0;			while( child = parent->IterateChildren( child ) )		@endverbatim		IterateChildren takes the previous child as input and finds		the next one. If the previous child is null, it returns the		first. IterateChildren will return null when done.	*/	TiXmlNode* IterateChildren( TiXmlNode* previous ) const;	/// This flavor of IterateChildren searches for children with a particular 'value'	TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous ) const;    #ifdef TIXML_USE_STL	TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) const	{	return IterateChildren (_value.c_str (), previous);	}	///< STL std::string form.	#endif	/** Add a new node related to this. Adds a child past the LastChild.		Returns a pointer to the new object or NULL if an error occured.	*/	TiXmlNode* InsertEndChild( const TiXmlNode& addThis );	/** Add a new node related to this. Adds a child past the LastChild.		NOTE: the node to be added is passed by pointer, and will be		henceforth owned (and deleted) by tinyXml. This method is efficient		and avoids an extra copy, but should be used with care as it		uses a different memory model than the other insert functions.		@sa InsertEndChild	*/	TiXmlNode* LinkEndChild( TiXmlNode* addThis );	/** Add a new node related to this. Adds a child before the specified child.		Returns a pointer to the new object or NULL if an error occured.	*/	TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );	/** Add a new node related to this. Adds a child after the specified child.		Returns a pointer to the new object or NULL if an error occured.	*/	TiXmlNode* InsertAfterChild(  TiXmlNode* afterThis, const TiXmlNode& addThis );	/** Replace a child of this node.		Returns a pointer to the new object or NULL if an error occured.	*/	TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );	/// Delete a child of this node.	bool RemoveChild( TiXmlNode* removeThis );	/// Navigate to a sibling node.	TiXmlNode* PreviousSibling() const			{ return prev; }	/// Navigate to a sibling node.	TiXmlNode* PreviousSibling( const char * ) const;    #ifdef TIXML_USE_STL	TiXmlNode* PreviousSibling( const std::string& _value ) const	{	return PreviousSibling (_value.c_str ());	}	///< STL std::string form.	TiXmlNode* NextSibling( const std::string& _value) const		{	return NextSibling (_value.c_str ());	}	///< STL std::string form.	#endif	/// Navigate to a sibling node.	TiXmlNode* NextSibling() const				{ return next; }	/// Navigate to a sibling node with the given 'value'.	TiXmlNode* NextSibling( const char * ) const;	/** Convenience function to get through elements.		Calls NextSibling and ToElement. Will skip all non-Element		nodes. Returns 0 if there is not another element.	*/	TiXmlElement* NextSiblingElement() const;	/** Convenience function to get through elements.		Calls NextSibling and ToElement. Will skip all non-Element		nodes. Returns 0 if there is not another element.	*/	TiXmlElement* NextSiblingElement( const char * ) const;    #ifdef TIXML_USE_STL	TiXmlElement* NextSiblingElement( const std::string& _value) const	{	return NextSiblingElement (_value.c_str ());	}	///< STL std::string form.	#endif	/// Convenience function to get through elements.	TiXmlElement* FirstChildElement()	const;	/// Convenience function to get through elements.	TiXmlElement* FirstChildElement( const char * value ) const;    #ifdef TIXML_USE_STL	TiXmlElement* FirstChildElement( const std::string& _value ) const	{	return FirstChildElement (_value.c_str ());	}	///< STL std::string form.	#endif	/** Query the type (as an enumerated value, above) of this node.		The possible types are: DOCUMENT, ELEMENT, COMMENT,								UNKNOWN, TEXT, and DECLARATION.	*/	virtual int Type() const	{ return type; }	/** Return a pointer to the Document this node lives in.		Returns null if not in a document.	*/	TiXmlDocument* GetDocument() const;	/// Returns true if this node has no children.	bool NoChildren() const						{ return !firstChild; }	TiXmlDocument* ToDocument()	const		{ return ( this && type == DOCUMENT ) ? (TiXmlDocument*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.	TiXmlElement*  ToElement() const		{ return ( this && type == ELEMENT  ) ? (TiXmlElement*)  this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.	TiXmlComment*  ToComment() const		{ return ( this && type == COMMENT  ) ? (TiXmlComment*)  this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.	TiXmlUnknown*  ToUnknown() const		{ return ( this && type == UNKNOWN  ) ? (TiXmlUnknown*)  this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.	TiXmlText*	   ToText()    const		{ return ( this && type == TEXT     ) ? (TiXmlText*)     this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.	TiXmlDeclaration* ToDeclaration() const	{ return ( this && type == DECLARATION ) ? (TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.	/** Create an exact duplicate of this node and return it. The memory must be deleted		by the caller. 	*/	virtual TiXmlNode* Clone() const = 0;protected:	TiXmlNode( NodeType _type );	// Copy to the allocated object. Shared functionality between Clone, Copy constructor,	// and the assignment operator.	void CopyTo( TiXmlNode* target ) const;	#ifdef TIXML_USE_STL	    // The real work of the input operator.	    virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0;	#endif	// Figure out what is at *p, and parse it. Returns null if it is not an xml node.	TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );	// Internal Value function returning a TIXML_STRING	const TIXML_STRING& SValue() const	{ return value ; }	TiXmlNode*		parent;	NodeType		type;	TiXmlNode*		firstChild;	TiXmlNode*		lastChild;	TIXML_STRING	value;	TiXmlNode*		prev;	TiXmlNode*		next;private:	TiXmlNode( const TiXmlNode& );				// not implemented.	void operator=( const TiXmlNode& base );	// not allowed.};/** An attribute is a name-value pair. Elements have an arbitrary	number of attributes, each with a unique name.	@note The attributes are not TiXmlNodes, since they are not		  part of the tinyXML document object model. There are other		  suggested ways to look at this problem.*/class TiXmlAttribute : public TiXmlBase{	friend class TiXmlAttributeSet;public:	/// Construct an empty attribute.	TiXmlAttribute() : TiXmlBase()	{		document = 0;		prev = next = 0;	}	#ifdef TIXML_USE_STL	/// std::string constructor.	TiXmlAttribute( const std::string& _name, const std::string& _value )	{		name = _name;		value = _value;		document = 0;		prev = next = 0;	}	#endif	/// Construct an attribute with a name and value.	TiXmlAttribute( const char * _name, const char * _value )	{		name = _name;		value = _value;		document = 0;		prev = next = 0;	}	const char*		Name()  const		{ return name.c_str (); }		///< Return the name of this attribute.	const char*		Value() const		{ return value.c_str (); }		///< Return the value of this attribute.	const int       IntValue() const;									///< Return the value of this attribute, converted to an integer.	const double	DoubleValue() const;								///< Return the value of this attribute, converted to a double.	/** QueryIntValue examines the value string. It is an alternative to the		IntValue() method with richer error checking.		If the value is an integer, it is stored in 'value' and 		the call returns TIXML_SUCCESS. If it is not		an integer, it returns TIXML_WRONG_TYPE.		A specialized but useful call. Note that for success it returns 0,		which is the opposite of almost all other TinyXml calls.	*/	int QueryIntValue( int* value ) const;	/// QueryDoubleValue examines the value string. See QueryIntValue().	int QueryDoubleValue( double* value ) const;	void SetName( const char* _name )	{ name = _name; }				///< Set the name of this attribute.	void SetValue( const char* _value )	{ value = _value; }				///< Set the value.	void SetIntValue( int value );										///< Set the value from an integer.	void SetDoubleValue( double value );								///< Set the value from a double.    #ifdef TIXML_USE_STL	/// STL std::string form.	void SetName( const std::string& _name )		{			StringToBuffer buf( _name );		SetName ( buf.buffer ? buf.buffer : "error" );		}	/// STL std::string form.		void SetValue( const std::string& _value )		{			StringToBuffer buf( _value );		SetValue( buf.buffer ? buf.buffer : "error" );		}	#endif	/// Get the next sibling attribute in the DOM. Returns null at end.	TiXmlAttribute* Next() const;	/// Get the previous sibling attribute in the DOM. Returns null at beginning.	TiXmlAttribute* Previous() const;	bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }	bool operator<( const TiXmlAttribute& rhs )	 const { return name < rhs.name; }	bool operator>( const TiXmlAttribute& rhs )  const { return name > rhs.name; }	/*	Attribute parsing starts: first letter of the name						 returns: the next char after the value end quote	*/	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );	// Prints this Attribute to a FILE stream.	virtual void Print( FILE* cfile, int depth ) const;	virtual void StreamOut( TIXML_OSTREAM * out ) const;	// [internal use]	// Set the document pointer so the attribute can report errors.	void SetDocument( TiXmlDocument* doc )	{ document = doc; }private:	TiXmlAttribute( const TiXmlAttribute& );				// not implemented.	void operator=( const TiXmlAttribute& base );	// not allowed.	TiXmlDocument*	document;	// A pointer back to a document, for error reporting.	TIXML_STRING name;	TIXML_STRING value;	TiXmlAttribute*	prev;	TiXmlAttribute*	next;};/*	A class used to manage a group of attributes.	It is only used internally, both by the ELEMENT and the DECLARATION.		The set can be changed transparent to the Element and Declaration	classes that use it, but NOT transparent to the Attribute	which has to implement a next() and previous() method. Which makes	it a bit problematic and prevents the use of STL.	This version is implemented with circular lists because:		- I like circular lists		- it demonstrates some independence from the (typical) doubly linked list.*/class TiXmlAttributeSet{public:	TiXmlAttributeSet();	~TiXmlAttributeSet();	void Add( TiXmlAttribute* attribute );	void Remove( TiXmlAttribute* attribute );	TiXmlAttribute* First() const	{ return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }	TiXmlAttribute* Last()  const	{ return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }	TiXmlAttribute*	Find( const char * name ) const;private:	TiXmlAttribute sentinel;};/** The element is a container class. It has a value, the element name,	and can contain other elements, text, comments, and unknowns.	Elements also contain an arbitrary number of attributes.*/class TiXmlElement : public TiXmlNode{public:	/// Construct an element.	TiXmlElement (const char * in_value);	#ifdef TIXML_USE_STL	/// std::string constructor.	TiXmlElement( const std::string& _value );	#endif	TiXmlElement( const TiXmlElement& );	void operator=( const TiXmlElement& base );	virtual ~TiXmlElement();	/** Given an attribute name, Attribute() returns the value		for the attribute of that name, or null if none exists.	*/	const char* Attribute( const char* name ) const;	/** Given an attribute name, Attribute() returns the value		for the attribute of that name, or null if none exists.		If the attribute exists and can be converted to an integer,		the integer value will be put in the return 'i', if 'i'		is non-null.	*/	const char* Attribute( const char* name, int* i ) const;	/** Given an attribute name, Attribute() returns the value		for the attribute of that name, or null if none exists.		If the attribute exists and can be converted to an double,		the double value will be put in the return 'd', if 'd'		is non-null.	*/	const char* Attribute( const char* name, double* d ) const;	/** QueryIntAttribute examines the attribute - it is an alternative to the		Attribute() method with richer error checking.		If the attribute is an integer, it is stored in 'value' and 		the call returns TIXML_SUCCESS. If it is not		an integer, it returns TIXML_WRONG_TYPE. If the attribute		does not exist, then TIXML_NO_ATTRIBUTE is returned.	*/		int QueryIntAttribute( const char* name, int* value ) const;	/// QueryDoubleAttribute examines the attribute - see QueryIntAttribute().	int QueryDoubleAttribute( const char* name, double* value ) const;	/** Sets an attribute of name to a given value. The attribute		will be created if it does not exist, or changed if it does.	*/	void SetAttribute( const char* name, const char * value );    #ifdef TIXML_USE_STL	const char* Attribute( const std::string& name ) const				{ return Attribute( name.c_str() ); }	const char* Attribute( const std::string& name, int* i ) const		{ return Attribute( name.c_str(), i ); }	const char* Attribute( const std::string& name, double* d ) const	{ return Attribute( name.c_str(), d ); }	int QueryIntAttribute( const std::string& name, int* value ) const	{ return QueryIntAttribute( name.c_str(), value ); }	int QueryDoubleAttribute( const std::string& name, double* value ) const { return QueryDoubleAttribute( name.c_str(), value ); }	/// STL std::string form.	void SetAttribute( const std::string& name, const std::string& _value )		{			StringToBuffer n( name );		StringToBuffer v( _value );		if ( n.buffer && v.buffer )			SetAttribute (n.buffer, v.buffer );		}		///< STL std::string form.	void SetAttribute( const std::string& name, int _value )		{			StringToBuffer n( name );		if ( n.buffer )			SetAttribute (n.buffer, _value);		}		#endif	/** Sets an attribute of name to a given value. The attribute		will be created if it does not exist, or changed if it does.	*/	void SetAttribute( const char * name, int value );	/** Sets an attribute of name to a given value. The attribute		will be created if it does not exist, or changed if it does.	*/	void SetDoubleAttribute( const char * name, double value );	/** Deletes an attribute with the given name.	*/	void RemoveAttribute( const char * name );    #ifdef TIXML_USE_STL	void RemoveAttribute( const std::string& name )	{	RemoveAttribute (name.c_str ());	}	///< STL std::string form.	#endif	TiXmlAttribute* FirstAttribute() const	{ return attributeSet.First(); }		///< Access the first attribute in this element.	TiXmlAttribute* LastAttribute()	const 	{ return attributeSet.Last(); }		///< Access the last attribute in this element.	/// Creates a new Element and returns it - the returned element is a copy.	virtual TiXmlNode* Clone() const;	// Print the Element to a FILE stream.	virtual void Print( FILE* cfile, int depth ) const;	/*	Attribtue parsing starts: next char past '<'						 returns: next char past '>'	*/	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );protected:	void CopyTo( TiXmlElement* target ) const;	void ClearThis();	// like clear, but initializes 'this' object as well	// Used to be public [internal use]	#ifdef TIXML_USE_STL	    virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );	#endif	virtual void StreamOut( TIXML_OSTREAM * out ) const;	/*	[internal use]		Reads the "value" of the element -- another element, or text.		This should terminate with the current end tag.	*/	const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );private:	TiXmlAttributeSet attributeSet;};/**	An XML comment.*/class TiXmlComment : public TiXmlNode{public:	/// Constructs an empty comment.	TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}	TiXmlComment( const TiXmlComment& );	void operator=( const TiXmlComment& base );	virtual ~TiXmlComment()	{}

⌨️ 快捷键说明

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