Skip to content

Commit 0b17685

Browse files
committed
fix; cleanup
1 parent d7c7671 commit 0b17685

26 files changed

Lines changed: 95 additions & 103 deletions

src/odr/internal/abstract/file.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class DecodedFile {
3434

3535
[[nodiscard]] virtual std::shared_ptr<File> file() const noexcept = 0;
3636

37+
[[nodiscard]] virtual DecoderEngine decoder_engine() const noexcept = 0;
3738
[[nodiscard]] virtual FileType file_type() const noexcept = 0;
3839
[[nodiscard]] virtual FileCategory file_category() const noexcept = 0;
39-
[[nodiscard]] virtual FileMeta file_meta() const noexcept = 0;
40-
[[nodiscard]] virtual DecoderEngine decoder_engine() const noexcept = 0;
4140
[[nodiscard]] virtual std::string_view mimetype() const noexcept = 0;
41+
[[nodiscard]] virtual FileMeta file_meta() const noexcept = 0;
4242

4343
[[nodiscard]] virtual bool password_encrypted() const noexcept {
4444
return false;
@@ -100,6 +100,9 @@ class PdfFile : public DecodedFile {
100100
[[nodiscard]] FileCategory file_category() const noexcept final {
101101
return FileCategory::document;
102102
}
103+
[[nodiscard]] std::string_view mimetype() const noexcept final {
104+
return "application/pdf";
105+
}
103106
};
104107

105108
} // namespace odr::internal::abstract

src/odr/internal/cfb/cfb_file.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@ std::shared_ptr<abstract::File> CfbFile::file() const noexcept {
1212
return m_cfb->file();
1313
}
1414

15-
FileType CfbFile::file_type() const noexcept {
16-
return FileType::compound_file_binary_format;
17-
}
18-
19-
FileMeta CfbFile::file_meta() const noexcept {
20-
return {FileType::compound_file_binary_format, "application/x-cfb", false,
21-
std::nullopt};
22-
}
23-
2415
DecoderEngine CfbFile::decoder_engine() const noexcept {
2516
return DecoderEngine::odr;
2617
}
2718

19+
FileType CfbFile::file_type() const noexcept {
20+
return FileType::compound_file_binary_format;
21+
}
22+
2823
std::string_view CfbFile::mimetype() const noexcept {
2924
return "application/x-cfb";
3025
}
3126

27+
FileMeta CfbFile::file_meta() const noexcept {
28+
return {file_type(), mimetype(), false, std::nullopt};
29+
}
30+
3231
bool CfbFile::is_decodable() const noexcept { return true; }
3332

3433
std::shared_ptr<abstract::Archive> CfbFile::archive() const {

src/odr/internal/cfb/cfb_file.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class CfbFile final : public abstract::ArchiveFile {
2323

2424
[[nodiscard]] std::shared_ptr<abstract::File> file() const noexcept override;
2525

26-
[[nodiscard]] FileType file_type() const noexcept override;
27-
[[nodiscard]] FileMeta file_meta() const noexcept override;
2826
[[nodiscard]] DecoderEngine decoder_engine() const noexcept override;
27+
[[nodiscard]] FileType file_type() const noexcept override;
2928
[[nodiscard]] std::string_view mimetype() const noexcept override;
29+
[[nodiscard]] FileMeta file_meta() const noexcept override;
3030

3131
[[nodiscard]] bool is_decodable() const noexcept override;
3232

src/odr/internal/csv/csv_file.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ std::shared_ptr<abstract::File> CsvFile::file() const noexcept {
1616
return m_file->file();
1717
}
1818

19-
FileType CsvFile::file_type() const noexcept {
20-
return FileType::comma_separated_values;
21-
}
22-
2319
DecoderEngine CsvFile::decoder_engine() const noexcept {
2420
return DecoderEngine::odr;
2521
}
2622

23+
FileType CsvFile::file_type() const noexcept {
24+
return FileType::comma_separated_values;
25+
}
26+
2727
std::string_view CsvFile::mimetype() const noexcept { return "text/csv"; }
2828

2929
FileMeta CsvFile::file_meta() const noexcept {
30-
return {FileType::comma_separated_values, "text/csv", false, std::nullopt};
30+
return {file_type(), mimetype(), false, std::nullopt};
3131
}
3232

3333
bool CsvFile::is_decodable() const noexcept { return false; }

src/odr/internal/csv/csv_file.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class CsvFile final : public abstract::TextFile {
1414

1515
[[nodiscard]] std::shared_ptr<abstract::File> file() const noexcept override;
1616

17-
[[nodiscard]] FileType file_type() const noexcept override;
18-
[[nodiscard]] FileMeta file_meta() const noexcept override;
1917
[[nodiscard]] DecoderEngine decoder_engine() const noexcept override;
18+
[[nodiscard]] FileType file_type() const noexcept override;
2019
[[nodiscard]] std::string_view mimetype() const noexcept override;
20+
[[nodiscard]] FileMeta file_meta() const noexcept override;
2121

2222
[[nodiscard]] bool is_decodable() const noexcept override;
2323

src/odr/internal/json/json_file.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,22 @@ std::shared_ptr<abstract::File> JsonFile::file() const noexcept {
1616
return m_file->file();
1717
}
1818

19-
FileType JsonFile::file_type() const noexcept {
20-
return FileType::javascript_object_notation;
21-
}
22-
23-
FileMeta JsonFile::file_meta() const noexcept {
24-
return {FileType::javascript_object_notation, "application/json", false,
25-
std::nullopt};
26-
}
27-
2819
DecoderEngine JsonFile::decoder_engine() const noexcept {
2920
return DecoderEngine::odr;
3021
}
3122

23+
FileType JsonFile::file_type() const noexcept {
24+
return FileType::javascript_object_notation;
25+
}
26+
3227
std::string_view JsonFile::mimetype() const noexcept {
3328
return "application/json";
3429
}
3530

31+
FileMeta JsonFile::file_meta() const noexcept {
32+
return {file_type(), mimetype(), false, std::nullopt};
33+
}
34+
3635
bool JsonFile::is_decodable() const noexcept { return false; }
3736

3837
} // namespace odr::internal::json

src/odr/internal/json/json_file.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class JsonFile final : public abstract::TextFile {
1414

1515
[[nodiscard]] std::shared_ptr<abstract::File> file() const noexcept override;
1616

17-
[[nodiscard]] FileType file_type() const noexcept override;
18-
[[nodiscard]] FileMeta file_meta() const noexcept override;
1917
[[nodiscard]] DecoderEngine decoder_engine() const noexcept override;
18+
[[nodiscard]] FileType file_type() const noexcept override;
2019
[[nodiscard]] std::string_view mimetype() const noexcept override;
20+
[[nodiscard]] FileMeta file_meta() const noexcept override;
2121

2222
[[nodiscard]] bool is_decodable() const noexcept override;
2323

src/odr/internal/libmagic/libmagic.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <odr/global_params.hpp>
44

5+
#include <memory>
6+
57
#include <magic.h>
68

79
namespace odr::internal {

src/odr/internal/odf/odf_file.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ std::shared_ptr<abstract::File> OpenDocumentFile::file() const noexcept {
3636
return {};
3737
}
3838

39-
FileType OpenDocumentFile::file_type() const noexcept {
40-
return m_file_meta.type;
41-
}
42-
43-
FileMeta OpenDocumentFile::file_meta() const noexcept { return m_file_meta; }
44-
4539
DecoderEngine OpenDocumentFile::decoder_engine() const noexcept {
4640
return DecoderEngine::odr;
4741
}
4842

43+
FileType OpenDocumentFile::file_type() const noexcept {
44+
return m_file_meta.type;
45+
}
46+
4947
std::string_view OpenDocumentFile::mimetype() const noexcept {
5048
return m_file_meta.mimetype;
5149
}
5250

51+
FileMeta OpenDocumentFile::file_meta() const noexcept { return m_file_meta; }
52+
5353
DocumentType OpenDocumentFile::document_type() const {
5454
return m_file_meta.document_meta.value().document_type;
5555
}

src/odr/internal/odf/odf_file.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ class OpenDocumentFile final : public virtual abstract::DocumentFile {
2525

2626
[[nodiscard]] std::shared_ptr<abstract::File> file() const noexcept override;
2727

28-
[[nodiscard]] FileType file_type() const noexcept override;
29-
[[nodiscard]] FileMeta file_meta() const noexcept override;
3028
[[nodiscard]] DecoderEngine decoder_engine() const noexcept override;
29+
[[nodiscard]] FileType file_type() const noexcept override;
3130
[[nodiscard]] std::string_view mimetype() const noexcept override;
31+
[[nodiscard]] FileMeta file_meta() const noexcept override;
3232

3333
[[nodiscard]] DocumentType document_type() const override;
3434
[[nodiscard]] DocumentMeta document_meta() const override;

0 commit comments

Comments
 (0)