Packable Class Referenceabstract

#include <Packable.h>

Inheritance diagram for Packable:

Public Member Functions

virtual ~Packable ()
 
virtual void append (const char *buf, int size)=0
 Appends a c-string to existing packed data. More...
 
void appendf (const char *fmt,...) PRINTF_FORMAT_ARG2
 Append operation with printf-style arguments. More...
 
virtual void vappendf (const char *fmt, va_list ap)=0
 
virtual void buffer ()
 
virtual void flush ()
 

Detailed Description

A uniform interface to store-like modules

Rationale:

We have two major interfaces Comm and Store, which take a variety of different data buffering objects and have different output actions to be performed on data.

Store has a nice storeAppend[Printf] capability which makes "storing" things easy and painless.

Comm lacks commAppend[Printf] because Comm does not handle its own buffers (no mem_obj equivalent for Comm).

Thus, if one wants to be able to Store and Comm::Write an object, 'e has to implement almost identical functions for using all the data storage objects and their associated actions. Doing this for all the available data storage types is a tedious nightmare of almost-duplicated code.

Packer

Objects inheriting from Packable provide a uniform interface for code to assemble data before passing to Store and Comm modules.

Packable objects have their own append and printf routines that "know" where to send incoming data. In case of Store interface, sending data to storeAppend. Packable buffer objects retain the data such that it can be flushed later to Comm::Write.

Thus, one can write just one function that will take a Packable object and either "pack" things for Comm::Write or "append" things to Store, depending on actual Packable object supplied.

XXX: Misnamed. This is a Packer or Packager API (i.e., "something that packs or packages others"); this is not a "something that can be packed" API.

Definition at line 52 of file Packable.h.

Constructor & Destructor Documentation

◆ ~Packable()

virtual Packable::~Packable ( )
inlinevirtual

Definition at line 55 of file Packable.h.

Member Function Documentation

◆ append()

◆ appendf()

void Packable::appendf ( const char *  fmt,
  ... 
)
inline

Definition at line 61 of file Packable.h.

References vappendf().

Referenced by Ftp::Server::acceptDataConnection(), aclParseAccessLine(), aclParseAclList(), Format::Format::assemble(), HttpStateData::buildRequestPrefix(), clientPackRangeHdr(), clientPackTermBound(), ErrorState::compileLegacyCode(), ErrorState::Dump(), EventScheduler::dump(), dump_cachemgrpasswd(), store_client::dumpStats(), Adaptation::Icap::ModXact::encapsulateHead(), Adaptation::Icap::Xaction::fillDoneStatus(), Adaptation::Icap::ModXact::fillDoneStatus(), Adaptation::Icap::Xaction::fillPendingStatus(), Adaptation::Icap::ModXact::fillPendingStatus(), HttpStateData::getMoreRequestBody(), Ftp::Server::handleEpsvReply(), Ftp::Server::handlePasvReply(), helperDispatch(), httpHdrContRangePackInto(), httpHdrRangeRespSpecPackInto(), internalRemoteUri(), Adaptation::Icap::ModXact::makeAllowHeader(), Adaptation::Icap::OptXact::makeRequest(), Adaptation::Icap::ModXact::makeRequestHeaders(), Adaptation::Icap::ModXact::makeUsernameHeader(), memBufReport(), munge_menu_line(), munge_other_line(), Adaptation::Icap::ModXact::openChunk(), HttpRequest::pack(), Http::Stream::packChunk(), HttpRequest::packFirstLineInto(), Http::StatusLine::packInto(), HttpHdrCc::packInto(), HttpHdrScTarget::packInto(), HttpHdrRangeSpec::packInto(), Helper::Client::packStatsInto(), Acl::AllOf::parse(), Ftp::PrintReply(), Ftp::Client::sendEprt(), Ftp::Client::sendPassive(), ExternalACLLookup::Start(), Ident::Start(), MemObject::stat(), statStoreEntry(), AsyncJob::status(), BodyPipe::status(), Adaptation::Ecap::XactionRep::status(), Adaptation::Icap::ServiceRep::status(), Adaptation::Icap::Xaction::status(), Http::Tunneler::status(), Comm::TcpAcceptor::status(), Ipc::Inquirer::status(), Security::PeerConnector::status(), wordlistCat(), Ftp::Server::writeCustomReply(), Ftp::Server::writeEarlyReply(), Ftp::Server::writeErrorReply(), and Http::Tunneler::writeRequest().

◆ buffer()

virtual void Packable::buffer ( )
inlinevirtual

start buffering appends (if relevant)

Indicates that a number of small appends are about to follow so would be detrimental to trigger expensive activity on each.

Reimplemented in StoreEntry, and CapturingStoreEntry.

Definition at line 88 of file Packable.h.

◆ flush()

virtual void Packable::flush ( )
inlinevirtual

perform a buffer flush (if relevant)

Used by code such as PackableStream, that assumes the Packable leads to some form of output buffer.

Reimplemented in StoreEntry, and CapturingStoreEntry.

Definition at line 95 of file Packable.h.

◆ vappendf()

virtual void Packable::vappendf ( const char *  fmt,
va_list  ap 
)
pure virtual

Append operation, with vsprintf(3)-style arguments.

Note
arguments may be evaluated more than once, be careful of side-effects

XXX: This method either should not exist or should not be virtual. Kids should not be forced to re-implement vappendf() logic. That logic should be implemented once, using other [Packable] APIs. Packable is not about providing a printf(3) service. Packable is about writing opaque data to various custom destinations.

Implemented in StoreEntry, MemBuf, and ShmWriter.

Referenced by appendf().


The documentation for this class was generated from the following file:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors