23 : m_tagHandler( ph ), m_current( 0 ), m_root( 0 ), m_state( Initial ),
24 m_preamble( 0 ), m_quote( false )
35 std::string::const_iterator it = data.begin();
36 for( ; it != data.end(); ++it )
38 const unsigned char c = (*it);
51 if( isWhitespace( c ) )
67 if( isWhitespace( c ) )
79 m_state = TagClosingSlash;
82 m_state = TagNameCollect;
87 m_state = TagNameCollect;
92 if( isWhitespace( c ) )
94 m_state = TagNameComplete;
107 m_state = TagOpeningSlash;
124 m_state = TagOpening;
131 case TagOpeningSlash:
132 if( isWhitespace( c ) )
152 case TagClosingSlash:
153 if( isWhitespace( c ) )
166 m_state = TagClosing;
192 case TagNameComplete:
193 if( isWhitespace( c ) )
203 m_state = TagOpeningSlash;
206 if( m_preamble == 1 )
215 if( m_preamble == 1 )
225 m_state = TagAttribute;
230 if( isWhitespace( c ) )
232 m_state = TagAttributeComplete;
245 m_state = TagAttributeEqual;
251 case TagAttributeComplete:
252 if( isWhitespace( c ) )
258 m_state = TagAttributeEqual;
269 case TagAttributeEqual:
270 if( isWhitespace( c ) )
304 m_state = TagNameComplete;
322 void Parser::addTag()
327 m_root =
new Tag( m_tag,
"",
true );
333 m_current =
new Tag( m_current, m_tag,
"",
true );
336 if( m_attribs.size() )
343 if( m_tag ==
"stream:stream" )
345 streamEvent( m_root );
351 if( m_tag ==
"xml" && m_preamble == 2 )
355 void Parser::addAttribute()
364 void Parser::addCData()
374 bool Parser::closeTag()
378 if( m_tag ==
"stream:stream" )
381 if( !m_current || m_current->
name() != m_tag )
388 m_current = m_current->
parent();
392 streamEvent( m_root );
399 void Parser::cleanup()
413 bool Parser::isValid(
unsigned char c )
415 return ( c != 0xc0 || c != 0xc1 || c < 0xf5 );
418 bool Parser::isWhitespace(
unsigned char c )
420 return ( c == 0x09 || c == 0x0a || c == 0x0d || c == 0x20 );
423 void Parser::streamEvent( Tag *tag )