E-MailRelay

Public Member Functions | List of all members
GNet::LineStore Class Reference

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

## Detailed Description

A pair of character buffers, one kept by value and the other being an ephemeral extension.

Used in the implementation of GNet::LineBuffer as a zero-copy optimisation.

Definition at line 40 of file glinestore.h.

## Member Function Documentation

## ◆ append() [1/2]

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 186 of file glinestore.cpp.

## ◆ append() [2/2]

void GNet::LineStore::append | ( | const std::string & | s | ) |

Appends to the store (by copying).

Any existing extension is first consolidate()d.

Definition at line 180 of file glinestore.cpp.

## ◆ at()

char GNet::LineStore::at | ( | std::size_t | n | ) | const
| inline

Returns the n'th character.

Definition at line 124 of file glinestore.h.

## ◆ clear()

void GNet::LineStore::clear | ( |  | ) |

Clears all data.

Definition at line 199 of file glinestore.cpp.

## ◆ consolidate()

void GNet::LineStore::consolidate | ( |  | ) |

Consolidates the extension into the store.

Definition at line 205 of file glinestore.cpp.

## ◆ data()

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 351 of file glinestore.cpp.

## ◆ discard()

void GNet::LineStore::discard | ( | std::size_t | n | ) |

Discards the first 'n' bytes and consolidates the residue.

Definition at line 212 of file glinestore.cpp.

## ◆ empty()

bool GNet::LineStore::empty | ( |  | ) | const
| inline

Returns true if size() is zero.

Definition at line 137 of file glinestore.h.

## ◆ extend()

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 192 of file glinestore.cpp.

## ◆ find() [1/2]

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 257 of file glinestore.cpp.

## ◆ find() [2/2]

std::size_t GNet::LineStore::find | ( | const std::string & | s,
|  | std::size_t | startpos = `0U`
| ) |  | const

Finds the given string.

Returns npos if not found.

Definition at line 280 of file glinestore.cpp.

## ◆ findSubStringAtEnd()

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 319 of file glinestore.cpp.

## ◆ head()

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 396 of file glinestore.cpp.

## ◆ size()

std::size_t GNet::LineStore::size | ( |  | ) | const
| inline

Returns the overall size.

Definition at line 131 of file glinestore.h.

## ◆ str()

std::string GNet::LineStore::str | ( |  | ) | const

Returns the complete string.

Definition at line 387 of file glinestore.cpp.

The documentation for this class was generated from the following files:

- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gnet/glinestore.h
- /tmp/slackdce/slackrepo.HKsbdz/build_emailrelay/emailrelay-2.6/src/gnet/glinestore.cpp