9#ifndef SQUID_SRC_NOTES_H
10#define SQUID_SRC_NOTES_H
15#include "mem/forward.h"
76 typedef std::vector<Value::Pointer>
Values;
78 Note(
const char *aKey,
const size_t keyLen):
theKey(aKey, keyLen) {}
117 typedef std::vector<SBuf>
Keys;
122 explicit Notes(
const char *aDescr,
const Keys *extraReservedKeys =
nullptr,
bool allowFormatted =
true);
194 Entry(
const char *aKey,
const char *aValue)
231 std::optional<SBuf>
find(
const char *noteKey,
const char *sep =
",")
const;
234 const char *
findFirst(
const char *noteKey)
const;
240 void add(
const char *key,
const char *value);
244 void remove(
const char *key);
257 void print(std::ostream &os,
const char *nameValueSeparator,
const char *entryTerminator)
const;
#define RefCountable
The locking interface for use on Reference-Counted classes.
RefCount< NotePairs > NotePairsPointer
RefCount< AccessLogEntry > AccessLogEntryPointer
optimized set of C chars, with quick membership test and merge support
Used to store a note key/value pair.
Entry(const char *aKey, const char *aValue)
const SBuf & value() const
Entry(const SBuf &aKey, const SBuf &aValue)
Entry & operator=(const Entry &)=delete
const SBuf & name() const
RefCount< Entry > Pointer
Entry(const Entry &)=delete
void appendNewOnly(const NotePairs *src)
void append(const NotePairs *src)
Append the entries of the src NotePairs list to our list.
std::vector< SBuf > Names
std::vector< Entry::Pointer > Entries
The key/value pair entries.
NotePairs(NotePairs const &)=delete
std::optional< SBuf > find(const char *noteKey, const char *sep=",") const
void add(const SBuf &key, const SBuf &value)
void print(std::ostream &os, const char *nameValueSeparator, const char *entryTerminator) const
void remove(const char *key)
void replaceOrAdd(const NotePairs *src)
RefCount< NotePairs > Pointer
bool hasPair(const SBuf &key, const SBuf &value) const
const Entries & expandListEntries(const CharacterSet *delimiters) const
const char * findFirst(const char *noteKey) const
void addStrList(const SBuf &key, const SBuf &values, const CharacterSet &delimiters)
Entries entries
The key/value pair entries.
NotePairs & operator=(NotePairs const &)=delete
void replaceOrAddOrAppend(const NotePairs *src, const Names &appendables)
Stores a value for the note.
RefCount< Value > Pointer
SBuf theFormattedValue
The expanded value produced by format(), empty for non-quoted values.
Format::Format * valueFormat
Compiled annotation value format.
Value(const Value &)=delete
ACLList * aclList
The access list used to determine if this value is valid for a request.
const SBuf & value() const
const SBuf & format(const AccessLogEntryPointer &al)
Value & operator=(const Value &)=delete
Value::Pointer addValue(const char *value, const bool quoted, const char *descr, const Value::Method m=Value::mhAppend)
Note(const char *aKey, const size_t keyLen)
bool match(HttpRequest *request, HttpReply *reply, const AccessLogEntryPointer &al, SBuf &matched)
Values values
The possible values list for the note.
Note(const Note &)=delete
void printAsNoteDirective(StoreEntry *, const char *directiveName) const
Prints key and value(s) using a "note" directive format (including directive name).
void printAsAnnotationAclParameters(std::ostream &) const
Note & operator=(const Note &)=delete
std::vector< Value::Pointer > Values
void updateNotePairs(NotePairsPointer pairs, const CharacterSet *delimiters, const AccessLogEntryPointer &al)
Note::Pointer find(const SBuf ¬eKey)
NotesList::const_iterator const_iterator
iterates over the notes list
Note::Pointer parse(ConfigParser &parser)
Parses a notes line and returns a pointer to the parsed Note object.
void clean()
clean the notes list
std::vector< SBuf > Keys
unordered annotation names
Note::Pointer add(const SBuf ¬eKey)
iterator begin()
points to the first argument
void updateNotePairs(NotePairsPointer pairs, const CharacterSet *delimiters, const AccessLogEntryPointer &al)
const char * descr
identifies note source in error messages
void printAsNoteDirectives(StoreEntry *, const char *directiveName) const
Prints notes using "note" squid.conf directive format, one directive per stored note.
iterator end()
points to the end of list
Notes & operator=(const Notes &)=delete
std::vector< Note::Pointer > NotesList
NotesList::iterator iterator
iterates over the notes list
void banReservedKey(const SBuf &key, const Keys &banned) const
Makes sure the given key is not on the given list of banned names.
NotesList notes
The Note::Pointer objects array list.
bool formattedValues
whether to expand quoted logformat codes
static const Notes::Keys & ReservedKeys()
always prohibited key names
Notes(const Notes &)=delete
void printAsAnnotationAclParameters(std::ostream &) const
RefCount< Notes > Pointer
void validateKey(const SBuf &key) const
void parseKvPair()
Parses an annotate line with "key=value" or "key+=value" formats.
Keys reservedKeys
a list of additional prohibited key names