21#ifndef G_NET_LINE_STORE_H
22#define G_NET_LINE_STORE_H
46 void append(
const std::string & ) ;
50 void append(
const char * , std::size_t ) ;
54 void extend(
const char * , std::size_t ) ;
70 std::size_t
size()
const ;
76 std::size_t
find(
char c , std::size_t startpos = 0U )
const ;
80 std::size_t
find(
const std::string & s , std::size_t startpos = 0U )
const ;
84 std::size_t
findSubStringAtEnd(
const std::string & s , std::size_t startpos = 0U )
const ;
90 const char *
data( std::size_t pos , std::size_t
size )
const ;
96 char at( std::size_t n )
const ;
99 std::string
str()
const ;
102 std::string
head( std::size_t n )
const ;
114 const char * dataimp( std::size_t pos , std::size_t
size ) ;
115 std::size_t search( std::string::const_iterator , std::string::const_iterator , std::size_t )
const ;
118 std::string m_store ;
119 const char * m_extra_data {
nullptr} ;
120 std::size_t m_extra_size {0U} ;
126 G_ASSERT( n <
size() ) ;
127 return n < m_store.size() ? m_store[n] : m_extra_data[n-m_store.size()] ;
133 return m_store.size() + m_extra_size ;
139 return m_store.empty() && m_extra_size == 0U ;
A pair of character buffers, one kept by value and the other being an ephemeral extension.
void discard(std::size_t n)
Discards the first 'n' bytes and consolidates the residue.
void append(const std::string &)
Appends to the store (by copying).
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.
std::string head(std::size_t n) const
Returns the leading sub-string of str() of up to 'n' characters.
bool empty() const
Returns true if size() is zero.
void clear()
Clears all data.
LineStore()
Default constructor.
std::string str() const
Returns the complete string.
std::size_t find(char c, std::size_t startpos=0U) const
Finds the given character.
std::size_t size() const
Returns the overall size.
void consolidate()
Consolidates the extension into the store.
void extend(const char *, std::size_t)
Sets the extension.
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,...
char at(std::size_t n) const
Returns the n'th character.