]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Polish: allow debugs printing a StringArea
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 19 Apr 2013 01:33:23 +0000 (19:33 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 19 Apr 2013 01:33:23 +0000 (19:33 -0600)
This operation is very useful for printing sub-sections of string buffers
of any kind.

src/base/StringArea.h

index 7391515df3b2f26267796cef2fe6a1a8df4e3f1a..e5b14a88f4b8bdfcf7f34a5d85fe55156bf5ad88 100644 (file)
@@ -35,6 +35,7 @@
 #if HAVE_CSTRING
 #include <cstring>
 #endif
+#include <ostream>
 
 /** 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 */