]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/Notes.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / Notes.h
index f9e5ed0ce452b4720e4684e8eea29fc7da655cdb..b4d97bc044b88d637e0213fec91174e0d719a193 100644 (file)
@@ -1,18 +1,22 @@
+/*
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
 #ifndef SQUID_NOTES_H
 #define SQUID_NOTES_H
 
 #include "acl/forward.h"
 #include "base/RefCount.h"
-#include "base/Vector.h"
-#include "CbDataList.h"
 #include "format/Format.h"
-#include "MemPool.h"
+#include "mem/forward.h"
 #include "SquidString.h"
-#include "typedefs.h"
 
-#if HAVE_STRING
 #include <string>
-#endif
+#include <vector>
 
 class HttpRequest;
 class HttpReply;
@@ -40,7 +44,7 @@ public:
         explicit Value(const String &aVal) : value(aVal), aclList(NULL), valueFormat(NULL) {}
         ~Value();
     };
-    typedef Vector<Value::Pointer> Values;
+    typedef std::vector<Value::Pointer> Values;
 
     explicit Note(const String &aKey): key(aKey) {}
 
@@ -70,12 +74,12 @@ class ConfigParser;
 class Notes
 {
 public:
-    typedef Vector<Note::Pointer> NotesList;
+    typedef std::vector<Note::Pointer> NotesList;
     typedef NotesList::iterator iterator; ///< iterates over the notes list
     typedef NotesList::const_iterator const_iterator; ///< iterates over the notes list
 
     Notes(const char *aDescr, const char **metasBlacklist, bool allowFormatted = false): descr(aDescr), blacklisted(metasBlacklist), formattedValues(allowFormatted) {}
-    Notes(): descr(NULL), blacklisted(NULL) {}
+    Notes(): descr(NULL), blacklisted(NULL), formattedValues(false) {}
     ~Notes() { notes.clear(); }
     /**
      * Parse a notes line and returns a pointer to the
@@ -122,11 +126,11 @@ public:
      */
     class Entry
     {
+        MEMPROXY_CLASS(Entry);
     public:
         Entry(const char *aKey, const char *aValue): name(aKey), value(aValue) {}
         String name;
         String value;
-        MEMPROXY_CLASS(Entry);
     };
 
     NotePairs() {}
@@ -137,6 +141,12 @@ public:
      */
     void append(const NotePairs *src);
 
+    /**
+     * Replace existing list entries with the src NotePairs entries.
+     * Entries which do not exist in the destination set are added.
+     */
+    void replaceOrAdd(const NotePairs *src);
+
     /**
      * Append any new entries of the src NotePairs list to our list.
      * Entries which already exist in the destination set are ignored.
@@ -147,7 +157,7 @@ public:
      * Returns a comma separated list of notes with key 'noteKey'.
      * Use findFirst instead when a unique kv-pair is needed.
      */
-    const char *find(const char *noteKey) const;
+    const char *find(const char *noteKey, const char *sep = ",") const;
 
     /**
      * Returns the first note value for this key or an empty string.
@@ -161,6 +171,11 @@ public:
      */
     void add(const char *key, const char *value);
 
+    /**
+     * Remove all notes with a given key.
+     */
+    void remove(const char *key);
+
     /**
      * Adds a note key and values strList to the notes list.
      * If the key name already exists in list, add the new values to its set
@@ -184,19 +199,23 @@ public:
      */
     bool empty() const {return entries.empty();}
 
-    Vector<NotePairs::Entry *> entries;          ///< The key/value pair entries
+    std::vector<NotePairs::Entry *> entries;      ///< The key/value pair entries
 
 private:
     NotePairs &operator = (NotePairs const &); // Not implemented
     NotePairs(NotePairs const &); // Not implemented
 };
 
-MEMPROXY_CLASS_INLINE(NotePairs::Entry);
-
 class AccessLogEntry;
 /**
  * Keep in sync HttpRequest and the corresponding AccessLogEntry objects
  */
 NotePairs &SyncNotes(AccessLogEntry &ale, HttpRequest &request);
 
+class ConnStateData;
+/**
+ * Updates ConnStateData ids and HttpRequest notes from helpers received notes.
+ */
+void UpdateRequestNotes(ConnStateData *csd, HttpRequest &request, NotePairs const &notes);
 #endif
+