From: Amos Jeffries Date: Fri, 19 Apr 2013 01:33:23 +0000 (-0600) Subject: Polish: allow debugs printing a StringArea X-Git-Tag: SQUID_3_4_0_1~196 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ad6d09d289ecbf529194cf38cd1c239e3cb95a8;p=thirdparty%2Fsquid.git Polish: allow debugs printing a StringArea This operation is very useful for printing sub-sections of string buffers of any kind. --- diff --git a/src/base/StringArea.h b/src/base/StringArea.h index 7391515df3..e5b14a88f4 100644 --- a/src/base/StringArea.h +++ b/src/base/StringArea.h @@ -35,6 +35,7 @@ #if HAVE_CSTRING #include #endif +#include /** A char* plus length combination. Useful for temporary storing * and quickly looking up strings. @@ -56,6 +57,8 @@ public: return (theLen < s.theLen || (theLen == s.theLen && memcmp(theStart,s.theStart,theLen) < 0)) ; } + void print(std::ostream &os) const { os.write(theStart, theLen); } + private: /// pointed to the externally-managed memory area const char *theStart; @@ -63,4 +66,11 @@ private: size_t theLen; }; +inline std::ostream & +operator <<(std::ostream &os, const StringArea &a) +{ + a.print(os); + return os; +} + #endif /* SQUID_STRINGAREA_H */