21#ifndef G_NET_LINE_STORE_H
22#define G_NET_LINE_STORE_H
47 void append(
const std::string & ) ;
51 void append(
const char * , std::size_t ) ;
55 void extend(
const char * , std::size_t ) ;
71 std::size_t
size()
const ;
77 std::size_t
find(
char c , std::size_t startpos = 0U )
const ;
81 std::size_t
find(
const std::string & s , std::size_t startpos = 0U )
const ;
85 std::size_t
findSubStringAtEnd(
const std::string & s , std::size_t startpos = 0U )
const ;
91 const char *
data( std::size_t pos , std::size_t
size )
const ;
97 char at( std::size_t n )
const ;
100 std::string
str()
const ;
103 std::string
head( std::size_t n )
const ;
115 const char * dataimp( std::size_t pos , std::size_t
size ) ;
116 std::size_t search( std::string::const_iterator , std::string::const_iterator , std::size_t )
const ;
119 std::string m_store ;
120 const char * m_extra_data{
nullptr} ;
121 std::size_t m_extra_size{0U} ;
127 G_ASSERT( n <
size() ) ;
128 return n < m_store.size() ? m_store[n] : m_extra_data[n-m_store.size()] ;
134 return m_store.size() + m_extra_size ;
140 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.