From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Wed, 1 Nov 2023 12:09:05 +0000 (+0000) Subject: Add AsList::suffixedBy() (#1564) X-Git-Tag: SQUID_7_0_1~301 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=042263ead3a9ea2c175dd19cc206c89621e3967e;p=thirdparty%2Fsquid.git Add AsList::suffixedBy() (#1564) --- diff --git a/src/base/IoManip.h b/src/base/IoManip.h index 53e17d94d2..b34a313e7d 100644 --- a/src/base/IoManip.h +++ b/src/base/IoManip.h @@ -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 &manipulator) } os << item; } + if (opened && manipulator.suffix) + os << manipulator.suffix; return os; }