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_view & | operator= (buffer_view &&x) noexcept |
buffer_view & | operator= (const buffer_view &x)=delete |
buffer_view & | operator= (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 () |
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
|
default |
Default constructor
matador::buffer_view::buffer_view | ( | const char * | start, |
size_t | size | ||
) |
Initialize a buffer_view with a character string
start | Start of the character string |
size | Length of the character string |
|
explicit |
Initialize a buffer_view with a character string
start | Start of the character string |
|
explicit |
Initialize a buffer_view with a string
str | String to initialize with |
|
inlineexplicit |
Initialize a buffer_view with an array of characters
S | Size of the array |
ar | Array of characters |
|
noexcept |
Move copy constructor
x | buffer_view to copy move from |
|
delete |
Copy constructor
x | buffer_view to copy from |
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
len | Number of characters to bump forward |
size_t matador::buffer_view::capacity | ( | ) | const |
Returns the total capacity of the buffer_view
void matador::buffer_view::clear | ( | ) |
Resets the cursor to the initial (first) position of the internal string
char * matador::buffer_view::data | ( | ) |
Get the data of the string starting from the current cursor position
const char * matador::buffer_view::data | ( | ) | const |
Get the data of the string starting from the current cursor position
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
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
|
noexcept |
|
delete |
buffer_view & matador::buffer_view::operator= | ( | const std::string & | str | ) |
Assign the given string to the buffer_view
str | String to assign |
size_t matador::buffer_view::size | ( | ) | const |
Returns the remaining size of the buffer_view