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_t & | m_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.
...
}
restinio::easy_parser::impl::source_t::source_t
source_t(string_view_t data) noexcept
Initializing constructor.
Definition: easy_parser.hpp:756
restinio::easy_parser::impl::entity_type_t::consumer
@ consumer
Entity is a consumer of values. It requires a value on the input and doesn't produces anything.
restinio::easy_parser::try_parse
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.
Definition: easy_parser.hpp:5042

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:

- restinio/helpers/easy_parser.hpp