RESTinio
Public Member Functions | Private Attributes | List of all members
restinio::easy_parser::impl::source_t::content_consumer_t Class Reference

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

#include <easy_parser.hpp>

Public Member Functions

 content_consumer_t ()=delete
 
 content_consumer_t (const content_consumer_t &)=delete
 
 content_consumer_t (content_consumer_t &&)=delete
 
 content_consumer_t (source_t &from) noexcept
 
 ~content_consumer_t () noexcept
 
position_t started_at () const noexcept
 
void commit () noexcept
 Consume all acquired content. More...
 

Private Attributes

source_tm_from
 
const position_t m_started_at
 
bool m_consumed { false }
 

Detailed Description

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

Usage example:

expected_t<result_type, parse_error_t> try_parse(source_t & from) {
source_t::content_consumer_t consumer{from};
for(auto ch = from.getch(); some_condition(ch); ch = from.getch())
{
... // do something with ch.
}
if(no_errors_detected())
// All acquired content should be consumed.
consumer.commit();
// Otherwise all acquired content will be returned back to the input stream.
...
}
source_t(string_view_t data) noexcept
Initializing constructor.
@ consumer
Entity is a consumer of values. It requires a value on the input and doesn't produces anything.
RESTINIO_NODISCARD expected_t< typename Producer::result_type, parse_error_t > try_parse(string_view_t from, Producer producer)
Perform the parsing of the specified content by using specified value producer.
Since
v.0.6.1

Definition at line 850 of file easy_parser.hpp.

Constructor & Destructor Documentation

◆ content_consumer_t() [1/4]

restinio::easy_parser::impl::source_t::content_consumer_t::content_consumer_t ( )
delete

◆ content_consumer_t() [2/4]

restinio::easy_parser::impl::source_t::content_consumer_t::content_consumer_t ( const content_consumer_t )
delete

◆ content_consumer_t() [3/4]

restinio::easy_parser::impl::source_t::content_consumer_t::content_consumer_t ( content_consumer_t &&  )
delete

◆ content_consumer_t() [4/4]

restinio::easy_parser::impl::source_t::content_consumer_t::content_consumer_t ( source_t from)
inlinenoexcept

Definition at line 861 of file easy_parser.hpp.

◆ ~content_consumer_t()

restinio::easy_parser::impl::source_t::content_consumer_t::~content_consumer_t ( )
inlinenoexcept

Definition at line 866 of file easy_parser.hpp.

Member Function Documentation

◆ commit()

void restinio::easy_parser::impl::source_t::content_consumer_t::commit ( )
inlinenoexcept

Consume all acquired content.

Note
If that method is not called then all acquired content will be returned back.

Definition at line 885 of file easy_parser.hpp.

◆ started_at()

position_t restinio::easy_parser::impl::source_t::content_consumer_t::started_at ( ) const
inlinenoexcept

Definition at line 873 of file easy_parser.hpp.

Member Data Documentation

◆ m_consumed

bool restinio::easy_parser::impl::source_t::content_consumer_t::m_consumed { false }
private

Definition at line 854 of file easy_parser.hpp.

◆ m_from

source_t& restinio::easy_parser::impl::source_t::content_consumer_t::m_from
private

Definition at line 852 of file easy_parser.hpp.

◆ m_started_at

const position_t restinio::easy_parser::impl::source_t::content_consumer_t::m_started_at
private

Definition at line 853 of file easy_parser.hpp.


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