#include <SquidString.h>

Collaboration diagram for String:

Public Types

typedef size_t size_type
 

Public Member Functions

 String ()
 
 String (char const *)
 
 String (String const &)
 
 String (String &&S)
 
 ~String ()
 
Stringoperator= (char const *)
 
Stringoperator= (String const &)
 
Stringoperator= (String &&S)
 
bool operator== (String const &) const
 
bool operator!= (String const &) const
 
char operator[] (unsigned int aPos) const
 
size_type size () const
 
int psize () const
 
char const * rawBuf () const
 
char const * termedBuf () const
 
void limitInit (const char *str, int len)
 
void clean ()
 
void reset (char const *str)
 
void append (char const *buf, int len)
 
void append (char const *buf)
 
void append (char const)
 
void append (String const &)
 
void absorb (String &old)
 
const char * pos (char const *aString) const
 
const char * pos (char const ch) const
 
size_type find (char const ch) const
 
size_type find (char const *aString) const
 
const char * rpos (char const ch) const
 
size_type rfind (char const ch) const
 
int cmp (char const *) const
 
int cmp (char const *, size_type count) const
 
int cmp (String const &) const
 
int caseCmp (char const *) const
 
int caseCmp (char const *, size_type count) const
 
int caseCmp (String const &str) const
 
bool canGrowBy (const size_type growthLen) const
 whether appending growthLen characters is safe (i.e., unlikely to assert) More...
 
String substr (size_type from, size_type to) const
 
void cut (size_type newLength)
 

Static Public Member Functions

static size_type SizeMaxXXX ()
 
static bool CanGrowTo (size_type totalLen, const size_type extras=0)
 

Static Public Attributes

static const size_type npos = static_cast<size_type>(-1)
 

Private Member Functions

void allocAndFill (const char *str, int len)
 
void allocBuffer (size_type sz)
 
void setBuffer (char *buf, size_type sz)
 
bool defined () const
 
bool undefined () const
 
void set (char const *loc, char const ch)
 
void cutPointer (char const *loc)
 

Static Private Member Functions

static bool SafeAdd (size_type &base, size_type extra)
 returns true after increasing the first argument by extra if the sum does not exceed SizeMax_ More...
 

Private Attributes

size_type size_ = 0
 
size_type len_ = 0
 
char * buf_ = nullptr
 

Static Private Attributes

static const size_type SizeMax_ = 65535
 

Detailed Description

Definition at line 24 of file SquidString.h.

Member Typedef Documentation

Definition at line 37 of file SquidString.h.

Constructor & Destructor Documentation

String::String ( )

Definition at line 42 of file String.cc.

String::String ( char const *  aString)

Definition at line 49 of file String.cc.

References allocAndFill().

String::String ( String const &  old)

Definition at line 114 of file String.cc.

References allocAndFill(), rawBuf(), and size().

String::String ( String &&  S)
inline

Definition at line 31 of file SquidString.h.

String::~String ( )

Definition at line 141 of file String.cc.

References clean().

Member Function Documentation

void String::absorb ( String old)

Definition at line 212 of file String.cc.

References buf_, clean(), len_, NULL, setBuffer(), and size_.

Referenced by append().

void String::allocAndFill ( const char *  str,
int  len 
)
private

Definition at line 103 of file String.cc.

References allocBuffer(), assert, buf_, len, len_, PROF_start, and PROF_stop.

Referenced by limitInit(), operator=(), reset(), and String().

void String::allocBuffer ( String::size_type  sz)
private

Definition at line 22 of file String.cc.

References assert, memAllocString(), PROF_start, PROF_stop, setBuffer(), and undefined().

Referenced by allocAndFill(), and append().

void String::append ( char const *  buf)

Definition at line 190 of file String.cc.

References append(), and assert.

void String::append ( char const  chr)

Definition at line 197 of file String.cc.

References append().

void String::append ( String const &  old)

Definition at line 206 of file String.cc.

References append(), len_, and rawBuf().

bool String::canGrowBy ( const size_type  growthLen) const
inline

Definition at line 122 of file SquidString.h.

References CanGrowTo(), and size().

Referenced by append(), HttpStateData::httpBuildRequestHeader(), and strListAdd().

static bool String::CanGrowTo ( size_type  totalLen,
const size_type  extras = 0 
)
inlinestatic

