diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-04-16 19:21:57 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-04-16 19:35:27 +0200 |
commit | 75fe4f60c3f59af30cb1d8f2b5902d866c05550a (patch) | |
tree | 81106c6129626417cb9f71ab31393b31f9c27078 /libqpdf/QPDF.cc | |
parent | 38edca820eac0a79fd860895b46dd03005e3c96b (diff) | |
download | qpdf-75fe4f60c3f59af30cb1d8f2b5902d866c05550a.tar.zst |
Use anonymous namespaces for file-private classes
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r-- | libqpdf/QPDF.cc | 108 |
1 files changed, 56 insertions, 52 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 1864a1b4..abf51333 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -50,60 +50,64 @@ static char const* EMPTY_PDF = ( "110\n" "%%EOF\n"); -class InvalidInputSource: public InputSource +namespace { - public: - virtual ~InvalidInputSource() = default; - virtual qpdf_offset_t - findAndSkipNextEOL() override + class InvalidInputSource: public InputSource { - throwException(); - return 0; - } - virtual std::string const& - getName() const override - { - static std::string name("closed input source"); - return name; - } - virtual qpdf_offset_t - tell() override - { - throwException(); - return 0; - } - virtual void - seek(qpdf_offset_t offset, int whence) override - { - throwException(); - } - virtual void - rewind() override - { - throwException(); - } - virtual size_t - read(char* buffer, size_t length) override - { - throwException(); - return 0; - } - virtual void - unreadCh(char ch) override - { - throwException(); - } - - private: - void - throwException() - { - throw std::logic_error( - "QPDF operation attempted on a QPDF object with no input source." - " QPDF operations are invalid before processFile (or another" - " process method) or after closeInputSource"); - } -}; + public: + virtual ~InvalidInputSource() = default; + virtual qpdf_offset_t + findAndSkipNextEOL() override + { + throwException(); + return 0; + } + virtual std::string const& + getName() const override + { + static std::string name("closed input source"); + return name; + } + virtual qpdf_offset_t + tell() override + { + throwException(); + return 0; + } + virtual void + seek(qpdf_offset_t offset, int whence) override + { + throwException(); + } + virtual void + rewind() override + { + throwException(); + } + virtual size_t + read(char* buffer, size_t length) override + { + throwException(); + return 0; + } + virtual void + unreadCh(char ch) override + { + throwException(); + } + + private: + void + throwException() + { + throw std::logic_error( + "QPDF operation attempted on a QPDF object with no input " + "source." + " QPDF operations are invalid before processFile (or another" + " process method) or after closeInputSource"); + } + }; +} // namespace QPDF::ForeignStreamData::ForeignStreamData( std::shared_ptr<EncryptionParameters> encp, |