RESTinio

Classes | Public Types | Public Member Functions | Private Attributes | List of all members
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. More...

## Public Member Functions
| source_t (string_view_t data) noexcept
| Initializing constructor. More...
RESTINIO_NODISCARD character_t | getch () noexcept
| Get the next character from the input stream. More...
void | putback () noexcept
| Return one character back to the input stream. More...
RESTINIO_NODISCARD position_t | current_position () const noexcept
| Get the current position in the stream. More...
void | backto (position_t pos) noexcept
| Return the current position in the input stream at the specified position. More...
RESTINIO_NODISCARD bool | eof () const noexcept
| Is EOF has been reached? More...
RESTINIO_NODISCARD 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. More...

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

## 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 739 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 753 of file easy_parser.hpp.

## Constructor & Destructor Documentation

## ◆ source_t()

restinio::easy_parser::impl::source_t::source_t | ( | string_view_t | data | ) |
| inline explicit noexcept

Initializing constructor.

Definition at line 756 of file easy_parser.hpp.

## Member Function Documentation

## ◆ backto()

void restinio::easy_parser::impl::source_t::backto | ( | position_t | pos | ) |
| inline noexcept

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

Definition at line 794 of file easy_parser.hpp.

## ◆ current_position()

RESTINIO_NODISCARD position_t restinio::easy_parser::impl::source_t::current_position | ( |  | ) | const
| inline noexcept

Get the current position in the stream.

Definition at line 786 of file easy_parser.hpp.

## ◆ eof()

RESTINIO_NODISCARD bool restinio::easy_parser::impl::source_t::eof | ( |  | ) | const
| inline noexcept

Is EOF has been reached?

Definition at line 803 of file easy_parser.hpp.

## ◆ fragment()

RESTINIO_NODISCARD 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
| inline noexcept

Return a fragment from the input stream.

Attention
  The value of from should be lesser than the size of the input stream.

Parameters

  from | Starting position for the fragment required.
  length | Length 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 816 of file easy_parser.hpp.

## ◆ getch()

RESTINIO_NODISCARD character_t restinio::easy_parser::impl::source_t::getch | ( |  | ) |
| inline noexcept

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 765 of file easy_parser.hpp.

## ◆ putback()

void restinio::easy_parser::impl::source_t::putback | ( |  | ) |
| inline noexcept

Return one character back to the input stream.

Definition at line 777 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 742 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 749 of file easy_parser.hpp.

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

- restinio/helpers/easy_parser.hpp