matador::buffer_view Class Reference

Cursor based string buffer. More...

#include <buffer_view.hpp>

Public Member Functions

 buffer_view ()=default
 
 buffer_view (const char *start, size_t size)
 
 buffer_view (const char *start)
 
 buffer_view (const std::string &str)
 
template<std::size_t S>
 buffer_view (const std::array< char, S > &ar)
 
 buffer_view (buffer_view &&x) noexcept
 
 buffer_view (const buffer_view &x)=delete
 
buffer_viewoperator= (buffer_view &&x) noexcept
 
buffer_viewoperator= (const buffer_view &x)=delete
 
buffer_viewoperator= (const std::string &str)
 
void bump (size_t len)
 
const char * data () const
 
char * data ()
 
size_t size () const
 
size_t capacity () const
 
bool empty () const
 
bool full () const
 
void clear ()
 

Detailed Description

Cursor based string buffer.

This class represents a character string with a cursor representing the position in the string.

The class can be used when a string must be processed and copying should be prevented

Constructor & Destructor Documentation

◆ buffer_view() [1/7]

matador::buffer_view::buffer_view ( )
default

Default constructor

◆ buffer_view() [2/7]

matador::buffer_view::buffer_view ( const char *  start,
size_t  size 
)

Initialize a buffer_view with a character string

Parameters
startStart of the character string
sizeLength of the character string

◆ buffer_view() [3/7]

matador::buffer_view::buffer_view ( const char *  start)
explicit

Initialize a buffer_view with a character string

Parameters
startStart of the character string

◆ buffer_view() [4/7]

matador::buffer_view::buffer_view ( const std::string &  str)
explicit

Initialize a buffer_view with a string

Parameters
strString to initialize with

◆ buffer_view() [5/7]

template<std::size_t S>
matador::buffer_view::buffer_view ( const std::array< char, S > &  ar)
inlineexplicit

Initialize a buffer_view with an array of characters

Template Parameters
SSize of the array
Parameters
arArray of characters

◆ buffer_view() [6/7]

matador::buffer_view::buffer_view ( buffer_view &&  x)
noexcept

Move copy constructor

Parameters
xbuffer_view to copy move from

◆ buffer_view() [7/7]

matador::buffer_view::buffer_view ( const buffer_view x)
delete

Copy constructor

Parameters
xbuffer_view to copy from

Member Function Documentation

◆ bump()

void matador::buffer_view::bump ( size_t  len)

Bump the cursor len characters forward. If the new position is after the end of the view the position is set to the end

Parameters
lenNumber of characters to bump forward

◆ capacity()

size_t matador::buffer_view::capacity ( ) const

Returns the total capacity of the buffer_view

Returns
Returns the total capacity

◆ clear()

void matador::buffer_view::clear ( )

Resets the cursor to the initial (first) position of the internal string

◆ data() [1/2]

char * matador::buffer_view::data ( )

Get the data of the string starting from the current cursor position

Returns
The string starting at the current position

◆ data() [2/2]

const char * matador::buffer_view::data ( ) const

Get the data of the string starting from the current cursor position

Returns
The string starting at the current position

◆ empty()

bool matador::buffer_view::empty ( ) const

Returns true if the buffer_view is empty meaning that no characters were used at all and the cursor points to the very beginning of the string

Returns
True if buffer_view is in initial state

◆ full()

bool matador::buffer_view::full ( ) const

Returns true if the buffer_view is full meaning that all characters are used and the cursor point to the very and of the internal string

Returns
True if the cursor points to the end of the string

◆ operator=() [1/3]

buffer_view & matador::buffer_view::operator= ( buffer_view &&  x)
noexcept

Move assign constructor

Parameters
xbuffer_view to move assign from
Returns
The moved buffer_view

◆ operator=() [2/3]

buffer_view & matador::buffer_view::operator= ( const buffer_view x)
delete

Assign constructor

Parameters
xbuffer_view to assign from
Returns
The assigned buffer_view

◆ operator=() [3/3]

buffer_view & matador::buffer_view::operator= ( const std::string &  str)

Assign the given string to the buffer_view

Parameters
strString to assign
Returns
The assigned buffer_view

◆ size()

size_t matador::buffer_view::size ( ) const

Returns the remaining size of the buffer_view

Returns
The remaining size

The documentation for this class was generated from the following file:
  • matador/utils/buffer_view.hpp