Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Sep 14, 2024
1 parent 028809b commit 32e3d5d
Show file tree
Hide file tree
Showing 27 changed files with 68 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/odr/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ FileCategory DecodedFile::file_category() const noexcept {

FileMeta DecodedFile::file_meta() const noexcept { return m_impl->file_meta(); }

DecoderEngine DecodedFile::decoder_engine() const noexcept {
return m_impl->decoder_engine();
}

File DecodedFile::file() const { return File(m_impl->file()); }

bool DecodedFile::is_text_file() const {
Expand Down
1 change: 1 addition & 0 deletions src/odr/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class DecodedFile {
[[nodiscard]] FileType file_type() const noexcept;
[[nodiscard]] FileCategory file_category() const noexcept;
[[nodiscard]] FileMeta file_meta() const noexcept;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept;

[[nodiscard]] File file() const;

Expand Down
1 change: 1 addition & 0 deletions src/odr/internal/abstract/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class DecodedFile {
[[nodiscard]] virtual FileType file_type() const noexcept = 0;
[[nodiscard]] virtual FileCategory file_category() const noexcept = 0;
[[nodiscard]] virtual FileMeta file_meta() const noexcept = 0;
[[nodiscard]] virtual DecoderEngine decoder_engine() const noexcept = 0;
};

class TextFile : public DecodedFile {
Expand Down
4 changes: 4 additions & 0 deletions src/odr/internal/cfb/cfb_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ FileMeta CfbFile::file_meta() const noexcept {
return meta;
}

DecoderEngine CfbFile::decoder_engine() const noexcept {
return DecoderEngine::odr;
}

std::shared_ptr<abstract::Archive> CfbFile::archive() const {
return std::make_shared<CfbArchive>(m_cfb);
}
Expand Down
1 change: 1 addition & 0 deletions src/odr/internal/cfb/cfb_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CfbFile final : public abstract::ArchiveFile {

[[nodiscard]] FileType file_type() const noexcept final;
[[nodiscard]] FileMeta file_meta() const noexcept final;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept final;

[[nodiscard]] std::shared_ptr<abstract::Archive> archive() const final;

Expand Down
4 changes: 4 additions & 0 deletions src/odr/internal/common/image_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ FileType ImageFile::file_type() const noexcept { return m_file_type; }

FileMeta ImageFile::file_meta() const noexcept { return {}; }

DecoderEngine ImageFile::decoder_engine() const noexcept {
return DecoderEngine::odr;
}

std::shared_ptr<abstract::Image> ImageFile::image() const { return {}; }

} // namespace odr::internal::common
1 change: 1 addition & 0 deletions src/odr/internal/common/image_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ImageFile : public abstract::ImageFile {

[[nodiscard]] FileType file_type() const noexcept final;
[[nodiscard]] FileMeta file_meta() const noexcept final;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept final;

[[nodiscard]] std::shared_ptr<abstract::Image> image() const final;

Expand Down
4 changes: 4 additions & 0 deletions src/odr/internal/csv/csv_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ FileMeta CsvFile::file_meta() const noexcept {
return {FileType::comma_separated_values, false, {}};
}

DecoderEngine CsvFile::decoder_engine() const noexcept {
return DecoderEngine::odr;
}

} // namespace odr::internal::csv
1 change: 1 addition & 0 deletions src/odr/internal/csv/csv_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CsvFile final : public abstract::TextFile {

[[nodiscard]] FileType file_type() const noexcept final;
[[nodiscard]] FileMeta file_meta() const noexcept final;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept final;

private:
std::shared_ptr<text::TextFile> m_file;
Expand Down
4 changes: 4 additions & 0 deletions src/odr/internal/json/json_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ FileMeta JsonFile::file_meta() const noexcept {
return {FileType::javascript_object_notation, false, {}};
}

DecoderEngine JsonFile::decoder_engine() const noexcept {
return DecoderEngine::odr;
}

} // namespace odr::internal::json
1 change: 1 addition & 0 deletions src/odr/internal/json/json_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class JsonFile final : public abstract::TextFile {

[[nodiscard]] FileType file_type() const noexcept final;
[[nodiscard]] FileMeta file_meta() const noexcept final;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept final;

private:
std::shared_ptr<text::TextFile> m_file;
Expand Down
4 changes: 4 additions & 0 deletions src/odr/internal/odf/odf_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ FileType OpenDocumentFile::file_type() const noexcept {

FileMeta OpenDocumentFile::file_meta() const noexcept { return m_file_meta; }

DecoderEngine OpenDocumentFile::decoder_engine() const noexcept {
return DecoderEngine::odr;
}

DocumentType OpenDocumentFile::document_type() const {
return m_file_meta.document_meta->document_type;
}
Expand Down
2 changes: 2 additions & 0 deletions src/odr/internal/odf/odf_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class OpenDocumentFile final : public virtual abstract::DocumentFile {

[[nodiscard]] FileType file_type() const noexcept final;
[[nodiscard]] FileMeta file_meta() const noexcept final;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept final;

[[nodiscard]] DocumentType document_type() const final;
[[nodiscard]] DocumentMeta document_meta() const final;

Expand Down
4 changes: 4 additions & 0 deletions src/odr/internal/oldms/oldms_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ FileType LegacyMicrosoftFile::file_type() const noexcept {

FileMeta LegacyMicrosoftFile::file_meta() const noexcept { return m_file_meta; }

DecoderEngine LegacyMicrosoftFile::decoder_engine() const noexcept {
return DecoderEngine::odr;
}

DocumentType LegacyMicrosoftFile::document_type() const {
return m_file_meta.document_meta->document_type;
}
Expand Down
2 changes: 2 additions & 0 deletions src/odr/internal/oldms/oldms_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class LegacyMicrosoftFile final : public abstract::DocumentFile {

[[nodiscard]] FileType file_type() const noexcept final;
[[nodiscard]] FileMeta file_meta() const noexcept final;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept final;

[[nodiscard]] DocumentType document_type() const final;
[[nodiscard]] DocumentMeta document_meta() const final;

Expand Down
4 changes: 4 additions & 0 deletions src/odr/internal/ooxml/ooxml_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ FileType OfficeOpenXmlFile::file_type() const noexcept {

FileMeta OfficeOpenXmlFile::file_meta() const noexcept { return m_file_meta; }

DecoderEngine OfficeOpenXmlFile::decoder_engine() const noexcept {
return DecoderEngine::odr;
}

DocumentType OfficeOpenXmlFile::document_type() const {
return m_file_meta.document_meta->document_type;
}
Expand Down
2 changes: 2 additions & 0 deletions src/odr/internal/ooxml/ooxml_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class OfficeOpenXmlFile final : public abstract::DocumentFile {

[[nodiscard]] FileType file_type() const noexcept final;
[[nodiscard]] FileMeta file_meta() const noexcept final;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept final;

[[nodiscard]] DocumentType document_type() const final;
[[nodiscard]] DocumentMeta document_meta() const final;

Expand Down
2 changes: 1 addition & 1 deletion src/odr/internal/open_strategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace odr::internal {

std::vector<FileType>
open_strategy::types(std::shared_ptr<abstract::File> file) {
open_strategy::types(const std::shared_ptr<abstract::File> &file) {
std::vector<FileType> result;

auto file_type = magic::file_type(*file);
Expand Down
5 changes: 3 additions & 2 deletions src/odr/internal/open_strategy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class Path;
} // namespace odr::internal::common

namespace odr::internal::open_strategy {
std::vector<FileType> types(std::shared_ptr<internal::abstract::File> file);
std::vector<FileType>
types(const std::shared_ptr<internal::abstract::File> &file);
std::vector<DecoderEngine>
engines(std::shared_ptr<internal::abstract::File> file, FileType as);
engines(const std::shared_ptr<internal::abstract::File> &file, FileType as);

std::unique_ptr<internal::abstract::DecodedFile>
open_file(std::shared_ptr<internal::abstract::File> file);
Expand Down
4 changes: 4 additions & 0 deletions src/odr/internal/pdf/pdf_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ FileType PdfFile::file_type() const noexcept {

FileMeta PdfFile::file_meta() const noexcept { return {}; }

DecoderEngine PdfFile::decoder_engine() const noexcept {
return DecoderEngine::odr;
}

} // namespace odr::internal::pdf
1 change: 1 addition & 0 deletions src/odr/internal/pdf/pdf_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class PdfFile : public abstract::DecodedFile {
[[nodiscard]] FileType file_type() const noexcept final;
[[nodiscard]] FileCategory file_category() const noexcept final;
[[nodiscard]] FileMeta file_meta() const noexcept final;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept final;

private:
std::shared_ptr<abstract::File> m_file;
Expand Down
4 changes: 4 additions & 0 deletions src/odr/internal/svm/svm_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ FileMeta SvmFile::file_meta() const noexcept {
return result;
}

DecoderEngine SvmFile::decoder_engine() const noexcept {
return DecoderEngine::odr;
}

std::shared_ptr<abstract::Image> SvmFile::image() const { return {}; }

} // namespace odr::internal::svm
1 change: 1 addition & 0 deletions src/odr/internal/svm/svm_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class SvmFile final : public abstract::ImageFile {

[[nodiscard]] FileType file_type() const noexcept final;
[[nodiscard]] FileMeta file_meta() const noexcept final;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept final;

[[nodiscard]] std::shared_ptr<abstract::Image> image() const final;

Expand Down
4 changes: 4 additions & 0 deletions src/odr/internal/text/text_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ FileMeta TextFile::file_meta() const noexcept {
return {FileType::text_file, false, {}};
}

DecoderEngine TextFile::decoder_engine() const noexcept {
return DecoderEngine::odr;
}

} // namespace odr::internal::text
1 change: 1 addition & 0 deletions src/odr/internal/text/text_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TextFile final : public abstract::TextFile {

[[nodiscard]] FileType file_type() const noexcept final;
[[nodiscard]] FileMeta file_meta() const noexcept final;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept final;

private:
std::shared_ptr<abstract::File> m_file;
Expand Down
4 changes: 4 additions & 0 deletions src/odr/internal/zip/zip_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ FileMeta ZipFile::file_meta() const noexcept {
return meta;
}

DecoderEngine ZipFile::decoder_engine() const noexcept {
return DecoderEngine::odr;
}

std::shared_ptr<abstract::Archive> ZipFile::archive() const {
return std::make_shared<ZipArchive>(m_zip);
}
Expand Down
1 change: 1 addition & 0 deletions src/odr/internal/zip/zip_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ZipFile final : public abstract::ArchiveFile {

[[nodiscard]] FileType file_type() const noexcept final;
[[nodiscard]] FileMeta file_meta() const noexcept final;
[[nodiscard]] DecoderEngine decoder_engine() const noexcept final;

[[nodiscard]] std::shared_ptr<abstract::Archive> archive() const final;

Expand Down

0 comments on commit 32e3d5d

Please sign in to comment.