]>
Commit | Line | Data |
---|---|---|
43ae1d95 | 1 | /* |
bbc27441 | 2 | * Copyright (C) 1996-2014 The Squid Software Foundation and contributors |
43ae1d95 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
43ae1d95 | 7 | */ |
bbc27441 | 8 | |
43ae1d95 | 9 | #ifndef SQUID_ESIPARSER_H |
10 | #define SQUID_ESIPARSER_H | |
11 | ||
12 | class ESIParserClient | |
13 | { | |
43ae1d95 | 14 | public: |
15 | virtual void start(const char *el, const char **attr, size_t attrCount) = 0; | |
16 | virtual void end(const char *el) = 0; | |
17 | virtual void parserDefault (const char *s, int len) =0; | |
18 | virtual void parserComment (const char *s) = 0; | |
63be0a78 | 19 | virtual ~ESIParserClient() {}; |
63be0a78 | 20 | }; |
43ae1d95 | 21 | |
8bf217bd | 22 | #include "base/RefCount.h" |
e1f7507e | 23 | |
43ae1d95 | 24 | class ESIParser : public RefCountable |
25 | { | |
43ae1d95 | 26 | public: |
7901db21 | 27 | class Register; |
43ae1d95 | 28 | typedef RefCount<ESIParser> Pointer; |
e1f7507e | 29 | |
c2d4889f | 30 | static void registerParser(const char *name, Pointer (*new_func)(ESIParserClient *aClient)); |
43ae1d95 | 31 | static Pointer NewParser(ESIParserClient *aClient); |
32 | static char *Type; | |
e1f7507e AJ |
33 | |
34 | /** | |
35 | \retval true on success | |
36 | \retval false on what? | |
37 | */ | |
43ae1d95 | 38 | virtual bool parse(char const *dataToParse, size_t const lengthOfData, bool const endOfStream) = 0; |
e1f7507e | 39 | |
137a13ea | 40 | virtual long int lineNumber() const =0; |
43ae1d95 | 41 | virtual char const * errorString() const =0; |
42 | ||
43 | protected: | |
26ac0430 | 44 | ESIParser() {}; |
43ae1d95 | 45 | |
46 | private: | |
c2d4889f | 47 | static Register *Parser; |
48 | static Register *Parsers; | |
49 | ||
50 | public: | |
51 | }; | |
52 | ||
53 | class ESIParser::Register | |
54 | { | |
55 | ||
56 | public: | |
7901db21 AR |
57 | Register(const char *_name, ESIParser::Pointer (*_newParser)(ESIParserClient *aClient)); |
58 | ~Register(); | |
c2d4889f | 59 | |
60 | const char *name; | |
61 | ESIParser::Pointer (*newParser)(ESIParserClient *aClient); | |
62 | Register * next; | |
43ae1d95 | 63 | }; |
64 | ||
7901db21 | 65 | #define EsiParserDefinition(ThisClass) \ |
c2d4889f | 66 | ESIParser::Pointer ThisClass::NewParser(ESIParserClient *aClient) \ |
67 | { \ | |
f53969cc | 68 | return new ThisClass (aClient); \ |
c2d4889f | 69 | } |
70 | ||
7901db21 AR |
71 | #define EsiParserDeclaration \ |
72 | static ESIParser::Pointer NewParser(ESIParserClient *aClient) | |
e1f7507e | 73 | |
43ae1d95 | 74 | #endif /* SQUID_ESIPARSER_H */ |
f53969cc | 75 |