]> git.ipfire.org Git - thirdparty/squid.git/blob - src/format/Token.h
merge from trunk r13423
[thirdparty/squid.git] / src / format / Token.h
1 #ifndef _SQUID_FORMAT_TOKEN_H
2 #define _SQUID_FORMAT_TOKEN_H
3
4 //#include "format/TokenTableEntry.h"
5 #include "format/ByteCode.h"
6
7 /*
8 * Squid configuration allows users to define custom formats in
9 * several components.
10 * - logging
11 * - external ACL input
12 * - deny page URL
13 *
14 * These enumerations and classes define the API for parsing of
15 * format directives to define these patterns. Along with output
16 * functionality to produce formatted buffers.
17 */
18
19 namespace Format
20 {
21
22 class TokenTableEntry;
23
24 #define LOG_BUF_SZ (MAX_URL<<2)
25
26 // XXX: inherit from linked list
27 class Token
28 {
29 public:
30 Token();
31 ~Token();
32
33 /// Initialize the format token registrations
34 static void Init();
35
36 /** parses a single token. Returns the token length in characters,
37 * and fills in this item with the token information.
38 * def is for sure null-terminated.
39 */
40 int parse(const char *def, enum Quoting *quote);
41
42 ByteCode_t type;
43 const char *label;
44 struct {
45 char *string;
46
47 struct {
48 char *header;
49 char *element;
50 char separator;
51 } header;
52 } data;
53 int widthMin; ///< minimum field width
54 int widthMax; ///< maximum field width
55 enum Quoting quote;
56 bool left;
57 bool space;
58 bool zero;
59 int divisor; // class invariant: MUST NOT be zero.
60 Token *next; /* todo: move from linked list to array */
61
62 private:
63 const char *scanForToken(TokenTableEntry const table[], const char *cur);
64 };
65
66 } // namespace Format
67
68 #endif /* _SQUID_FORMAT_TOKEN_H */