From: Amos Jeffries Date: Tue, 3 Mar 2015 11:43:26 +0000 (-0800) Subject: Convert packing methods from Packer* to Packable* objects X-Git-Tag: merge-candidate-3-v1~101^2~12^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17802cf1f353c3f32d31b4767d4cb76bad35c4c8;p=thirdparty%2Fsquid.git Convert packing methods from Packer* to Packable* objects 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. --- diff --git a/src/HttpBody.cc b/src/HttpBody.cc index 7b2b267267..50a161301e 100644 --- a/src/HttpBody.cc +++ b/src/HttpBody.cc @@ -39,7 +39,7 @@ HttpBody::setMb(MemBuf * mb_) } void -HttpBody::packInto(Packer * p) const +HttpBody::packInto(Packable * p) const { assert(p); diff --git a/src/HttpBody.h b/src/HttpBody.h index 0f790698cb..69df6450f1 100644 --- a/src/HttpBody.h +++ b/src/HttpBody.h @@ -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(); diff --git a/src/HttpHdrCc.cc b/src/HttpHdrCc.cc index c079b7447e..27ba1559ae 100644 --- a/src/HttpHdrCc.cc +++ b/src/HttpHdrCc.cc @@ -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) diff --git a/src/HttpHdrCc.h b/src/HttpHdrCc.h index c14903ec0d..00399e8b14 100644 --- a/src/HttpHdrCc.h +++ b/src/HttpHdrCc.h @@ -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. diff --git a/src/HttpHdrContRange.cc b/src/HttpHdrContRange.cc index 0c33b75311..bee649c619 100644 --- a/src/HttpHdrContRange.cc +++ b/src/HttpHdrContRange.cc @@ -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); diff --git a/src/HttpHdrContRange.h b/src/HttpHdrContRange.h index 6c14e5089b..322a671673 100644 --- a/src/HttpHdrContRange.h +++ b/src/HttpHdrContRange.h @@ -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); diff --git a/src/HttpHdrRange.cc b/src/HttpHdrRange.cc index e297de7258..eea85b1544 100644 --- a/src/HttpHdrRange.cc +++ b/src/HttpHdrRange.cc @@ -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(); diff --git a/src/HttpHdrSc.cc b/src/HttpHdrSc.cc index 537b880ad7..f165ff613c 100644 --- a/src/HttpHdrSc.cc +++ b/src/HttpHdrSc.cc @@ -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); diff --git a/src/HttpHdrSc.h b/src/HttpHdrSc.h index 586065457f..c38255d3be 100644 --- a/src/HttpHdrSc.h +++ b/src/HttpHdrSc.h @@ -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); diff --git a/src/HttpHdrScTarget.h b/src/HttpHdrScTarget.h index 5154801b07..f03f75dc27 100644 --- a/src/HttpHdrScTarget.h +++ b/src/HttpHdrScTarget.h @@ -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: diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index d71f3cf750..092a69e006 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -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()); diff --git a/src/HttpHeader.h b/src/HttpHeader.h index f646d032dd..23a95df4a6 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -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); diff --git a/src/HttpHeaderRange.h b/src/HttpHeaderRange.h index b69fc01101..448e0ebf45 100644 --- a/src/HttpHeaderRange.h +++ b/src/HttpHeaderRange.h @@ -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; diff --git a/src/HttpMsg.cc b/src/HttpMsg.cc index 527a53c173..25907a2db7 100644 --- a/src/HttpMsg.cc +++ b/src/HttpMsg.cc @@ -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); diff --git a/src/HttpMsg.h b/src/HttpMsg.h index 309a82972d..275b260591 100644 --- a/src/HttpMsg.h +++ b/src/HttpMsg.h @@ -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; diff --git a/src/HttpReply.cc b/src/HttpReply.cc index f599796d29..2dcd995894 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -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); diff --git a/src/HttpReply.h b/src/HttpReply.h index 05b51a346f..cfa6cc94b1 100644 --- a/src/HttpReply.h +++ b/src/HttpReply.h @@ -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); }; diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 9206a3e64d..b0497b18e3 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -373,7 +373,7 @@ HttpRequest::swapOut(StoreEntry * e) /* packs request-line and headers, appends 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(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", diff --git a/src/HttpRequest.h b/src/HttpRequest.h index de9339afbe..ada6ed0560 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -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); diff --git a/src/http/StatusLine.cc b/src/http/StatusLine.cc index 57008291c6..285aec8a2c 100644 --- a/src/http/StatusLine.cc +++ b/src/http/StatusLine.cc @@ -43,7 +43,7 @@ Http::StatusLine::reason() const } void -Http::StatusLine::packInto(Packer * p) const +Http::StatusLine::packInto(Packable * p) const { assert(p); diff --git a/src/http/StatusLine.h b/src/http/StatusLine.h index fdf6254a47..608c8173aa 100644 --- a/src/http/StatusLine.h +++ b/src/http/StatusLine.h @@ -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; diff --git a/src/tests/stub_HttpReply.cc b/src/tests/stub_HttpReply.cc index d1d1a77dc5..a91e28027a 100644 --- a/src/tests/stub_HttpReply.cc +++ b/src/tests/stub_HttpReply.cc @@ -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) diff --git a/src/tests/stub_HttpRequest.cc b/src/tests/stub_HttpRequest.cc index fcaf21d62b..9c45144062 100644 --- a/src/tests/stub_HttpRequest.cc +++ b/src/tests/stub_HttpRequest.cc @@ -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