Struct IStreamQuadIterator

Nested Relationships

Nested Types

Struct Documentation

struct IStreamQuadIterator

Similar to std::istream_iterator<>. Parses the given istream and tries to extract Quads given in TURTLE format.

Example:
std::ifstream ifs{"triples.nt"};

for (auto qit = IStreamQuadIterator{ifs}; qit != IStreamQuadIterator{}; ++qit) {
     if (qit->has_value()) {
         std::cout << qit->value() << std::endl;
     } else {
         std::cerr << qit->error() << std::endl;
     }
}

Note

the iterator starts on the first Quad

Note

An exhausted iterator becomes the end-of-stream iterator.

Warning

The value pointed to by an end-of-stream iterator is undefined

Public Types

using flags_type = ParsingFlags
using state_type = ParsingState
using ok_type = Quad
using error_type = ParsingError
using value_type = nonstd::expected<ok_type, error_type>
using reference = value_type const&
using pointer = value_type const*
using difference_type = std::ptrdiff_t
using iterator_category = std::input_iterator_tag
using istream_type = std::istream

Public Functions

IStreamQuadIterator(void *stream, ReadFunc read, ErrorFunc error, EOFFunc eof, flags_type flags = ParsingFlags::none(), state_type *initial_state = nullptr)

Constructs a IStreamQuadIterator from a C-like io api. That is something similar to the triple (FILE *, fread, ferror) (parameters are called (stream, read, error) here).

Parameters:
  • stream – Pointer to a voided object, could be a FILE * cast to void * or anything else.

  • read – see ReadFunc docs, elem_size is guaranteed to be always set to 1

  • error – see ErrorFunc docs

  • flags – flags to pass to the parser

  • initial_state – optionally specifies the initial state of the parser, providing nullptr as the initial state results in the parser creating its own,fresh state instead of writing to the provided state.

explicit IStreamQuadIterator(std::istream &istream, flags_type flags = ParsingFlags::none(), state_type *initial_state = nullptr)

Constructs an IStreamQuadIterator to parse an input stream in turtle syntax to quads

Parameters:
  • istream – turtle input stream

  • flags – specifies the parser behaviour

  • initial_state – optionally specifies the initial state of the parser, providing nullptr as the initial state results in the parser creating its own,fresh state instead of writing to the provided state.

IStreamQuadIterator(IStreamQuadIterator const&) = delete
IStreamQuadIterator(IStreamQuadIterator&&) noexcept
IStreamQuadIterator &operator=(IStreamQuadIterator const&) = delete
IStreamQuadIterator &operator=(IStreamQuadIterator&&) noexcept
~IStreamQuadIterator() noexcept
reference operator*() const noexcept
pointer operator->() const noexcept
IStreamQuadIterator &operator++()
uint64_t current_line() const noexcept
uint64_t current_column() const noexcept
bool operator==(std::default_sentinel_t) const noexcept
bool operator!=(std::default_sentinel_t) const noexcept