Whether creating a totalLen-character string is safe (i.e., unlikely to assert). Optional extras can be used for overflow-safe length addition. Implementation has to add 1 because many String allocation methods do.

Definition at line 120 of file SquidString.h.

References SafeAdd().

Referenced by canGrowBy().

int String::caseCmp ( char const *  aString,
String::size_type  count 
) const

Definition at line 309 of file String.cc.

References nilCmp(), size(), and termedBuf().

int String::caseCmp ( String const &  str) const
inline

Definition at line 113 of file SquidString.h.

References caseCmp(), rawBuf(), and size().

int String::cmp ( char const *  aString,
String::size_type  count 
) const

Definition at line 279 of file String.cc.

References nilCmp(), size(), and termedBuf().

int String::cmp ( String const &  aString) const

Definition at line 289 of file String.cc.

References nilCmp(), size(), and termedBuf().

void String::cut ( String::size_type  newLength)

Definition at line 236 of file String.cc.

References buf_, and len_.

Referenced by clientFollowXForwardedForCheck(), and Adaptation::ServiceGroup::finalize().

void String::cutPointer ( char const *  loc)
inlineprivate

Definition at line 153 of file SquidString.h.

References buf_, len_, and size_.

bool String::defined ( ) const
inlineprivate

Definition at line 133 of file SquidString.h.

References buf_, and NULL.

Referenced by clean(), and undefined().

String::size_type String::find ( char const  ch) const

offset from string start of the first occurrence of ch returns String::npos if ch is not found

Definition at line 522 of file String.cc.

References npos, NULL, pos(), and rawBuf().

Referenced by strListIsSubstr().

String::size_type String::find ( char const *  aString) const

Definition at line 532 of file String.cc.

References npos, NULL, pos(), and rawBuf().

bool String::operator!= ( String const &  that) const

Definition at line 84 of file String.cc.

References cmp().

String & String::operator= ( char const *  aString)

Definition at line 59 of file String.cc.

References reset().

String & String::operator= ( String const &  old)

Definition at line 66 of file String.cc.

References allocAndFill(), clean(), rawBuf(), and size().

String& String::operator= ( String &&  S)
inline

Definition at line 42 of file SquidString.h.

References buf_, len_, and size_.

bool String::operator== ( String const &  that) const

Definition at line 75 of file String.cc.

References cmp().

char String::operator[] ( unsigned int  aPos) const
inline

Retrieve a single character in the string.

Parameters
aPosPosition of character to retrieve.

Definition at line 61 of file SquidString.h.

References assert, buf_, and size_.

const char * String::pos ( char const *  aString) const

Definition at line 498 of file String.cc.

References NULL, termedBuf(), and undefined().

Referenced by Http::ContentLengthInterpreter::checkField(), esiEnableProcessing(), and find().

const char * String::pos ( char const  ch) const

Definition at line 506 of file String.cc.

References NULL, termedBuf(), and undefined().

int String::psize ( ) const
inline

variant of size() suited to be used for printf-alikes. throws when size() >= INT_MAX

Definition at line 75 of file SquidString.h.

References INT_MAX, Must, and size().

Referenced by Ipc::TypedMsgHdr::putString(), and HttpReply::sanityCheckStartLine().

void String::reset ( char const *  str)

Definition at line 151 of file String.cc.

References allocAndFill(), clean(), PROF_start, and PROF_stop.

Referenced by ftpReadCwd(), and operator=().

String::size_type String::rfind ( char const  ch) const

Definition at line 542 of file String.cc.

References npos, NULL, rawBuf(), and rpos().

const char * String::rpos ( char const  ch) const

Definition at line 514 of file String.cc.

References NULL, termedBuf(), and undefined().

Referenced by rfind().

static bool String::SafeAdd ( size_type base,
size_type  extra 
)
inlinestaticprivate

Definition at line 143 of file SquidString.h.

Referenced by CanGrowTo().

void String::set ( char const *  loc,
char const  ch 
)
inlineprivate

Definition at line 147 of file SquidString.h.

References buf_, and size_.

void String::setBuffer ( char *  buf,
String::size_type  aSize 
)
private

Definition at line 34 of file String.cc.

References assert, buf_, size_, SizeMax_, and undefined().

