]> git.ipfire.org Git - thirdparty/squid.git/blob - src/format/Format.h
Merged from trunk 13172.
[thirdparty/squid.git] / src / format / Format.h
1 #ifndef _SQUID_FORMAT_FORMAT_H
2 #define _SQUID_FORMAT_FORMAT_H
3
4 #include "base/RefCount.h"
5 #include "ConfigParser.h"
6 /*
7 * Squid configuration allows users to define custom formats in
8 * several components.
9 * - logging
10 * - external ACL input
11 * - deny page URL
12 *
13 * These enumerations and classes define the API for parsing of
14 * format directives to define these patterns. Along with output
15 * functionality to produce formatted buffers.
16 */
17
18 class AccessLogEntry;
19 typedef RefCount<AccessLogEntry> AccessLogEntryPointer;
20 class MemBuf;
21 class StoreEntry;
22
23 namespace Format
24 {
25
26 class Token;
27
28 // XXX: inherit from linked list
29 class Format
30 {
31 public:
32 Format(const char *name);
33 virtual ~Format();
34
35 /* very inefficent parser, but who cares, this needs to be simple */
36 /* First off, let's tokenize, we'll optimize in a second pass.
37 * A token can either be a %-prefixed sequence (usually a dynamic
38 * token but it can be an escaped sequence), or a string. */
39 bool parse(const char *def);
40
41 /// assemble the state information into a formatted line.
42 void assemble(MemBuf &mb, const AccessLogEntryPointer &al, int logSequenceNumber) const;
43
44 /// dump this whole list of formats into the provided StoreEntry
45 void dump(StoreEntry * entry, const char *directiveName);
46
47 char *name;
48 Token *format;
49 Format *next;
50 };
51
52 } // namespace Format
53
54 #endif /* _SQUID_FORMAT_FORMAT_H */