11#ifndef SQUID_SRC_SBUF_SBUF_H
12#define SQUID_SRC_SBUF_SBUF_H
31#define SQUIDSBUFPH "%.*s"
32#define SQUIDSBUFPRINT(s) (s).plength(),(s).rawContent()
69 const char *
iter =
nullptr;
125 explicit SBuf(
const char *S);
128 explicit SBuf(
const std::string &s);
146 store_ = std::move(S.store_);
304 inline int cmp(
const char *S)
const {
428 return static_cast<int>(
length());
489 SBuf&
trim(
const SBuf &toRemove,
bool atBeginning =
true,
bool atEnd =
true);
625 if (blob->
mem <= otherBuffer && otherBuffer < (blob->
mem + blob->
capacity))
781 : iter(s.rawContent()+pos)
SBuf ToUpper(SBuf buf)
Returns a lower-cased copy of its parameter.
std::ostream & operator<<(std::ostream &os, const SBuf &S)
ostream output operator
void SBufToCstring(char *d, const SBuf &s)
SBuf ToLower(SBuf buf)
Returns an upper-cased copy of its parameter.
optimized set of C chars, with quick membership test and merge support
size_type spaceSize() const
the number unused bytes at the end of the allocated blob
value_type * mem
raw allocated memory block
size_type capacity
size of the raw allocated memory block
MemBlob::size_type size_type
bool operator!=(const SBufIterator &s) const
bool operator==(const SBufIterator &s) const
std::ptrdiff_t difference_type
std::input_iterator_tag iterator_category
const char & operator*() const
SBufIterator & operator++()
SBufIterator(const SBuf &, size_type)
Named SBuf::reserve() parameters. Defaults ask for and restrict nothing.
bool allowShared
whether sharing our storage with others is OK
size_type minSpace
allocate [at least this much] if spaceSize() is smaller
SBuf::size_type size_type
size_type maxCapacity
do not allocate more than this
size_type idealSpace
if allocating anyway, provide this much space
SBufReverseIterator & operator++()
SBufReverseIterator(const SBuf &s, size_type sz)
const char & operator*() const
uint64_t moves
number of move constructions/assignments
uint64_t getChar
number of calls to at() and operator[]
Locker(SBuf *parent, const char *otherBuffer)
char * rawAppendStart(size_type anticipatedSize)
void toUpper()
converts all characters to upper case;
int cmp(const char *S) const
void push_back(char)
Append a single character. The character may be NUL (\0).
int caseCmp(const SBuf &S, const size_type n) const
shorthand version for case-insensitive compare()
SBuf & append(const char c)
Append a single character. The character may be NUL (\0).
SBuf & assign(const char *S)
int cmp(const char *S, const size_type n) const
Shorthand version for C-string compare().
const char * rawContent() const
static const size_type npos
bool operator<(const SBuf &S) const
char at(size_type pos) const
SBuf & append(const char *S)
SBuf consume(size_type n=npos)
SBuf & vappendf(const char *fmt, va_list vargs)
SBuf & chop(size_type pos, size_type n=npos)
void reserveCapacity(size_type minCapacity)
size_type len_
number of our content bytes in shared store_
static const SBufStats & GetStats()
gets global statistic information
static MemBlob::Pointer GetStorePrototype()
SBuf & lowAppend(const char *memArea, size_type areaSize)
const InstanceId< SBuf > id
void reAlloc(size_type newsize)
size_type length() const
Returns the number of bytes stored in SBuf.
static SBufStats stats
class-wide statistics
SBuf & appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
SBuf()
create an empty (zero-size) SBuf
size_type rfind(char c, size_type endPos=npos) const
SBuf & operator=(const SBuf &S)
size_type reserve(const SBufReservationRequirements &requirements)
SBuf & Printf(const char *fmt,...) PRINTF_FORMAT_ARG2
int cmp(const SBuf &S, const size_type n) const
shorthand version for compare()
size_type findFirstNotOf(const CharacterSet &set, size_type startPos=0) const
SBuf & trim(const SBuf &toRemove, bool atBeginning=true, bool atEnd=true)
bool operator>=(const SBuf &S) const
int compare(const SBuf &S, const SBufCaseSensitive isCaseSensitive) const
size_type spaceSize() const
size_type find(char c, size_type startPos=0) const
int cmp(const SBuf &S) const
size_type findFirstOf(const CharacterSet &set, size_type startPos=0) const
bool operator!=(const SBuf &S) const
size_type copy(char *dest, size_type n) const
std::string toStdString() const
std::string export function
bool operator==(const SBuf &S) const
size_type estimateCapacity(size_type desired) const
size_type findLastNotOf(const CharacterSet &set, size_type endPos=npos) const
char * rawSpace(size_type minSize)
bool operator>(const SBuf &S) const
const_iterator begin() const
char operator[](size_type pos) const
std::ostream & dump(std::ostream &os) const
void cow(size_type minsize=npos)
void checkAccessBounds(const size_type pos) const
SBuf & append(const SBuf &S)
MemBlob::Pointer store_
memory block, possibly shared with other SBufs
const_reverse_iterator rbegin() const
SBufIterator const_iterator
SBufReverseIterator const_reverse_iterator
int caseCmp(const SBuf &S) const
int caseCmp(const char *S, const size_type n) const
Shorthand version for case-insensitive C-string compare().
void reserveSpace(size_type minSpace)
int caseCmp(const char *S) const
int compare(const char *s, const SBufCaseSensitive isCaseSensitive) const
size_type findLastOf(const CharacterSet &set, size_type endPos=npos) const
size_type off_
our content start offset from the beginning of shared store_
const_iterator end() const
bool startsWith(const SBuf &S, const SBufCaseSensitive isCaseSensitive=caseSensitive) const
SBuf substr(size_type pos, size_type n=npos) const
std::ostream & print(std::ostream &os) const
print the SBuf contents to the supplied ostream
MemBlob::size_type size_type
void rawAppendFinish(const char *start, size_type actualSize)
SBuf & assign(const SBuf &S)
bool operator<=(const SBuf &S) const
const_reverse_iterator rend() const
void setAt(size_type pos, char toset)
void toLower()
converts all characters to lower case;
int compare(const SBuf &S, const SBufCaseSensitive isCaseSensitive, const size_type n) const
static const size_type maxSize
Maximum size of a SBuf. By design it MUST be < MAX(size_type)/2. Currently 256Mb.
#define PRINTF_FORMAT_ARG2
#define debugs(SECTION, LEVEL, CONTENT)