2
Copyright (c) 2004-2009 by Jakob Schroeter <js@camaya.net>
3
This file is part of the gloox library. http://camaya.net/gloox
5
This software is distributed under a license. The full license
6
agreement can be found in the file LICENSE in this distribution.
7
This software may not be copied, modified, sold or distributed
8
other than expressed in the named license agreement.
10
This software is distributed without any warranty.
19
#include "taghandler.h"
29
* @brief This class implements an XML parser.
31
* @author Jakob Schroeter <js@camaya.net>
34
class GLOOX_API Parser
38
* Constructs a new Parser object.
39
* @param ph The object to send incoming Tags to.
40
* @param deleteRoot Indicates whether a parsed Tag should be
41
* deleted after pushing it upstream. Defaults to @p true.
43
Parser( TagHandler* ph, bool deleteRoot = true );
51
* Use this function to feed the parser with more XML.
52
* @param data Raw xml to parse. It may be modified if backbuffering is necessary.
53
* @return Returns @b -1 if parsing was successful. If a parse error occured, the
54
* character position where the error was occured is returned.
56
int feed( std::string& data );
59
* Resets internal state.
60
* @param deleteRoot Whether to delete the m_root member. For
63
void cleanup( bool deleteRoot = true );
66
enum ParserInternalState
76
TagNameAlmostComplete,
92
ForwardInsufficientSize
106
bool isWhitespace( unsigned char c );
107
bool isValid( unsigned char c );
108
void streamEvent( Tag* tag );
109
ForwardScanState forwardScan( std::string::size_type& pos, const std::string& data,
110
const std::string& needle );
111
DecodeState decode( std::string::size_type& pos, const std::string& data );
113
TagHandler* m_tagHandler;
118
ParserInternalState m_state;
119
Tag::AttributeList m_attribs;
122
std::string m_attrib;
125
std::string m_tagPrefix;
126
std::string m_attribPrefix;
127
std::string m_backBuffer;
130
bool m_haveTagPrefix;
131
bool m_haveAttribPrefix;
132
bool m_attribIsXmlns;