Referenced by absorb(), and allocBuffer().

size_type String::size ( ) const
inline

Definition at line 71 of file SquidString.h.

References len_.

Referenced by ESIAssign::addElement(), HttpHeader::addEntry(), StoreEntry::adjustVary(), Format::Format::assemble(), canGrowBy(), caseCmp(), Adaptation::Icap::Options::cfgIntHeader(), Http::ContentLengthInterpreter::checkField(), Http::ContentLengthInterpreter::checkList(), CacheManager::CheckPassword(), clientFollowXForwardedForCheck(), clientProcessRequest(), cmp(), Ssl::ErrorDetail::cn(), Adaptation::Icap::Options::configure(), ErrorState::Convert(), Ipc::Port::CoordinatorAddr(), copy_cn(), copyOneHeaderFromClientsideRequestToUpstreamRequest(), copyResultsFromEntry(), HttpHeader::delAt(), ErrorState::Dump(), ESICustomParser::errorString(), ESIVariableExpression::eval(), ESIVariableCookie::eval(), ESIAssign::evaluateVariable(), Adaptation::Icap::ModXact::expectIcapTrailers(), Mgr::Action::fillEntry(), Adaptation::ServiceGroup::finalize(), Adaptation::Icap::ModXact::finalizeLogInfo(), Mgr::QueryParams::find(), HttpHdrSc::findTarget(), Mgr::QueryParams::get(), AccessLogEntry::getExtUser(), HttpHeader::getList(), gopherToHTML(), Ftp::Server::handleEprtRequest(), Ftp::Server::handleEpsvRequest(), Ftp::Server::handlePasvRequest(), Ftp::Server::handlePortRequest(), HttpHdrCc::hasNoCacheWithoutParameters(), HttpHdrCc::hasNoCacheWithParameters(), HttpHdrScTarget::hasTarget(), MemObject::hasUris(), HttpStateData::httpBuildRequestHeader(), httpFixupAuthentication(), DelayTagged::id(), HttpHeader::insertEntry(), TemplateFile::loadDefault(), MemObject::logUri(), Adaptation::Icap::ModXact::makeRequestHeaders(), Adaptation::Icap::ModXact::makeUsernameHeader(), Adaptation::Ecap::XactionRep::masterxSharedValue(), ACLExtUser::match(), HttpHdrCc::noCache(), operator<<(), operator=(), HttpHeaderEntry::packInto(), HttpHdrCc::packInto(), Adaptation::ServiceConfig::parse(), Mgr::QueryParams::Parse(), Ssl::ErrorDetailFile::parse(), Http::StatusLine::parse(), HttpHdrCc::parse(), Adaptation::Icap::ModXact::parseIcapHead(), Dns::LookupDetails::print(), HttpHdrCc::Private(), ESIAssign::process(), psize(), Ipc::Coordinator::registerStrand(), HttpReply::removeStaleWarnings(), HttpReply::removeStaleWarningValues(), ESIVarState::removeVariable(), HttpReply::sanityCheckStartLine(), statClientRequests(), clientReplyContext::storeId(), MemObject::storeId(), HttpRequest::storeId(), storeLog(), strHdrAcptLangGetItem(), String(), StringToSBuf(), strListAdd(), substr(), testEvent::testDump(), Mgr::QueryParams::unpack(), Adaptation::Ecap::XactionRep::usernameValue(), HttpReply::validatorsMatch(), Adaptation::Ecap::HeaderRep::value(), and Ftp::Server::writeErrorReply().

static size_type String::SizeMaxXXX ( )
inlinestatic

The absolute size limit on data held in a String. Since Strings can be nil-terminated implicitly it is best to ensure the useful content length is strictly less than this limit.

Definition at line 69 of file SquidString.h.

References SizeMax_.

Referenced by HttpHeader::addVia().

String String::substr ( String::size_type  from,
String::size_type  to 
) const
char const* String::termedBuf ( ) const
inline

Returns a raw pointer to the underlying backing store. The caller requires it to be null-terminated.

Definition at line 90 of file SquidString.h.

References buf_.

