]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add AsList::suffixedBy() (#1564)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Wed, 1 Nov 2023 12:09:05 +0000 (12:09 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 1 Nov 2023 22:29:12 +0000 (22:29 +0000)
src/base/IoManip.h

index 53e17d94d2fcc88985c8b6e981b71676271b653c..b34a313e7db0e87d66326f19b9211a9150d67ccf 100644 (file)
@@ -111,6 +111,9 @@ public:
     /// a c-string to print before the first item (if any). Caller must ensure lifetime.
     auto &prefixedBy(const char * const p) { prefix = p; return *this; }
 
+    /// a c-string to print after the last item (if any). Caller must ensure lifetime.
+    auto &suffixedBy(const char * const p) { suffix = p; return *this; }
+
     /// a c-string to print between consecutive items (if any). Caller must ensure lifetime.
     auto &delimitedBy(const char * const d) { delimiter = d; return *this; }
 
@@ -118,6 +121,7 @@ public:
     const Container &container; ///< zero or more items to print
 
     const char *prefix = nullptr; ///< \copydoc prefixedBy()
+    const char *suffix = nullptr; ///< \copydoc suffixedBy()
     const char *delimiter = nullptr; ///< \copydoc delimitedBy()
 };
 
@@ -137,6 +141,8 @@ operator <<(std::ostream &os, const AsList<Container> &manipulator)
         }
         os << item;
     }
+    if (opened && manipulator.suffix)
+        os << manipulator.suffix;
     return os;
 }