diff --git a/src/odr/internal/pdf/pdf_cmap_parser.cpp b/src/odr/internal/pdf/pdf_cmap_parser.cpp index c28934bc..99264cb5 100644 --- a/src/odr/internal/pdf/pdf_cmap_parser.cpp +++ b/src/odr/internal/pdf/pdf_cmap_parser.cpp @@ -13,13 +13,13 @@ static constexpr int_type eof = std::streambuf::traits_type::eof(); CMapParser::CMapParser(std::istream &in) : m_parser(in) {} -std::istream &CMapParser::in() const { return m_parser.in(); } +std::istream &CMapParser::in() { return m_parser.in(); } -std::streambuf &CMapParser::sb() const { return m_parser.sb(); } +std::streambuf &CMapParser::sb() { return m_parser.sb(); } -const ObjectParser &CMapParser::parser() const { return m_parser; } +const ObjectParser &CMapParser::parser() { return m_parser; } -std::variant CMapParser::read_token() const { +std::variant CMapParser::read_token() { if (m_parser.peek_number()) { return std::visit([](auto n) { return Object(n); }, m_parser.read_integer_or_real()); @@ -51,7 +51,7 @@ std::variant CMapParser::read_token() const { } void CMapParser::read_codespacerange(const std::uint32_t n, - [[maybe_unused]] const CMap &cmap) const { + [[maybe_unused]] const CMap &cmap) { m_parser.skip_whitespace(); for (std::uint32_t i = 0; i < n; ++i) { auto from_glyph = m_parser.read_object(); @@ -63,7 +63,7 @@ void CMapParser::read_codespacerange(const std::uint32_t n, } } -void CMapParser::read_bfchar(const std::uint32_t n, CMap &cmap) const { +void CMapParser::read_bfchar(const std::uint32_t n, CMap &cmap) { m_parser.skip_whitespace(); for (std::uint32_t i = 0; i < n; ++i) { std::string glyph = m_parser.read_object().as_string(); @@ -88,7 +88,7 @@ void CMapParser::read_bfchar(const std::uint32_t n, CMap &cmap) const { } void CMapParser::read_bfrange(const std::uint32_t n, - [[maybe_unused]] const CMap &cmap) const { + [[maybe_unused]] const CMap &cmap) { m_parser.skip_whitespace(); for (std::uint32_t i = 0; i < n; ++i) { auto from_glyph = m_parser.read_object(); @@ -102,7 +102,7 @@ void CMapParser::read_bfrange(const std::uint32_t n, } } -CMap CMapParser::parse_cmap() const { +CMap CMapParser::parse_cmap() { CMap cmap; std::uint32_t last_int{}; diff --git a/src/odr/internal/pdf/pdf_cmap_parser.hpp b/src/odr/internal/pdf/pdf_cmap_parser.hpp index c7653257..8adb331e 100644 --- a/src/odr/internal/pdf/pdf_cmap_parser.hpp +++ b/src/odr/internal/pdf/pdf_cmap_parser.hpp @@ -16,20 +16,20 @@ class CMapParser { explicit CMapParser(std::istream &); - std::istream &in() const; - std::streambuf &sb() const; - const ObjectParser &parser() const; + [[nodiscard]] std::istream &in(); + [[nodiscard]] std::streambuf &sb(); + [[nodiscard]] const ObjectParser &parser(); - CMap parse_cmap() const; + [[nodiscard]] CMap parse_cmap(); private: ObjectParser m_parser; - Token read_token() const; + [[nodiscard]] Token read_token(); - void read_codespacerange(std::uint32_t n, const CMap &) const; - void read_bfchar(std::uint32_t n, CMap &) const; - void read_bfrange(std::uint32_t n, const CMap &) const; + void read_codespacerange(std::uint32_t n, const CMap &cmap); + void read_bfchar(std::uint32_t n, CMap &cmap); + void read_bfrange(std::uint32_t n, const CMap &cmap); }; } // namespace odr::internal::pdf diff --git a/src/odr/internal/pdf/pdf_document.hpp b/src/odr/internal/pdf/pdf_document.hpp index f926ccaf..48fc2a26 100644 --- a/src/odr/internal/pdf/pdf_document.hpp +++ b/src/odr/internal/pdf/pdf_document.hpp @@ -9,7 +9,7 @@ struct Catalog; struct Element; struct Document { - Catalog *catalog; + Catalog *catalog{nullptr}; std::vector> elements; template T *create_element(Args &&...args) { diff --git a/src/odr/internal/pdf/pdf_document_element.hpp b/src/odr/internal/pdf/pdf_document_element.hpp index 264fc039..2578ea9f 100644 --- a/src/odr/internal/pdf/pdf_document_element.hpp +++ b/src/odr/internal/pdf/pdf_document_element.hpp @@ -44,7 +44,7 @@ struct Pages final : Element { struct Page final : Element { Pages *parent{nullptr}; - Resources *resources; + Resources *resources{nullptr}; std::vector annotations; // TODO remove diff --git a/src/odr/internal/pdf/pdf_document_parser.cpp b/src/odr/internal/pdf/pdf_document_parser.cpp index 04e9e5ed..29cbe02f 100644 --- a/src/odr/internal/pdf/pdf_document_parser.cpp +++ b/src/odr/internal/pdf/pdf_document_parser.cpp @@ -167,9 +167,9 @@ Catalog *parse_catalog(DocumentParser &parser, const ObjectReference &reference, DocumentParser::DocumentParser(std::istream &in) : m_parser(in) {} -std::istream &DocumentParser::in() const { return m_parser.in(); } +std::istream &DocumentParser::in() { return m_parser.in(); } -const FileParser &DocumentParser::parser() const { return m_parser; } +FileParser &DocumentParser::parser() { return m_parser; } const Xref &DocumentParser::xref() const { return m_xref; } diff --git a/src/odr/internal/pdf/pdf_document_parser.hpp b/src/odr/internal/pdf/pdf_document_parser.hpp index 479bfe32..ced1a40b 100644 --- a/src/odr/internal/pdf/pdf_document_parser.hpp +++ b/src/odr/internal/pdf/pdf_document_parser.hpp @@ -15,8 +15,8 @@ class DocumentParser { public: explicit DocumentParser(std::istream &); - [[nodiscard]] std::istream &in() const; - [[nodiscard]] const FileParser &parser() const; + [[nodiscard]] std::istream &in(); + [[nodiscard]] FileParser &parser(); [[nodiscard]] const Xref &xref() const; const IndirectObject &read_object(const ObjectReference &reference); diff --git a/src/odr/internal/pdf/pdf_file_parser.cpp b/src/odr/internal/pdf/pdf_file_parser.cpp index 91492c4b..e1c3a362 100644 --- a/src/odr/internal/pdf/pdf_file_parser.cpp +++ b/src/odr/internal/pdf/pdf_file_parser.cpp @@ -10,13 +10,13 @@ namespace odr::internal::pdf { FileParser::FileParser(std::istream &in) : m_parser(in) {} -std::istream &FileParser::in() const { return m_parser.in(); } +std::istream &FileParser::in() { return m_parser.in(); } -std::streambuf &FileParser::sb() const { return m_parser.sb(); } +std::streambuf &FileParser::sb() { return m_parser.sb(); } -const ObjectParser &FileParser::parser() const { return m_parser; } +ObjectParser &FileParser::parser() { return m_parser; } -IndirectObject FileParser::read_indirect_object() const { +IndirectObject FileParser::read_indirect_object() { IndirectObject result; result.reference.id = m_parser.read_unsigned_integer(); @@ -47,7 +47,7 @@ IndirectObject FileParser::read_indirect_object() const { throw std::runtime_error("expected stream"); } -Trailer FileParser::read_trailer() const { +Trailer FileParser::read_trailer() { m_parser.expect_characters("trailer"); m_parser.skip_whitespace(); @@ -62,7 +62,7 @@ Trailer FileParser::read_trailer() const { return result; } -Xref FileParser::read_xref() const { +Xref FileParser::read_xref() { if (const std::string line = m_parser.read_line(); line != "xref") { throw std::runtime_error("expected xref"); } @@ -94,7 +94,7 @@ Xref FileParser::read_xref() const { } } -StartXref FileParser::read_start_xref() const { +StartXref FileParser::read_start_xref() { if (const std::string line = m_parser.read_line(); line != "startxref") { throw std::runtime_error("expected startxref"); } @@ -108,7 +108,7 @@ StartXref FileParser::read_start_xref() const { return result; } -std::string FileParser::read_stream(const std::int32_t size) const { +std::string FileParser::read_stream(const std::int32_t size) { std::string result; if (size >= 0) { @@ -140,7 +140,7 @@ std::string FileParser::read_stream(const std::int32_t size) const { return result; } -void FileParser::read_header() const { +void FileParser::read_header() { const std::string header1 = m_parser.read_line(); const std::string header2 = m_parser.read_line(); @@ -151,7 +151,7 @@ void FileParser::read_header() const { m_parser.skip_whitespace(); } -Entry FileParser::read_entry() const { +Entry FileParser::read_entry() { std::uint32_t position = in().tellg(); const std::string entry_header = m_parser.read_line(); in().seekg(position); @@ -179,7 +179,7 @@ Entry FileParser::read_entry() const { throw std::runtime_error("unknown entry"); } -void FileParser::seek_start_xref(const std::uint32_t margin) const { +void FileParser::seek_start_xref(const std::uint32_t margin) { in().seekg(0, std::ios::end); const std::int64_t size = in().tellg(); in().seekg(std::max(static_cast(0), size - margin), diff --git a/src/odr/internal/pdf/pdf_file_parser.hpp b/src/odr/internal/pdf/pdf_file_parser.hpp index 550d1a84..677a51e6 100644 --- a/src/odr/internal/pdf/pdf_file_parser.hpp +++ b/src/odr/internal/pdf/pdf_file_parser.hpp @@ -17,21 +17,21 @@ class FileParser { public: explicit FileParser(std::istream &); - [[nodiscard]] std::istream &in() const; - [[nodiscard]] std::streambuf &sb() const; - [[nodiscard]] const ObjectParser &parser() const; + [[nodiscard]] std::istream &in(); + [[nodiscard]] std::streambuf &sb(); + [[nodiscard]] ObjectParser &parser(); - [[nodiscard]] IndirectObject read_indirect_object() const; - [[nodiscard]] Trailer read_trailer() const; - [[nodiscard]] Xref read_xref() const; - [[nodiscard]] StartXref read_start_xref() const; + [[nodiscard]] IndirectObject read_indirect_object(); + [[nodiscard]] Trailer read_trailer(); + [[nodiscard]] Xref read_xref(); + [[nodiscard]] StartXref read_start_xref(); - [[nodiscard]] std::string read_stream(std::int32_t size) const; + [[nodiscard]] std::string read_stream(std::int32_t size); - void read_header() const; - [[nodiscard]] Entry read_entry() const; + void read_header(); + [[nodiscard]] Entry read_entry(); - void seek_start_xref(std::uint32_t margin = 64) const; + void seek_start_xref(std::uint32_t margin = 64); private: ObjectParser m_parser; diff --git a/src/odr/internal/pdf/pdf_graphics_operator.hpp b/src/odr/internal/pdf/pdf_graphics_operator.hpp index 84efdb60..1b57c963 100644 --- a/src/odr/internal/pdf/pdf_graphics_operator.hpp +++ b/src/odr/internal/pdf/pdf_graphics_operator.hpp @@ -103,7 +103,7 @@ struct GraphicsOperator { using Argument = Object; using Arguments = std::vector; - GraphicsOperatorType type; + GraphicsOperatorType type{GraphicsOperatorType::unknown}; Arguments arguments; }; diff --git a/src/odr/internal/pdf/pdf_graphics_operator_parser.cpp b/src/odr/internal/pdf/pdf_graphics_operator_parser.cpp index a6b27efa..7621f05d 100644 --- a/src/odr/internal/pdf/pdf_graphics_operator_parser.cpp +++ b/src/odr/internal/pdf/pdf_graphics_operator_parser.cpp @@ -115,11 +115,11 @@ static constexpr int_type eof = std::streambuf::traits_type::eof(); GraphicsOperatorParser::GraphicsOperatorParser(std::istream &in) : m_parser(in) {} -std::istream &GraphicsOperatorParser::in() const { return m_parser.in(); } +std::istream &GraphicsOperatorParser::in() { return m_parser.in(); } -std::streambuf &GraphicsOperatorParser::sb() const { return m_parser.sb(); } +std::streambuf &GraphicsOperatorParser::sb() { return m_parser.sb(); } -std::string GraphicsOperatorParser::read_operator_name() const { +std::string GraphicsOperatorParser::read_operator_name() { std::string result; while (true) { @@ -137,7 +137,7 @@ std::string GraphicsOperatorParser::read_operator_name() const { } } -GraphicsOperator GraphicsOperatorParser::read_operator() const { +GraphicsOperator GraphicsOperatorParser::read_operator() { GraphicsOperator result; while (true) { diff --git a/src/odr/internal/pdf/pdf_graphics_operator_parser.hpp b/src/odr/internal/pdf/pdf_graphics_operator_parser.hpp index 1cc337f8..3adf02a1 100644 --- a/src/odr/internal/pdf/pdf_graphics_operator_parser.hpp +++ b/src/odr/internal/pdf/pdf_graphics_operator_parser.hpp @@ -4,22 +4,18 @@ namespace odr::internal::pdf { -class SimpleArray; -class SimpleArrayElement; -class GraphicsArgument; -enum class GraphicsOperatorType; struct GraphicsOperator; class GraphicsOperatorParser { public: explicit GraphicsOperatorParser(std::istream &); - [[nodiscard]] std::istream &in() const; - [[nodiscard]] std::streambuf &sb() const; + [[nodiscard]] std::istream &in(); + [[nodiscard]] std::streambuf &sb(); - [[nodiscard]] std::string read_operator_name() const; + [[nodiscard]] std::string read_operator_name(); - [[nodiscard]] GraphicsOperator read_operator() const; + [[nodiscard]] GraphicsOperator read_operator(); private: ObjectParser m_parser; diff --git a/src/odr/internal/pdf/pdf_graphics_state.hpp b/src/odr/internal/pdf/pdf_graphics_state.hpp index 11a7b066..6e4ea9e0 100644 --- a/src/odr/internal/pdf/pdf_graphics_state.hpp +++ b/src/odr/internal/pdf/pdf_graphics_state.hpp @@ -69,7 +69,7 @@ struct GraphicsState { GraphicsState(); State ¤t(); - const State ¤t() const; + [[nodiscard]] const State ¤t() const; void execute(const GraphicsOperator &); }; diff --git a/src/odr/internal/pdf/pdf_object_parser.cpp b/src/odr/internal/pdf/pdf_object_parser.cpp index d7ba953e..dc81a567 100644 --- a/src/odr/internal/pdf/pdf_object_parser.cpp +++ b/src/odr/internal/pdf/pdf_object_parser.cpp @@ -12,11 +12,11 @@ namespace odr::internal::pdf { ObjectParser::ObjectParser(std::istream &in) : m_in{&in}, m_se(in, true), m_sb{in.rdbuf()} {} -std::istream &ObjectParser::in() const { return *m_in; } +std::istream &ObjectParser::in() { return *m_in; } -std::streambuf &ObjectParser::sb() const { return *m_sb; } +std::streambuf &ObjectParser::sb() { return *m_sb; } -ObjectParser::int_type ObjectParser::geti() const { +ObjectParser::int_type ObjectParser::geti() { const int_type c = sb().sgetc(); if (c == eof) { in().setstate(std::ios::eofbit); @@ -24,7 +24,7 @@ ObjectParser::int_type ObjectParser::geti() const { return c; } -ObjectParser::char_type ObjectParser::getc() const { +ObjectParser::char_type ObjectParser::getc() { const int_type c = sb().sgetc(); if (c == eof) { in().setstate(std::ios::eofbit); @@ -33,7 +33,7 @@ ObjectParser::char_type ObjectParser::getc() const { return static_cast(c); } -ObjectParser::char_type ObjectParser::bumpc() const { +ObjectParser::char_type ObjectParser::bumpc() { const int_type c = sb().sbumpc(); if (c == eof) { in().setstate(std::ios::eofbit); @@ -42,7 +42,7 @@ ObjectParser::char_type ObjectParser::bumpc() const { return static_cast(c); } -std::string ObjectParser::bumpnc(const std::size_t n) const { +std::string ObjectParser::bumpnc(const std::size_t n) { std::string result(n, '\0'); if (const auto m = static_cast(n); sb().sgetn(result.data(), m) != m) { @@ -51,7 +51,7 @@ std::string ObjectParser::bumpnc(const std::size_t n) const { return result; } -void ObjectParser::ungetc() const { +void ObjectParser::ungetc() { if (sb().sungetc() == eof) { throw std::runtime_error("unexpected stream exhaust"); } @@ -90,12 +90,12 @@ bool ObjectParser::is_whitespace(const char c) { c == ' '; } -bool ObjectParser::peek_whitespace() const { +bool ObjectParser::peek_whitespace() { const int_type c = geti(); return c != eof && is_whitespace(static_cast(c)); } -void ObjectParser::skip_whitespace() const { +void ObjectParser::skip_whitespace() { while (true) { const int_type c = geti(); if (c == eof) { @@ -108,14 +108,14 @@ void ObjectParser::skip_whitespace() const { } } -void ObjectParser::skip_line() const { read_line(); } +void ObjectParser::skip_line() { read_line(); } -std::string ObjectParser::read_line(const bool inclusive) const { +std::string ObjectParser::read_line(const bool inclusive) { return util::stream::read_line(in(), inclusive); } -void ObjectParser::expect_characters(const std::string &string) const { - auto observed = bumpnc(string.size()); +void ObjectParser::expect_characters(const std::string &string) { + const std::string observed = bumpnc(string.size()); if (observed != string) { throw std::runtime_error("unexpected characters" " (expected: " + @@ -123,12 +123,12 @@ void ObjectParser::expect_characters(const std::string &string) const { } } -bool ObjectParser::peek_number() const { +bool ObjectParser::peek_number() { const int_type c = geti(); return c != eof && (c == '+' || c == '-' || c == '.' || std::isdigit(c)); } -UnsignedInteger ObjectParser::read_unsigned_integer() const { +UnsignedInteger ObjectParser::read_unsigned_integer() { UnsignedInteger result = 0; while (true) { @@ -144,7 +144,7 @@ UnsignedInteger ObjectParser::read_unsigned_integer() const { } } -Integer ObjectParser::read_integer() const { +Integer ObjectParser::read_integer() { Integer sign = 1; const char_type c = getc(); @@ -160,11 +160,11 @@ Integer ObjectParser::read_integer() const { return sign * static_cast(read_unsigned_integer()); } -Real ObjectParser::read_number() const { +Real ObjectParser::read_number() { return std::visit([](auto v) -> Real { return v; }, read_integer_or_real()); } -std::variant ObjectParser::read_integer_or_real() const { +std::variant ObjectParser::read_integer_or_real() { Integer i = 0; if (char_type c = getc(); c != '.') { @@ -184,12 +184,12 @@ std::variant ObjectParser::read_integer_or_real() const { static_cast(i2) * std::pow(10.0, begin - end); } -bool ObjectParser::peek_name() const { +bool ObjectParser::peek_name() { const int_type c = geti(); return c == '/'; } -void ObjectParser::read_name(std::ostream &out) const { +void ObjectParser::read_name(std::ostream &out) { if (const char_type c = bumpc(); c != '/') { throw std::runtime_error("not a name"); } @@ -200,7 +200,7 @@ void ObjectParser::read_name(std::ostream &out) const { if (i == eof) { return; } - auto c = static_cast(i); + const auto c = static_cast(i); if (c < 0x21 || c > 0x7e || c == '/' || c == '%' || c == '(' || c == ')' || c == '<' || c == '>' || c == '[' || c == ']' || c == '{' || c == '}') { return; @@ -208,7 +208,7 @@ void ObjectParser::read_name(std::ostream &out) const { if (c == '#') { bumpc(); - auto hex = bumpnc<2>(); + const std::array hex = bumpnc<2>(); out.put(two_hex_to_char(hex[0], hex[1])); continue; } @@ -218,28 +218,28 @@ void ObjectParser::read_name(std::ostream &out) const { } } -Name ObjectParser::read_name() const { +Name ObjectParser::read_name() { std::stringstream ss; read_name(ss); return Name(ss.str()); } -bool ObjectParser::peek_null() const { +bool ObjectParser::peek_null() { const int_type c = geti(); return c != eof && (c == 'n' || c == 'N'); } -void ObjectParser::read_null() const { +void ObjectParser::read_null() { std::ignore = bumpnc<4>(); // TODO check ignore case } -bool ObjectParser::peek_boolean() const { +bool ObjectParser::peek_boolean() { const int_type c = geti(); return c != eof && (c == 't' || c == 'T' || c == 'f' || c == 'F'); } -Boolean ObjectParser::read_boolean() const { +Boolean ObjectParser::read_boolean() { const int_type c = geti(); if (c == 't' || c == 'T') { @@ -259,7 +259,7 @@ Boolean ObjectParser::read_boolean() const { throw std::runtime_error("unexpected starting character"); } -bool ObjectParser::peek_string() const { +bool ObjectParser::peek_string() { int_type c = geti(); if (c == eof) { return false; @@ -276,7 +276,7 @@ bool ObjectParser::peek_string() const { return false; } -std::variant ObjectParser::read_string() const { +std::variant ObjectParser::read_string() { std::string string; char_type c = bumpc(); @@ -288,7 +288,7 @@ std::variant ObjectParser::read_string() const { if (c == '\\') { c = getc(); if (std::isdigit(c)) { - auto octet = bumpnc<3>(); + const std::array octet = bumpnc<3>(); string += three_octet_to_char(octet[0], octet[1], octet[2]); } else { bumpc(); @@ -320,12 +320,12 @@ std::variant ObjectParser::read_string() const { throw std::runtime_error("unexpected starting character"); } -bool ObjectParser::peek_array() const { +bool ObjectParser::peek_array() { const int_type c = geti(); return c == '['; } -Array ObjectParser::read_array() const { +Array ObjectParser::read_array() { Array::Holder result; if (bumpc() != '[') { @@ -356,7 +356,7 @@ Array ObjectParser::read_array() const { } } -bool ObjectParser::peek_dictionary() const { +bool ObjectParser::peek_dictionary() { const int_type i = geti(); if (i == eof) { return false; @@ -370,7 +370,7 @@ bool ObjectParser::peek_dictionary() const { return false; } -Dictionary ObjectParser::read_dictionary() const { +Dictionary ObjectParser::read_dictionary() { Dictionary::Holder result; if (bumpc() != '<') { @@ -411,7 +411,7 @@ Dictionary ObjectParser::read_dictionary() const { } } -Object ObjectParser::read_object() const { +Object ObjectParser::read_object() { getc(); if (peek_null()) { @@ -442,7 +442,7 @@ Object ObjectParser::read_object() const { throw std::runtime_error("unknown object"); } -ObjectReference ObjectParser::read_object_reference() const { +ObjectReference ObjectParser::read_object_reference() { UnsignedInteger id = read_unsigned_integer(); skip_whitespace(); UnsignedInteger gen = read_unsigned_integer(); diff --git a/src/odr/internal/pdf/pdf_object_parser.hpp b/src/odr/internal/pdf/pdf_object_parser.hpp index 16925a58..a67e5ec5 100644 --- a/src/odr/internal/pdf/pdf_object_parser.hpp +++ b/src/odr/internal/pdf/pdf_object_parser.hpp @@ -18,21 +18,21 @@ class ObjectParser { explicit ObjectParser(std::istream &); - [[nodiscard]] std::istream &in() const; - [[nodiscard]] std::streambuf &sb() const; + [[nodiscard]] std::istream &in(); + [[nodiscard]] std::streambuf &sb(); - int_type geti() const; - char_type getc() const; - char_type bumpc() const; - template std::array bumpnc() const { + int_type geti(); + char_type getc(); + char_type bumpc(); + template std::array bumpnc() { std::array result; if (sb().sgetn(result.data(), result.size()) != result.size()) { throw std::runtime_error("unexpected stream exhaust"); } return result; } - [[nodiscard]] std::string bumpnc(std::size_t n) const; - void ungetc() const; + std::string bumpnc(std::size_t n); + void ungetc(); static int_type octet_char_to_int(char_type c); static int_type hex_char_to_int(char_type c); @@ -41,45 +41,45 @@ class ObjectParser { char_type third); static bool is_whitespace(char c); - [[nodiscard]] bool peek_whitespace() const; - void skip_whitespace() const; - void skip_line() const; - std::string read_line(bool inclusive = false) const; - void expect_characters(const std::string &string) const; + [[nodiscard]] bool peek_whitespace(); + void skip_whitespace(); + void skip_line(); + std::string read_line(bool inclusive = false); + void expect_characters(const std::string &string); - [[nodiscard]] bool peek_number() const; - [[nodiscard]] UnsignedInteger read_unsigned_integer() const; - [[nodiscard]] Integer read_integer() const; - [[nodiscard]] Real read_number() const; - [[nodiscard]] std::variant read_integer_or_real() const; + [[nodiscard]] bool peek_number(); + [[nodiscard]] UnsignedInteger read_unsigned_integer(); + [[nodiscard]] Integer read_integer(); + [[nodiscard]] Real read_number(); + [[nodiscard]] std::variant read_integer_or_real(); - [[nodiscard]] bool peek_name() const; - void read_name(std::ostream &) const; - [[nodiscard]] Name read_name() const; + [[nodiscard]] bool peek_name(); + void read_name(std::ostream &); + [[nodiscard]] Name read_name(); - [[nodiscard]] bool peek_null() const; - void read_null() const; + [[nodiscard]] bool peek_null(); + void read_null(); - [[nodiscard]] bool peek_boolean() const; - [[nodiscard]] Boolean read_boolean() const; + [[nodiscard]] bool peek_boolean(); + [[nodiscard]] Boolean read_boolean(); - [[nodiscard]] bool peek_string() const; - [[nodiscard]] std::variant read_string() const; + [[nodiscard]] bool peek_string(); + [[nodiscard]] std::variant read_string(); - [[nodiscard]] bool peek_array() const; - [[nodiscard]] Array read_array() const; + [[nodiscard]] bool peek_array(); + [[nodiscard]] Array read_array(); - [[nodiscard]] bool peek_dictionary() const; - [[nodiscard]] Dictionary read_dictionary() const; + [[nodiscard]] bool peek_dictionary(); + [[nodiscard]] Dictionary read_dictionary(); - [[nodiscard]] Object read_object() const; + [[nodiscard]] Object read_object(); - [[nodiscard]] ObjectReference read_object_reference() const; + [[nodiscard]] ObjectReference read_object_reference(); private: - std::istream *m_in; + std::istream *m_in{nullptr}; std::istream::sentry m_se; - std::streambuf *m_sb; + std::streambuf *m_sb{nullptr}; }; } // namespace odr::internal::pdf diff --git a/test/src/internal/pdf/pdf_file_parser.cpp b/test/src/internal/pdf/pdf_file_parser.cpp index e194aa82..83fc0660 100644 --- a/test/src/internal/pdf/pdf_file_parser.cpp +++ b/test/src/internal/pdf/pdf_file_parser.cpp @@ -19,7 +19,7 @@ TEST(FileParser, foo) { TestData::test_file_path("odr-public/pdf/style-various-1.pdf")); const auto in = file->stream(); - const FileParser parser(*in); + FileParser parser(*in); parser.read_header(); while (true) { @@ -81,7 +81,7 @@ TEST(FileParser, bar) { TestData::test_file_path("odr-public/pdf/style-various-1.pdf")); const auto in = file->stream(); - const FileParser parser(*in); + FileParser parser(*in); parser.read_header(); parser.seek_start_xref();