RESTinio
Loading...
Searching...
No Matches
restinio::easy_parser::impl::source_t Class Reference

The class that implements "input stream". More...

#include <easy_parser.hpp>

Classes

class  content_consumer_t
 A helper class to automatically return acquired content back to the input stream. More...

Public Types

using position_t = string_view_t::size_type
 Type to be used as the index inside the input stream.

Public Member Functions

 source_t (string_view_t data) noexcept
 Initializing constructor.
character_t getch () noexcept
 Get the next character from the input stream.
void putback () noexcept
 Return one character back to the input stream.
position_t current_position () const noexcept
 Get the current position in the stream.
void backto (position_t pos) noexcept
 Return the current position in the input stream at the specified position.
bool eof () const noexcept
 Is EOF has been reached?
string_view_t fragment (string_view_t::size_type from, string_view_t::size_type length=string_view_t::npos) const noexcept
 Return a fragment from the input stream.

Private Attributes

const string_view_t m_data
 The content to be used as "input stream".
string_view_t::size_type m_index {}
 The current position in the input stream.

Detailed Description

The class that implements "input stream".

It is expected that string_view passed to the constructor of source_t will outlive the instance of source_t.

Since
v.0.6.1

Definition at line 740 of file easy_parser.hpp.

Member Typedef Documentation

◆ position_t

using restinio::easy_parser::impl::source_t::position_t = string_view_t::size_type

Type to be used as the index inside the input stream.

Definition at line 754 of file easy_parser.hpp.

Constructor & Destructor Documentation

◆ source_t()

restinio::easy_parser::impl::source_t::source_t ( string_view_t data)
inlineexplicitnoexcept

Initializing constructor.

Definition at line 757 of file easy_parser.hpp.

Member Function Documentation

◆ backto()

void restinio::easy_parser::impl::source_t::backto ( position_t pos)
inlinenoexcept

Return the current position in the input stream at the specified position.

Definition at line 795 of file easy_parser.hpp.

◆ current_position()

position_t restinio::easy_parser::impl::source_t::current_position ( ) const
inlinenodiscardnoexcept

Get the current position in the stream.

Definition at line 787 of file easy_parser.hpp.

◆ eof()

bool restinio::easy_parser::impl::source_t::eof ( ) const
inlinenodiscardnoexcept

Is EOF has been reached?

Definition at line 804 of file easy_parser.hpp.

◆ fragment()

string_view_t restinio::easy_parser::impl::source_t::fragment ( string_view_t::size_type from,
string_view_t::size_type length = string_view_t::npos ) const
inlinenodiscardnoexcept

Return a fragment from the input stream.

Attention
The value of from should be lesser than the size of the input stream.
Parameters
fromStarting position for the fragment required.
lengthLength of the fragment required. Value string_view_t::npos means the whole remaining content of the input stream starting from position from.

Definition at line 817 of file easy_parser.hpp.

◆ getch()

character_t restinio::easy_parser::impl::source_t::getch ( )
inlinenodiscardnoexcept

Get the next character from the input stream.

EOF can be returned in the case if there is no more data in the input stream.

Definition at line 766 of file easy_parser.hpp.

◆ putback()

void restinio::easy_parser::impl::source_t::putback ( )
inlinenoexcept

Return one character back to the input stream.

Definition at line 778 of file easy_parser.hpp.

Member Data Documentation

◆ m_data

const string_view_t restinio::easy_parser::impl::source_t::m_data
private

The content to be used as "input stream".

Definition at line 743 of file easy_parser.hpp.

◆ m_index

string_view_t::size_type restinio::easy_parser::impl::source_t::m_index {}
private

The current position in the input stream.

Note
m_index can have value of m_data.size(). In that case EOF will be returned.

Definition at line 750 of file easy_parser.hpp.


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