join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::StringView Class Reference

string view. More...

#include <view.hpp>

Public Types

using ViewPos = const char*
 

Public Member Functions

constexpr StringView (const char *in, size_t count)
 default constructor.
 
constexpr StringView (const char *first, const char *last)
 default constructor.
 
 StringView (const char *in)
 default constructor.
 
 StringView (const StringView &other)=default
 copy constructor.
 
StringViewoperator= (const StringView &other)=default
 copy assignment.
 
 StringView (StringView &&other)=default
 move constructor.
 
StringViewoperator= (StringView &&other)=default
 move assignment.
 
 ~StringView ()=default
 destroy instance.
 
int peek () const noexcept
 get character without extracting it.
 
int get () noexcept
 extracts character.
 
bool getIf (char expected) noexcept
 extracts expected character.
 
bool getIfNoCase (char expected) noexcept
 extracts expected character (case insensitive, ASCII-only).
 
size_t read (char *buf, size_t count) noexcept
 read characters.
 
void readUntilEscaped (std::string &out) noexcept
 read characters until escaped.
 
int skipWhitespaces () noexcept
 skip whitespaces.
 
int skipWhitespacesAndComments () noexcept
 skip whitespaces and comments.
 
ViewPos tell () const noexcept
 get input position indicator.
 
void seek (ViewPos pos) noexcept
 seek to the specified position.
 

Detailed Description

string view.

Member Typedef Documentation

◆ ViewPos

using join::StringView::ViewPos = const char*

Constructor & Destructor Documentation

◆ StringView() [1/5]

join::StringView::StringView ( const char * in,
size_t count )
inlineconstexpr

default constructor.

Parameters
ininput string.
countnumber of characters.

◆ StringView() [2/5]

join::StringView::StringView ( const char * first,
const char * last )
inlineconstexpr

default constructor.

Parameters
firstpointer to the first character of the string.
lastpointer to the last character of the string.

◆ StringView() [3/5]

join::StringView::StringView ( const char * in)
inline

default constructor.

Parameters
ininput string.

◆ StringView() [4/5]

join::StringView::StringView ( const StringView & other)
default

copy constructor.

Parameters
otherobject to copy.

◆ StringView() [5/5]

join::StringView::StringView ( StringView && other)
default

move constructor.

Parameters
otherobject to move.

◆ ~StringView()

join::StringView::~StringView ( )
default

destroy instance.

Member Function Documentation

◆ get()

int join::StringView::get ( )
inlinenoexcept

extracts character.

Returns
extracted character.

◆ getIf()

bool join::StringView::getIf ( char expected)
inlinenoexcept

extracts expected character.

Parameters
expectedexpected character.
Returns
true if extracted, false otherwise.

◆ getIfNoCase()

bool join::StringView::getIfNoCase ( char expected)
inlinenoexcept

extracts expected character (case insensitive, ASCII-only).

Parameters
expectedexpected character.
Returns
true if extracted, false otherwise.

◆ operator=() [1/2]

StringView & join::StringView::operator= ( const StringView & other)
default

copy assignment.

Parameters
otherobject to copy.
Returns
a reference of the current object.

◆ operator=() [2/2]

StringView & join::StringView::operator= ( StringView && other)
default

move assignment.

Parameters
otherobject to move.
Returns
a reference of the current object.

◆ peek()

int join::StringView::peek ( ) const
inlinenoexcept

get character without extracting it.

Returns
extracted character.

◆ read()

size_t join::StringView::read ( char * buf,
size_t count )
inlinenoexcept

read characters.

Parameters
bufoutput buffer.
countnumber of characters to read.
Returns
number of characters read.

◆ readUntilEscaped()

void join::StringView::readUntilEscaped ( std::string & out)
inlinenoexcept

read characters until escaped.

Parameters
outoutput buffer.

◆ seek()

void join::StringView::seek ( ViewPos pos)
inlinenoexcept

seek to the specified position.

Parameters
posposition to seek to.

◆ skipWhitespaces()

int join::StringView::skipWhitespaces ( )
inlinenoexcept

skip whitespaces.

Returns
0 on success, -1 otherwise.

◆ skipWhitespacesAndComments()

int join::StringView::skipWhitespacesAndComments ( )
inlinenoexcept

skip whitespaces and comments.

Returns
0 on success, -1 otherwise.

◆ tell()

ViewPos join::StringView::tell ( ) const
inlinenoexcept

get input position indicator.

Returns
current position.

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