Skip to content

Commit 21a56fa

Browse files
committed
internal renamings
1 parent 0003faf commit 21a56fa

16 files changed

Lines changed: 37 additions & 32 deletions

src/odr/archive.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Archive::Archive(std::shared_ptr<internal::abstract::Archive> impl)
1919
Filesystem Archive::as_filesystem() const {
2020
return Filesystem(
2121
std::dynamic_pointer_cast<internal::abstract::ReadableFilesystem>(
22-
m_impl->filesystem()));
22+
m_impl->as_filesystem()));
2323
}
2424

2525
void Archive::save(std::ostream &out) const { m_impl->save(out); }

src/odr/document.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <odr/document.hpp>
22

33
#include <odr/document_element.hpp>
4+
#include <odr/exceptions.hpp>
45
#include <odr/file.hpp>
56
#include <odr/filesystem.hpp>
67

@@ -14,7 +15,7 @@ namespace odr {
1415
Document::Document(std::shared_ptr<internal::abstract::Document> impl)
1516
: m_impl{std::move(impl)} {
1617
if (!m_impl) {
17-
throw std::runtime_error("document is null");
18+
throw NullPointerError("document is null");
1819
}
1920
}
2021

@@ -44,7 +45,7 @@ Element Document::root_element() const {
4445
}
4546

4647
Filesystem Document::as_filesystem() const {
47-
return Filesystem(m_impl->files());
48+
return Filesystem(m_impl->as_filesystem());
4849
}
4950

5051
} // namespace odr

src/odr/internal/abstract/archive.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Archive {
1313
public:
1414
virtual ~Archive() = default;
1515

16-
[[nodiscard]] virtual std::shared_ptr<Filesystem> filesystem() const = 0;
16+
[[nodiscard]] virtual std::shared_ptr<Filesystem> as_filesystem() const = 0;
1717

1818
virtual void save(std::ostream &out) const = 0;
1919
};

src/odr/internal/abstract/document.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Document {
4444

4545
/// \return the underlying filesystem of the document.
4646
[[nodiscard]] virtual std::shared_ptr<ReadableFilesystem>
47-
files() const noexcept = 0;
47+
as_filesystem() const noexcept = 0;
4848

4949
/// \return cursor to the root element of the document.
5050
[[nodiscard]] virtual Element *root_element() const = 0;

src/odr/internal/cfb/cfb_archive.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace odr::internal::cfb {
1818
CfbArchive::CfbArchive(std::shared_ptr<util::Archive> archive)
1919
: m_cfb{std::move(archive)} {}
2020

21-
std::shared_ptr<abstract::Filesystem> CfbArchive::filesystem() const {
21+
std::shared_ptr<abstract::Filesystem> CfbArchive::as_filesystem() const {
2222
auto filesystem = std::make_shared<common::VirtualFilesystem>();
2323

2424
for (const auto &e : *m_cfb) {

src/odr/internal/cfb/cfb_archive.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class CfbArchive final : public abstract::Archive {
3333
public:
3434
explicit CfbArchive(std::shared_ptr<util::Archive> archive);
3535

36-
[[nodiscard]] std::shared_ptr<abstract::Filesystem> filesystem() const final;
36+
[[nodiscard]] std::shared_ptr<abstract::Filesystem>
37+
as_filesystem() const final;
3738

3839
void save(std::ostream &out) const final;
3940

src/odr/internal/common/document.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ DocumentType Document::document_type() const noexcept {
1818
return m_document_type;
1919
}
2020

21-
std::shared_ptr<abstract::ReadableFilesystem> Document::files() const noexcept {
21+
std::shared_ptr<abstract::ReadableFilesystem>
22+
Document::as_filesystem() const noexcept {
2223
return m_filesystem;
2324
}
2425

src/odr/internal/common/document.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Document : public abstract::Document {
2020
[[nodiscard]] DocumentType document_type() const noexcept final;
2121

2222
[[nodiscard]] std::shared_ptr<abstract::ReadableFilesystem>
23-
files() const noexcept final;
23+
as_filesystem() const noexcept final;
2424

2525
protected:
2626
FileType m_file_type;

src/odr/internal/odf/odf_crypto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ odf::decrypt(const std::shared_ptr<abstract::ReadableFilesystem> &filesystem,
181181

182182
auto memory_file =
183183
std::make_shared<common::MemoryFile>(std::move(decrypt));
184-
return zip::ZipFile(memory_file).archive()->filesystem();
184+
return zip::ZipFile(memory_file).archive()->as_filesystem();
185185
} catch (...) {
186186
throw WrongPasswordError();
187187
}

src/odr/internal/odf/odf_element.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,11 @@ GraphicStyle CustomShape::style(const abstract::Document *document) const {
437437

438438
bool Image::is_internal(const abstract::Document *document) const {
439439
auto doc = document_(document);
440-
if (!doc || !doc->files()) {
440+
if (!doc || !doc->as_filesystem()) {
441441
return false;
442442
}
443443
try {
444-
return doc->files()->is_file(common::Path(href(document)));
444+
return doc->as_filesystem()->is_file(common::Path(href(document)));
445445
} catch (...) {
446446
}
447447
return false;
@@ -452,7 +452,7 @@ std::optional<odr::File> Image::file(const abstract::Document *document) const {
452452
if (!doc || !is_internal(document)) {
453453
return {};
454454
}
455-
return File(doc->files()->open(common::Path(href(document))));
455+
return File(doc->as_filesystem()->open(common::Path(href(document))));
456456
}
457457

458458
std::string Image::href(const abstract::Document *) const {

0 commit comments

Comments
 (0)