parser.h

00001 /*
00002   Copyright (c) 2004-2007 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
00011 */
00012 
00013 
00014 
00015 #ifndef PARSER_H__
00016 #define PARSER_H__
00017 
00018 #include "gloox.h"
00019 #include "taghandler.h"
00020 #include "tag.h"
00021 
00022 #include <string>
00023 
00024 namespace gloox
00025 {
00026 
00027 
00034   class GLOOX_API Parser
00035   {
00036     public:
00041       Parser( TagHandler *ph );
00042 
00046       virtual ~Parser();
00047 
00053       bool feed( const std::string& data );
00054 
00055     private:
00056       void addTag();
00057       void addAttribute();
00058       void addCData();
00059       bool closeTag();
00060       void cleanup();
00061       bool isWhitespace( unsigned char c );
00062       bool isValid( unsigned char c );
00063       void streamEvent( Tag *tag );
00064 
00065       enum ParserInternalState
00066       {
00067         Initial,
00068         TagOpening,
00069         TagOpeningSlash,
00070         TagOpeningLt,
00071         TagInside,
00072         TagNameCollect,
00073         TagNameComplete,
00074         TagAttribute,
00075         TagAttributeComplete,
00076         TagAttributeEqual,
00077         TagClosing,
00078         TagClosingSlash,
00079         TagValueApos,
00080         TagValue,
00081         TagPreamble
00082       };
00083 
00084       TagHandler *m_tagHandler;
00085       Tag *m_current;
00086       Tag *m_root;
00087 
00088       ParserInternalState m_state;
00089       Tag::AttributeList m_attribs;
00090       std::string m_tag;
00091       std::string m_cdata;
00092       std::string m_attrib;
00093       std::string m_value;
00094       int m_preamble;
00095       bool m_quote;
00096 
00097   };
00098 
00099 }
00100 
00101 #endif // PARSER_H__

Generated on Sat Nov 10 08:50:27 2007 for gloox by  doxygen 1.5.3-20071008