/usr/include/gloox/parser.h is in libgloox-dev 1.0.11-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /*
Copyright (c) 2004-2014 by Jakob Schroeter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef PARSER_H__
#define PARSER_H__
#include "gloox.h"
#include "taghandler.h"
#include "tag.h"
#include <string>
namespace gloox
{
/**
* @brief This class implements an XML parser.
*
* @author Jakob Schroeter <js@camaya.net>
* @since 0.9
*/
class GLOOX_API Parser
{
public:
/**
* Constructs a new Parser object.
* @param ph The object to send incoming Tags to.
* @param deleteRoot Indicates whether a parsed Tag should be
* deleted after pushing it upstream. Defaults to @p true.
*/
Parser( TagHandler* ph, bool deleteRoot = true );
/**
* Virtual destructor.
*/
virtual ~Parser();
/**
* Use this function to feed the parser with more XML.
* @param data Raw xml to parse. It may be modified if backbuffering is necessary.
* @return Returns @b -1 if parsing was successful. If a parse error occured, the
* character position where the error was occured is returned.
*/
int feed( std::string& data );
/**
* Resets internal state.
* @param deleteRoot Whether to delete the m_root member. For
* internal use only.
*/
void cleanup( bool deleteRoot = true );
private:
enum ParserInternalState
{
Initial,
InterTag,
TagOpening,
TagOpeningSlash,
TagOpeningLt,
TagInside,
TagNameCollect,
TagNameComplete,
TagNameAlmostComplete,
TagAttribute,
TagAttributeComplete,
TagAttributeEqual,
TagClosing,
TagClosingSlash,
TagValueApos,
TagAttributeValue,
TagPreamble,
TagCDATASection
};
enum ForwardScanState
{
ForwardFound,
ForwardNotFound,
ForwardInsufficientSize
};
enum DecodeState
{
DecodeValid,
DecodeInvalid,
DecodeInsufficient
};
void addTag();
void addAttribute();
void addCData();
bool closeTag();
bool isWhitespace( unsigned char c );
void streamEvent( Tag* tag );
ForwardScanState forwardScan( std::string::size_type& pos, const std::string& data,
const std::string& needle );
DecodeState decode( std::string::size_type& pos, const std::string& data );
TagHandler* m_tagHandler;
Tag* m_current;
Tag* m_root;
StringMap* m_xmlnss;
ParserInternalState m_state;
Tag::AttributeList m_attribs;
std::string m_tag;
std::string m_cdata;
std::string m_attrib;
std::string m_value;
std::string m_xmlns;
std::string m_tagPrefix;
std::string m_attribPrefix;
std::string m_backBuffer;
int m_preamble;
bool m_quote;
bool m_haveTagPrefix;
bool m_haveAttribPrefix;
bool m_attribIsXmlns;
bool m_deleteRoot;
};
}
#endif // PARSER_H__
|