@@ -35,8 +35,6 @@ File::File(std::shared_ptr<internal::abstract::File> impl)
3535File::File (const std::string &path)
3636 : m_impl{std::make_shared<internal::common::DiskFile>(path)} {}
3737
38- File::operator bool () const { return m_impl.operator bool (); }
39-
4038FileLocation File::location () const noexcept { return m_impl->location (); }
4139
4240std::size_t File::size () const { return m_impl->size (); }
@@ -107,7 +105,7 @@ DecodedFile::DecodedFile(const std::string &path,
107105 : DecodedFile(internal::open_strategy::open_file(
108106 std::make_shared<internal::common::DiskFile>(path), preference)) {}
109107
110- DecodedFile::operator bool () const { return m_impl. operator bool ( ); }
108+ File DecodedFile::file () const { return File ( m_impl-> file () ); }
111109
112110FileType DecodedFile::file_type () const noexcept { return m_impl->file_type (); }
113111
@@ -121,7 +119,21 @@ DecoderEngine DecodedFile::decoder_engine() const noexcept {
121119 return m_impl->decoder_engine ();
122120}
123121
124- File DecodedFile::file () const { return File (m_impl->file ()); }
122+ bool DecodedFile::password_encrypted () const {
123+ return m_impl->password_encrypted ();
124+ }
125+
126+ EncryptionState DecodedFile::encryption_state () const {
127+ return m_impl->encryption_state ();
128+ }
129+
130+ std::optional<DecodedFile> DecodedFile::decrypt (const std::string &password) {
131+ auto decrypted = m_impl->decrypt (password);
132+ if (decrypted == nullptr ) {
133+ return std::nullopt ;
134+ }
135+ return DecodedFile (decrypted);
136+ }
125137
126138bool DecodedFile::is_text_file () const {
127139 return std::dynamic_pointer_cast<internal::abstract::TextFile>(m_impl) !=
@@ -231,18 +243,6 @@ DocumentFile::DocumentFile(const std::string &path)
231243 : DocumentFile(internal::open_strategy::open_document_file(
232244 std::make_shared<internal::common::DiskFile>(path))) {}
233245
234- bool DocumentFile::password_encrypted () const {
235- return m_impl->password_encrypted ();
236- }
237-
238- EncryptionState DocumentFile::encryption_state () const {
239- return m_impl->encryption_state ();
240- }
241-
242- bool DocumentFile::decrypt (const std::string &password) {
243- return m_impl->decrypt (password);
244- }
245-
246246DocumentType DocumentFile::document_type () const {
247247 return m_impl->document_type ();
248248}
@@ -260,18 +260,6 @@ std::shared_ptr<internal::abstract::DocumentFile> DocumentFile::impl() const {
260260PdfFile::PdfFile (std::shared_ptr<internal::abstract::PdfFile> impl)
261261 : DecodedFile(impl), m_impl{std::move (impl)} {}
262262
263- bool PdfFile::password_encrypted () const {
264- return m_impl->password_encrypted ();
265- }
266-
267- EncryptionState PdfFile::encryption_state () const {
268- return m_impl->encryption_state ();
269- }
270-
271- bool PdfFile::decrypt (const std::string &password) {
272- return m_impl->decrypt (password);
273- }
274-
275263std::shared_ptr<internal::abstract::PdfFile> PdfFile::impl () const {
276264 return m_impl;
277265}
0 commit comments