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