]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Implement operator<<(ostream, HttpHdrCc
authorFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 5 Aug 2015 21:11:09 +0000 (23:11 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 5 Aug 2015 21:11:09 +0000 (23:11 +0200)
src/HttpHdrCc.cc
src/HttpHdrCc.h

index 610657ab0acbf6e54604566886ed7469bece0505..51bc2a2299be643a19735a269e7d6102b036838a 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <map>
 #include <vector>
+#include <ostream>
 
 // invariant: row[j].id == j
 static LookupTable<HttpHdrCcType>::Record CcAttrs[] = {
@@ -288,6 +289,17 @@ httpHdrCcStatDumper(StoreEntry * sentry, int, double val, double, int count)
                           id, name, count, xdiv(count, dump_stat->ccParsedCount));
 }
 
+std::ostream &
+operator<< (std::ostream &s, HttpHdrCcType c)
+{
+    const unsigned char ic = static_cast<int>(c);
+    if (c >= HttpHdrCcType::CC_PUBLIC && c < HttpHdrCcType::CC_ENUM_END)
+        s << CcAttrs[ic].name << '[' << ic << ']' ;
+    else
+        s << "*invalid hdrcc* [" << ic << ']';
+    return s;
+}
+
 #if !_USE_INLINE_
 #include "HttpHdrCc.cci"
 #endif
index d263adca5a6160e98ad539d7d4082d261ed7816f..013bfdb0db47f6afc2750637e0034c8cf53ffe90 100644 (file)
@@ -12,6 +12,7 @@
 #include "dlink.h"
 #include "mem/forward.h"
 #include "SquidString.h"
+#include <iosfwd>
 
 class Packable;
 
@@ -197,6 +198,9 @@ void httpHdrCcInitModule(void);
 void httpHdrCcUpdateStats(const HttpHdrCc * cc, StatHist * hist);
 void httpHdrCcStatDumper(StoreEntry * sentry, int idx, double val, double size, int count);
 
+std::ostream&
+operator<< (std::ostream &, HttpHdrCcType);
+
 #if _USE_INLINE_
 #include "HttpHdrCc.cci"
 #endif