Program Listing for File IStreamQuadIterator.hpp¶
↰ Return to documentation for file (src/rdf4cpp/parser/IStreamQuadIterator.hpp)
#ifndef RDF4CPP_PARSER_ISTREAMQUADITERATOR_HPP
#define RDF4CPP_PARSER_ISTREAMQUADITERATOR_HPP
#include <iterator>
#include <memory>
#include <rdf4cpp/Expected.hpp>
#include <rdf4cpp/Quad.hpp>
#include <rdf4cpp/parser/ParsingError.hpp>
#include <rdf4cpp/parser/ParsingFlags.hpp>
#include <rdf4cpp/parser/ParsingState.hpp>
#include <rdf4cpp/IRIFactory.hpp>
namespace rdf4cpp::parser {
using ReadFunc = size_t (*)(void *buffer, size_t elem_size, size_t count, void *stream);
using ErrorFunc = int (*)(void *stream);
using EOFFunc = int (*)(void *stream);
struct IStreamQuadIterator {
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;
private:
struct Impl {
virtual ~Impl() = default;
[[nodiscard]] virtual std::optional<nonstd::expected<ok_type, error_type>> next() = 0;
[[nodiscard]] virtual uint64_t current_line() const noexcept = 0;
[[nodiscard]] virtual uint64_t current_column() const noexcept = 0;
Impl() = default;
Impl(Impl const &) = delete;
Impl(Impl&&) = delete;
Impl &operator=(Impl const &) = delete;
Impl &operator=(Impl &&) = delete;
};
struct ImplSerd;
struct ImplXML;
std::unique_ptr<Impl> impl;
std::optional<nonstd::expected<ok_type, error_type>> cur;
public:
IStreamQuadIterator(void *stream,
ReadFunc read,
ErrorFunc error,
EOFFunc eof,
flags_type flags = ParsingFlags::none(),
state_type *initial_state = nullptr);
explicit IStreamQuadIterator(std::istream &istream,
flags_type flags = ParsingFlags::none(),
state_type *initial_state = nullptr);
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++();
[[nodiscard]] uint64_t current_line() const noexcept;
[[nodiscard]] uint64_t current_column() const noexcept;
bool operator==(std::default_sentinel_t) const noexcept;
bool operator!=(std::default_sentinel_t) const noexcept;
};
FILE *fopen_fastseq(char const *path, char const *mode) noexcept;
} // namespace rdf4cpp::parser
#endif //RDF4CPP_PARSER_ISTREAMQUADITERATOR_HPP