]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/Notes.h
4 #include "HttpHeader.h"
5 #include "HttpHeaderTools.h"
16 * Used to store notes. The notes are custom key:value pairs
17 * ICAP request headers or ECAP options used to pass
18 * custom transaction-state related meta information to squid
19 * internal subsystems or to addaptation services.
21 class Note
: public RefCountable
24 typedef RefCount
<Note
> Pointer
;
25 /// Stores a value for the note.
26 class Value
: public RefCountable
29 typedef RefCount
<Value
> Pointer
;
30 String value
; ///< a note value
31 ACLList
*aclList
; ///< The access list used to determine if this value is valid for a request
32 explicit Value(const String
&aVal
) : value(aVal
), aclList(NULL
) {}
35 typedef Vector
<Value::Pointer
> Values
;
37 explicit Note(const String
&aKey
): key(aKey
) {}
40 * Adds a value to the note and returns a pointer to the
41 * related Value object.
43 Value::Pointer
addValue(const String
&value
);
46 * Walks through the possible values list of the note and selects
47 * the first value which matches the given HttpRequest and HttpReply
48 * or NULL if none matches.
50 const char *match(HttpRequest
*request
, HttpReply
*reply
);
51 String key
; ///< The note key
52 Values values
; ///< The possible values list for the note
57 * Used to store a notes list.
62 typedef Vector
<Note::Pointer
> NotesList
;
63 typedef NotesList::iterator iterator
; ///< iterates over the notes list
65 Notes(const char *aDescr
, const char **metasBlacklist
): descr(aDescr
), blacklisted(metasBlacklist
) {}
66 Notes(): descr(NULL
), blacklisted(NULL
) {}
67 ~Notes() { notes
.clean(); }
69 * Parse a notes line and returns a pointer to the
72 Note::Pointer
parse(ConfigParser
&parser
);
74 * Dump the notes list to the given StoreEntry object.
76 void dump(StoreEntry
*entry
, const char *name
);
77 void clean(); /// clean the notes list
79 /// points to the first argument
80 iterator
begin() { return notes
.begin(); }
81 /// points to the end of list
82 iterator
end() { return notes
.end(); }
83 /// return true if the notes list is empty
84 bool empty() { return notes
.empty(); }
86 NotesList notes
; ///< The Note::Pointer objects array list
87 const char *descr
; ///< A short description for notes list
88 const char **blacklisted
; ///< Null terminated list of blacklisted note keys
91 * Adds a note to the notes list and returns a pointer to the
92 * related Note object. If the note key already exists in list,
93 * returns a pointer to the existing object.
95 Note::Pointer
add(const String
¬eKey
);
98 class NotePairs
: public HttpHeader
101 NotePairs() : HttpHeader(hoNote
) {}