E-MailRelay
|
A pair of character buffers, one kept by value and the other being an ephemeral extension. More...
#include <glinestore.h>
Public Member Functions | |
LineStore () | |
Default constructor. | |
void | append (const std::string &) |
Appends to the store (by copying). More... | |
void | append (const char *, std::size_t) |
Appends to the store (by copying). More... | |
void | extend (const char *, std::size_t) |
Sets the extension. More... | |
void | discard (std::size_t n) |
Discards the first 'n' bytes and consolidates the residue. More... | |
void | consolidate () |
Consolidates the extension into the store. More... | |
void | clear () |
Clears all data. More... | |
std::size_t | size () const |
Returns the overall size. More... | |
bool | empty () const |
Returns true if size() is zero. More... | |
std::size_t | find (char c, std::size_t startpos=0U) const |
Finds the given character. More... | |
std::size_t | find (const std::string &s, std::size_t startpos=0U) const |
Finds the given string. More... | |
std::size_t | findSubStringAtEnd (const std::string &s, std::size_t startpos=0U) const |
Tries to find some leading sub-string of 's' that appears right at the end of the data, starting with the longest sub-string. More... | |
const char * | data (std::size_t pos, std::size_t size) const |
Returns a pointer for the data at the given position that is contiguous for the given size. More... | |
char | at (std::size_t n) const |
Returns the n'th character. More... | |
std::string | str () const |
Returns the complete string. More... | |
std::string | head (std::size_t n) const |
Returns the leading sub-string of str() of up to 'n' characters. More... | |
LineStore (const LineStore &)=delete | |
LineStore (LineStore &&)=delete | |
LineStore & | operator= (const LineStore &)=delete |
LineStore & | operator= (LineStore &&)=delete |
A pair of character buffers, one kept by value and the other being an ephemeral extension.
An iterator class can iterate over the combined data. Used in the implementation of GNet::LineBuffer as a zero-copy optimisation.
Definition at line 41 of file glinestore.h.
void GNet::LineStore::append | ( | const char * | data, |
std::size_t | size | ||
) |
Appends to the store (by copying).
Any existing extension is first consolidate()d.
Definition at line 205 of file glinestore.cpp.
void GNet::LineStore::append | ( | const std::string & | s | ) |
Appends to the store (by copying).
Any existing extension is first consolidate()d.
Definition at line 199 of file glinestore.cpp.
|
inline |
Returns the n'th character.
Definition at line 125 of file glinestore.h.
void GNet::LineStore::clear | ( | ) |
Clears all data.
Definition at line 218 of file glinestore.cpp.
void GNet::LineStore::consolidate | ( | ) |
Consolidates the extension into the store.
Definition at line 224 of file glinestore.cpp.
const char * GNet::LineStore::data | ( | std::size_t | pos, |
std::size_t | size | ||
) | const |
Returns a pointer for the data at the given position that is contiguous for the given size.
Data is shuffled around as required, which means that previous pointers are invalidated.
Definition at line 370 of file glinestore.cpp.
void GNet::LineStore::discard | ( | std::size_t | n | ) |
Discards the first 'n' bytes and consolidates the residue.
Definition at line 231 of file glinestore.cpp.
|
inline |
Returns true if size() is zero.
Definition at line 138 of file glinestore.h.
void GNet::LineStore::extend | ( | const char * | data, |
std::size_t | size | ||
) |
Sets the extension.
Any existing extension is consolidated(). Use consolidate(), discard() or clear() before the extension pointer becomes invalid.
Definition at line 211 of file glinestore.cpp.
std::size_t GNet::LineStore::find | ( | char | c, |
std::size_t | startpos = 0U |
||
) | const |
Finds the given character.
Returns npos if not found.
Definition at line 276 of file glinestore.cpp.
std::size_t GNet::LineStore::find | ( | const std::string & | s, |
std::size_t | startpos = 0U |
||
) | const |
std::size_t GNet::LineStore::findSubStringAtEnd | ( | const std::string & | s, |
std::size_t | startpos = 0U |
||
) | const |
Tries to find some leading sub-string of 's' that appears right at the end of the data, starting with the longest sub-string.
Returns npos if not found.
Definition at line 338 of file glinestore.cpp.
std::string GNet::LineStore::head | ( | std::size_t | n | ) | const |
Returns the leading sub-string of str() of up to 'n' characters.
Definition at line 415 of file glinestore.cpp.
|
inline |
Returns the overall size.
Definition at line 132 of file glinestore.h.
std::string GNet::LineStore::str | ( | ) | const |
Returns the complete string.
Definition at line 406 of file glinestore.cpp.