Referenced by aclMatchExternal(), Mgr::ActionParams::ActionParams(), addedEntry(), StoreEntry::adjustVary(), Format::Format::assemble(), assembleVaryKey(), clientReplyContext::buildReplyHeader(), ConnStateData::buildSslCertGenerationParams(), caseCmp(), Adaptation::Icap::Options::cfgIntHeader(), clientFollowXForwardedForCheck(), clientInterpretRequestHeaders(), HttpHeaderEntry::clone(), IpcIoFile::close(), cmp(), Ssl::ErrorDetail::cn(), ErrorState::Convert(), CacheManager::createRequestedAction(), Mgr::Action::createStoreEntry(), Adaptation::Icap::Xaction::dnsLookupDone(), testConfigParser::doParseQuotedTest(), ErrorState::Dump(), ESICustomParser::errorString(), Mgr::Action::fillEntry(), Adaptation::Icap::Xaction::finalizeLogInfo(), Adaptation::Icap::ModXact::finalizeLogInfo(), Adaptation::Ecap::FindAdapterService(), HttpHdrSc::findTarget(), Rock::SwapDir::freeSlotsPath(), HttpHeader::getContRange(), HttpHeader::getETag(), AccessLogEntry::getExtUser(), HttpHeaderEntry::getInt(), HttpHeaderEntry::getInt64(), HttpHeader::getLastStr(), HttpHeader::getList(), HttpHeader::getStr(), HttpHeader::getTime(), HttpHeader::getTimeOrTag(), ClientHttpRequest::handleAdaptationBlock(), Client::handleAdaptationBlocked(), Ftp::Server::handleEprtRequest(), Ftp::Server::handlePortRequest(), HttpHeader::hasNamed(), StoreEntry::hasOneOfEtags(), HttpStateData::httpBuildRequestHeader(), httpFixupAuthentication(), httpHeaderParseQuotedString(), TemplateFile::language(), TemplateFile::loadDefault(), ClientHttpRequest::logRequest(), MemObject::logUri(), Adaptation::Icap::ModXact::makeUsernameHeader(), ACLMyPortNameStrategy::match(), ACLTagStrategy::match(), ACLExtUser::match(), IpcIoFile::open(), Adaptation::Icap::Xaction::openConnection(), LoadableModule::openModule(), Adaptation::ServiceConfig::parse(), Ssl::ErrorDetailFile::parse(), Rock::SwapDir::parse(), HttpHeaderEntry::parse(), parse_HeaderWithAclList(), parseBytesOptionValue(), HttpHdrRange::parseInit(), Mgr::QueryParams::ParseParam(), peerDigestFetchedEnough(), peerDigestPDFinish(), peerDigestSetCBlock(), peerDigestStatsReport(), pos(), prepareLogWithRequestDetails(), Ftp::PrintReply(), ConfigParser::QuoteString(), HttpReply::removeStaleWarnings(), HttpReply::removeStaleWarningValues(), Kid::reportStopped(), Mgr::Response::Response(), rpos(), Log::Format::SquidIcap(), statClientRequests(), clientReplyContext::storeId(), MemObject::storeId(), storeLog(), strListGetItem(), CommonPool::theClassTypeLabel(), TemplateFile::tryLoadTemplate(), Adaptation::Ecap::UnregisterAdapterService(), Adaptation::Ecap::HeaderRep::value(), watch_child(), and Ftp::Server::writeErrorReply().

bool String::undefined ( ) const
inlineprivate

Definition at line 134 of file SquidString.h.

References defined().

Referenced by allocBuffer(), pos(), rpos(), and setBuffer().

Member Data Documentation

char* String::buf_ = nullptr
private
size_type String::len_ = 0
private

Definition at line 139 of file SquidString.h.

Referenced by absorb(), allocAndFill(), append(), clean(), cut(), cutPointer(), operator=(), and size().

const size_type String::npos = static_cast<size_type>(-1)
static

Definition at line 38 of file SquidString.h.

Referenced by find(), Adaptation::ServiceConfig::grokUri(), rfind(), and strListIsSubstr().

size_type String::size_ = 0
private

Definition at line 137 of file SquidString.h.

Referenced by absorb(), append(), clean(), cutPointer(), operator=(), operator[](), set(), and setBuffer().

const size_type String::SizeMax_ = 65535
staticprivate

64K limit protects some fixed-size buffers

Definition at line 141 of file SquidString.h.

Referenced by setBuffer(), and SizeMaxXXX().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors