]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Convert packing methods from Packer* to Packable* objects
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 3 Mar 2015 11:43:26 +0000 (03:43 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 3 Mar 2015 11:43:26 +0000 (03:43 -0800)
Packaging code can now receive any object that implements the Packable
interface instead of requiring the Packer trampoline object. For now it
is still the only object implementing Packable.

23 files changed:
src/HttpBody.cc
src/HttpBody.h
src/HttpHdrCc.cc
src/HttpHdrCc.h
src/HttpHdrContRange.cc
src/HttpHdrContRange.h
src/HttpHdrRange.cc
src/HttpHdrSc.cc
src/HttpHdrSc.h
src/HttpHdrScTarget.h
src/HttpHeader.cc
src/HttpHeader.h
src/HttpHeaderRange.h
src/HttpMsg.cc
src/HttpMsg.h
src/HttpReply.cc
src/HttpReply.h
src/HttpRequest.cc
src/HttpRequest.h
src/http/StatusLine.cc
src/http/StatusLine.h
src/tests/stub_HttpReply.cc
src/tests/stub_HttpRequest.cc

index 7b2b267267b9ca467b4a6c05c4c8ede9b4126bbc..50a161301eece5a34cb5e460f2eca685efd30f86 100644 (file)
@@ -39,7 +39,7 @@ HttpBody::setMb(MemBuf * mb_)
 }
 
 void
-HttpBody::packInto(Packer * p) const
+HttpBody::packInto(Packable * p) const
 {
     assert(p);
 
index 0f790698cbdab29b0a0e769c77029030a3c06f90..69df6450f12840795733145b7184ce40048ad4ec 100644 (file)
@@ -10,7 +10,6 @@
 #define HTTPBODY_H_
 
 #include "MemBuf.h"
-class Packer;
 
 /** Representation of a short predetermined message
  *
@@ -28,11 +27,12 @@ public:
      * by the HttpBody.
      */
     void setMb(MemBuf *);
-    /** output the HttpBody contents into the supplied packer
+
+    /** output the HttpBody contents into the supplied container
      *
      * \note content is not cleared by the output operation
      */
-    void packInto(Packer *) const;
+    void packInto(Packable *) const;
 
     /// clear the HttpBody content
     void clear();
index c079b7447e598cb53ba72473d4fc4bc09bafe938..27ba1559ae85ed5cea4afed87e63c97b5b393062 100644 (file)
@@ -251,7 +251,7 @@ HttpHdrCc::parse(const String & str)
 }
 
 void
-HttpHdrCc::packInto(Packer * p) const
+HttpHdrCc::packInto(Packable * p) const
 {
     // optimization: if the mask is empty do nothing
     if (mask==0)
index c14903ec0d6954658eeca629fc4e004b1ba88936..00399e8b14e105ad6ac946edf7b9f29bfc468e7c 100644 (file)
@@ -13,7 +13,7 @@
 #include "mem/forward.h"
 #include "SquidString.h"
 
-class Packer;
+class Packable;
 
 /** Http Cache-Control header representation
  *
@@ -144,7 +144,7 @@ public:
     /// check whether the attribute value supplied by id is set
     _SQUID_INLINE_ bool isSet(http_hdr_cc_type id) const;
 
-    void packInto(Packer * p) const;
+    void packInto(Packable * p) const;
 
     /** bit-mask representing what header values are set among those
      * recognized by squid.
index 0c33b75311f61da213e3c37216b3be0d4ba2f2c2..bee649c619a96f1354eb2b1c649ed55a894ef374 100644 (file)
@@ -98,7 +98,7 @@ httpHdrRangeRespSpecParseInit(HttpHdrRangeSpec * spec, const char *field, int fl
 }
 
 static void
-httpHdrRangeRespSpecPackInto(const HttpHdrRangeSpec * spec, Packer * p)
+httpHdrRangeRespSpecPackInto(const HttpHdrRangeSpec * spec, Packable * p)
 {
     /* Ensure typecast is safe */
     assert (spec->length >= 0);
@@ -200,7 +200,7 @@ httpHdrContRangeDup(const HttpHdrContRange * range)
 }
 
 void
-httpHdrContRangePackInto(const HttpHdrContRange * range, Packer * p)
+httpHdrContRangePackInto(const HttpHdrContRange * range, Packable * p)
 {
     assert(range && p);
     httpHdrRangeRespSpecPackInto(&range->spec, p);
index 6c14e5089b7988cb07d35551272a9fb6a6dfb8c7..322a6716738bf352df791bb954ae55f7a8709d03 100644 (file)
@@ -31,7 +31,7 @@ HttpHdrContRange *httpHdrContRangeParseCreate(const char *crange_spec);
 int httpHdrContRangeParseInit(HttpHdrContRange * crange, const char *crange_spec);
 void httpHdrContRangeDestroy(HttpHdrContRange * crange);
 HttpHdrContRange *httpHdrContRangeDup(const HttpHdrContRange * crange);
-void httpHdrContRangePackInto(const HttpHdrContRange * crange, Packer * p);
+void httpHdrContRangePackInto(const HttpHdrContRange * crange, Packable * p);
 /** inits with given spec */
 void httpHdrContRangeSet(HttpHdrContRange *, HttpHdrRangeSpec, int64_t);
 void httpHeaderAddContRange(HttpHeader *, HttpHdrRangeSpec, int64_t);
index e297de7258e4d2dd728c90083bbb9ab0f41b40a4..eea85b15440b3cbc3b205b7823a9d0f9338ad831 100644 (file)
@@ -105,7 +105,7 @@ HttpHdrRangeSpec::parseInit(const char *field, int flen)
 }
 
 void
-HttpHdrRangeSpec::packInto(Packer * packer) const
+HttpHdrRangeSpec::packInto(Packable * packer) const
 {
     if (!known_spec(offset))    /* suffix */
         packer->Printf("-%" PRId64,  length);
@@ -302,7 +302,7 @@ HttpHdrRange::end() const
 }
 
 void
-HttpHdrRange::packInto(Packer * packer) const
+HttpHdrRange::packInto(Packable * packer) const
 {
     const_iterator pos = begin();
 
index 537b880ad75907ee7de2680e01c2986b90b6dec3..f165ff613c25b5685d899fed2e698b85f06d918e 100644 (file)
@@ -235,7 +235,7 @@ HttpHdrSc::HttpHdrSc(const HttpHdrSc &sc)
 }
 
 void
-HttpHdrScTarget::packInto(Packer * p) const
+HttpHdrScTarget::packInto(Packable * p) const
 {
     http_hdr_sc_type flag;
     int pcount = 0;
@@ -265,7 +265,7 @@ HttpHdrScTarget::packInto(Packer * p) const
 }
 
 void
-HttpHdrSc::packInto(Packer * p) const
+HttpHdrSc::packInto(Packable * p) const
 {
     dlink_node *node;
     assert(p);
index 586065457fb63046c95828d7ce5b6487ce12d2d4..c38255d3be14f8e9a499cd35090b8d8277ba5250 100644 (file)
@@ -25,7 +25,7 @@ public:
     ~HttpHdrSc();
 
     bool parse(const String *str);
-    void packInto(Packer * p) const;
+    void packInto(Packable * p) const;
     void updateStats(StatHist *) const;
     HttpHdrScTarget * getMergedTarget (const char *ourtarget); //todo: make const?
     void setMaxAge(char const *target, int max_age);
index 5154801b071b45a01e9a00cbbd5f878ba4063c1c..f03f75dc27450b69c90fc5dd00510bc8ed56ad25 100644 (file)
@@ -15,8 +15,8 @@
 #include "SquidString.h"
 #include "typedefs.h"
 
+class Packable;
 class StatHist;
-class Packer;
 class StoreEntry;
 
 /** Representation of HTTP Surogate-Control header field targeted directive
@@ -82,7 +82,7 @@ public:
     String Target() const { return target; }
 
     void mergeWith(const HttpHdrScTarget * new_sc);
-    void packInto (Packer *p) const;
+    void packInto(Packable *p) const;
     void updateStats(StatHist *) const;
 
 private:
index d71f3cf750bb38dbdfe962ea27f4978ff7c519ab..092a69e006017cd34581db3bc2474de261ff1741 100644 (file)
@@ -735,7 +735,7 @@ HttpHeader::parse(const char *header_start, size_t hdrLen)
 
 /* packs all the entries using supplied packer */
 void
-HttpHeader::packInto(Packer * p, bool mask_sensitive_info) const
+HttpHeader::packInto(Packable * p, bool mask_sensitive_info) const
 {
     HttpHeaderPos pos = HttpHeaderInitPos;
     const HttpHeaderEntry *e;
@@ -1682,7 +1682,7 @@ HttpHeaderEntry::clone() const
 }
 
 void
-HttpHeaderEntry::packInto(Packer * p) const
+HttpHeaderEntry::packInto(Packable * p) const
 {
     assert(p);
     p->append(name.rawBuf(), name.size());
index f646d032dd9a3fe59cc0bfcb97aed82461e1374e..23a95df4a6efa70393e6f3ec3201edde062374e0 100644 (file)
@@ -22,7 +22,7 @@ class HttpHdrCc;
 class HttpHdrContRange;
 class HttpHdrRange;
 class HttpHdrSc;
-class Packer;
+class Packable;
 class StoreEntry;
 class SBuf;
 
@@ -87,7 +87,7 @@ public:
     ~HttpHeaderEntry();
     static HttpHeaderEntry *parse(const char *field_start, const char *field_end);
     HttpHeaderEntry *clone() const;
-    void packInto(Packer *p) const;
+    void packInto(Packable *p) const;
     int getInt() const;
     int64_t getInt64() const;
 
@@ -117,7 +117,7 @@ public:
     void compact();
     int reset();
     int parse(const char *header_start, size_t len);
-    void packInto(Packer * p, bool mask_sensitive_info=false) const;
+    void packInto(Packable * p, bool mask_sensitive_info=false) const;
     HttpHeaderEntry *getEntry(HttpHeaderPos * pos) const;
     HttpHeaderEntry *findEntry(http_hdr_type id) const;
     int delByName(const char *name);
index b69fc011018886f340a46565aab18ff3f54068b5..448e0ebf45b388bb2df526351caaf04a6a513bad 100644 (file)
@@ -33,7 +33,7 @@ public:
     bool parseInit(const char *field, int flen);
     int canonize(int64_t clen);
     void outputInfo( char const *note) const;
-    void packInto(Packer * p) const;
+    void packInto(Packable * p) const;
     bool mergeWith(const HttpHdrRangeSpec * donor);
     int64_t offset;
     int64_t length;
@@ -70,7 +70,7 @@ public:
     int canonize(HttpReply *rep);
     /* returns true if ranges are valid; inits HttpHdrRange */
     bool parseInit(const String * range_spec);
-    void packInto(Packer * p) const;
+    void packInto(Packable * p) const;
     /* other */
     bool isComplex() const;
     bool willBeComplex() const;
index 527a53c173b07d1a6bc56bdee7ff2fc7fec38f51..25907a2db7b0717351af3121cc960eacc8b9abf7 100644 (file)
@@ -316,7 +316,7 @@ HttpMsg::persistent() const
     }
 }
 
-void HttpMsg::packInto(Packer *p, bool full_uri) const
+void HttpMsg::packInto(Packable *p, bool full_uri) const
 {
     packFirstLineInto(p, full_uri);
     header.packInto(p);
index 309a82972de73257d72e6476320e1218f111d4f6..275b260591671e9b3188d2143ad0b144451720f0 100644 (file)
@@ -28,7 +28,7 @@ public:
 
     virtual void reset() = 0; // will have body when http*Clean()s are gone
 
-    void packInto(Packer * p, bool full_uri) const;
+    void packInto(Packable * p, bool full_uri) const;
 
     ///< produce a message copy, except for a few connection-specific settings
     virtual HttpMsg *clone() const = 0; ///< \todo rename: not a true copy?
@@ -91,7 +91,7 @@ protected:
      */
     virtual bool sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) = 0;
 
-    virtual void packFirstLineInto(Packer * p, bool full_uri) const = 0;
+    virtual void packFirstLineInto(Packable * p, bool full_uri) const = 0;
 
     virtual bool parseFirstLine(const char *blk_start, const char *blk_end) = 0;
 
index f599796d2911620da50f2384acb1b0b7b1cfc988..2dcd995894af7bdb646527d9d7ed962649f0fc3e 100644 (file)
@@ -108,7 +108,7 @@ HttpReply::clean()
 }
 
 void
-HttpReply::packHeadersInto(Packer * p) const
+HttpReply::packHeadersInto(Packable * p) const
 {
     sline.packInto(p);
     header.packInto(p);
@@ -116,7 +116,7 @@ HttpReply::packHeadersInto(Packer * p) const
 }
 
 void
-HttpReply::packInto(Packer * p)
+HttpReply::packInto(Packable * p)
 {
     packHeadersInto(p);
     body.packInto(p);
index 05b51a346f013fe11d0702dfbc10153bcb9e0836..cfa6cc94b18a0b57c652cf929d04bc7ede98eecb 100644 (file)
@@ -100,7 +100,7 @@ public:
 
     int validatorsMatch (HttpReply const *other) const;
 
-    void packHeadersInto(Packer * p) const;
+    void packHeadersInto(Packable * p) const;
 
     /** Clone this reply.
      *  Could be done as a copy-contructor but we do not want to accidently copy a HttpReply..
@@ -120,7 +120,7 @@ private:
 
     void hdrCacheClean();
 
-    void packInto(Packer * p);
+    void packInto(Packable * p);
 
     /* ez-routines */
     /** \return construct 304 reply and pack it into a MemBuf */
@@ -139,7 +139,7 @@ private:
     mutable int64_t bodySizeMax; /**< cached result of calcMaxBodySize */
 
 protected:
-    virtual void packFirstLineInto(Packer * p, bool) const { sline.packInto(p); }
+    virtual void packFirstLineInto(Packable * p, bool) const { sline.packInto(p); }
 
     virtual bool parseFirstLine(const char *start, const char *end);
 };
index 9206a3e64dc3dcca617f01722ba4cc6d99d3341f..b0497b18e3c59ec2404bdb8011b4667ff0d790f3 100644 (file)
@@ -373,7 +373,7 @@ HttpRequest::swapOut(StoreEntry * e)
 
 /* packs request-line and headers, appends <crlf> terminator */
 void
-HttpRequest::pack(Packer * p)
+HttpRequest::pack(Packable * p)
 {
     assert(p);
     /* pack request-line */
@@ -390,7 +390,7 @@ HttpRequest::pack(Packer * p)
  * A wrapper for debugObj()
  */
 void
-httpRequestPack(void *obj, Packer *p)
+httpRequestPack(void *obj, Packable *p)
 {
     HttpRequest *request = static_cast<HttpRequest*>(obj);
     request->pack(p);
@@ -507,7 +507,7 @@ const char *HttpRequest::packableURI(bool full_uri) const
     return "/";
 }
 
-void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const
+void HttpRequest::packFirstLineInto(Packable * p, bool full_uri) const
 {
     // form HTTP request-line
     p->Printf(SQUIDSBUFPH " %s HTTP/%d.%d\r\n",
index de9339afbe6eac43a2c520811c89502f44d29bf4..ada6ed0560283e0041a5c51bb1d46eeab45ff676 100644 (file)
@@ -37,7 +37,7 @@
 class ConnStateData;
 
 /*  Http Request */
-void httpRequestPack(void *obj, Packer *p);
+void httpRequestPack(void *obj, Packable *p);
 
 class HttpHdrRange;
 
@@ -220,9 +220,9 @@ public:
 
     void swapOut(StoreEntry * e);
 
-    void pack(Packer * p);
+    void pack(Packable * p);
 
-    static void httpRequestPack(void *obj, Packer *p);
+    static void httpRequestPack(void *obj, Packable *p);
 
     static HttpRequest * CreateFromUrlAndMethod(char * url, const HttpRequestMethod& method);
 
@@ -255,7 +255,7 @@ private:
     mutable int64_t rangeOffsetLimit;  /* caches the result of getRangeOffsetLimit */
 
 protected:
-    virtual void packFirstLineInto(Packer * p, bool full_uri) const;
+    virtual void packFirstLineInto(Packable * p, bool full_uri) const;
 
     virtual bool sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error);
 
index 57008291c6236d7ab591c3120df011c45facca72..285aec8a2c806e990bc141c97af8e9161603afa4 100644 (file)
@@ -43,7 +43,7 @@ Http::StatusLine::reason() const
 }
 
 void
-Http::StatusLine::packInto(Packer * p) const
+Http::StatusLine::packInto(Packable * p) const
 {
     assert(p);
 
index fdf6254a4768899efdbcc3cdc70d8a2a40d4aa4c..608c8173aa29c555f20487e9e54c014ce2e7b68b 100644 (file)
@@ -13,7 +13,7 @@
 #include "http/StatusCode.h"
 #include "SquidString.h"
 
-class Packer;
+class Packable;
 class String;
 
 namespace Http
@@ -44,7 +44,7 @@ public:
     const char *reason() const;
 
     /// pack fields using Packer
-    void packInto(Packer * p) const;
+    void packInto(Packable * p) const;
 
     /**
      * Parse a buffer and fill internal structures;
index d1d1a77dc5cc1078ab51237b0de35a9c04339d40..a91e28027a19d46d6b7e87b2595d5313769cb34d 100644 (file)
@@ -18,9 +18,9 @@ HttpReply::HttpReply() : HttpMsg(hoReply), date (0), last_modified (0),
     STUB_NOP
     HttpReply::~HttpReply() STUB
     void HttpReply::setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires_) STUB
-    void HttpReply::packHeadersInto(Packer * p) const STUB
+    void HttpReply::packHeadersInto(Packable *) const STUB
     void HttpReply::reset() STUB
-    void httpBodyPackInto(const HttpBody * body, Packer * p) STUB
+    void httpBodyPackInto(const HttpBody *, Packable *) STUB
     bool HttpReply::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) STUB_RETVAL(false)
     int HttpReply::httpMsgParseError() STUB_RETVAL(0)
     bool HttpReply::expectingBody(const HttpRequestMethod&, int64_t&) const STUB_RETVAL(false)
index fcaf21d62b92e298292b571daac08a6f078413b3..9c45144062c3eaf6ce21e74995832f53787624aa 100644 (file)
@@ -16,7 +16,7 @@
 HttpRequest::HttpRequest() : HttpMsg(hoRequest) STUB
     HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) : HttpMsg(hoRequest) STUB
     HttpRequest::~HttpRequest() STUB
-    void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const STUB
+    void HttpRequest::packFirstLineInto(Packable *, bool) const STUB
     bool HttpRequest::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) STUB_RETVAL(false)
     void HttpRequest::hdrCacheInit() STUB
     void HttpRequest::reset() STUB