Skip to content

Commit

Permalink
modernize (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand authored Dec 31, 2024
1 parent 00899d4 commit dac17e4
Show file tree
Hide file tree
Showing 146 changed files with 326 additions and 646 deletions.
5 changes: 1 addition & 4 deletions src/odr/archive.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_ARCHIVE_HPP
#define ODR_ARCHIVE_HPP
#pragma once

#include <memory>
#include <string>
Expand Down Expand Up @@ -27,5 +26,3 @@ class Archive {
};

} // namespace odr

#endif // ODR_ARCHIVE_HPP
7 changes: 4 additions & 3 deletions src/odr/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <odr/internal/common/path.hpp>

#include <stdexcept>
#include <utility>

namespace odr {

Expand All @@ -25,11 +24,13 @@ bool Document::savable(const bool encrypted) const noexcept {
return m_impl->is_savable(encrypted);
}

void Document::save(const std::string &path) const { m_impl->save(path); }
void Document::save(const std::string &path) const {
m_impl->save(internal::common::Path(path));
}

void Document::save(const std::string &path,
const std::string &password) const {
m_impl->save(path, password.c_str());
m_impl->save(internal::common::Path(path), password.c_str());
}

FileType Document::file_type() const noexcept { return m_impl->file_type(); }
Expand Down
5 changes: 1 addition & 4 deletions src/odr/document.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_DOCUMENT_HPP
#define ODR_DOCUMENT_HPP
#pragma once

#include <memory>
#include <string>
Expand Down Expand Up @@ -40,5 +39,3 @@ class Document final {
};

} // namespace odr

#endif // ODR_DOCUMENT_HPP
5 changes: 1 addition & 4 deletions src/odr/document_element.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_DOCUMENT_ELEMENT_HPP
#define ODR_DOCUMENT_ELEMENT_HPP
#pragma once

#include <cstdint>
#include <memory>
Expand Down Expand Up @@ -533,5 +532,3 @@ class Image final : public TypedElement<internal::abstract::Image> {
};

} // namespace odr

#endif // ODR_DOCUMENT_ELEMENT_HPP
5 changes: 1 addition & 4 deletions src/odr/document_path.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_DOCUMENT_PATH_HPP
#define ODR_DOCUMENT_PATH_HPP
#pragma once

#include <cstdint>
#include <string>
Expand Down Expand Up @@ -78,5 +77,3 @@ class DocumentPath final {
};

} // namespace odr

#endif // ODR_DOCUMENT_PATH_HPP
5 changes: 1 addition & 4 deletions src/odr/exceptions.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_EXCEPTIONS_HPP
#define ODR_EXCEPTIONS_HPP
#pragma once

#include <stdexcept>

Expand Down Expand Up @@ -149,5 +148,3 @@ struct UnknownDocumentType final : public std::runtime_error {
};

} // namespace odr

#endif // ODR_EXCEPTIONS_HPP
5 changes: 1 addition & 4 deletions src/odr/file.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_FILE_HPP
#define ODR_FILE_HPP
#pragma once

#include <cstdint>
#include <memory>
Expand Down Expand Up @@ -289,5 +288,3 @@ class PdfFile final : public DecodedFile {
};

} // namespace odr

#endif // ODR_FILE_HPP
11 changes: 6 additions & 5 deletions src/odr/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,24 @@ Filesystem::Filesystem(
Filesystem::operator bool() const { return m_impl.operator bool(); }

bool Filesystem::exists(const std::string &path) const {
return m_impl ? m_impl->exists(path) : false;
return m_impl ? m_impl->exists(internal::common::Path(path)) : false;
}

bool Filesystem::is_file(const std::string &path) const {
return m_impl ? m_impl->is_file(path) : false;
return m_impl ? m_impl->is_file(internal::common::Path(path)) : false;
}

bool Filesystem::is_directory(const std::string &path) const {
return m_impl ? m_impl->is_directory(path) : false;
return m_impl ? m_impl->is_directory(internal::common::Path(path)) : false;
}

FileWalker Filesystem::file_walker(const std::string &path) const {
return m_impl ? FileWalker(m_impl->file_walker(path)) : FileWalker();
return m_impl ? FileWalker(m_impl->file_walker(internal::common::Path(path)))
: FileWalker();
}

File Filesystem::open(const std::string &path) const {
return m_impl ? File(m_impl->open(path)) : File();
return m_impl ? File(m_impl->open(internal::common::Path(path))) : File();
}

} // namespace odr
5 changes: 1 addition & 4 deletions src/odr/filesystem.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_FILESYSTEM_HPP
#define ODR_FILESYSTEM_HPP
#pragma once

#include <cstdint>
#include <memory>
Expand Down Expand Up @@ -60,5 +59,3 @@ class Filesystem {
};

} // namespace odr

#endif // ODR_FILESYSTEM_HPP
5 changes: 1 addition & 4 deletions src/odr/html.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_HTML_HPP
#define ODR_HTML_HPP
#pragma once

#include <odr/document.hpp>
#include <odr/file.hpp>
Expand Down Expand Up @@ -202,5 +201,3 @@ void edit(const Document &document, const char *diff);
} // namespace html

} // namespace odr

#endif // ODR_HTML_HPP
5 changes: 1 addition & 4 deletions src/odr/html_service.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_HTML_SERVICE_HPP
#define ODR_HTML_SERVICE_HPP
#pragma once

#include <functional>
#include <iosfwd>
Expand Down Expand Up @@ -61,5 +60,3 @@ class HtmlFragment final {
};

} // namespace odr

#endif // ODR_HTML_SERVICE_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/abstract/archive.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_ABSTRACT_ARCHIVE_HPP
#define ODR_INTERNAL_ABSTRACT_ARCHIVE_HPP
#pragma once

#include <memory>

Expand All @@ -20,5 +19,3 @@ class Archive {
};

} // namespace odr::internal::abstract

#endif // ODR_INTERNAL_ABSTRACT_ARCHIVE_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/abstract/document.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_ABSTRACT_DOCUMENT_HPP
#define ODR_INTERNAL_ABSTRACT_DOCUMENT_HPP
#pragma once

#include <odr/document_element.hpp>

Expand Down Expand Up @@ -52,5 +51,3 @@ class Document {
};

} // namespace odr::internal::abstract

#endif // ODR_INTERNAL_ABSTRACT_DOCUMENT_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/abstract/document_element.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_ABSTRACT_DOCUMENT_ELEMENT_HPP
#define ODR_INTERNAL_ABSTRACT_DOCUMENT_ELEMENT_HPP
#pragma once

#include <odr/document_element.hpp>

Expand Down Expand Up @@ -297,5 +296,3 @@ class Image : public virtual Element {
};

} // namespace odr::internal::abstract

#endif // ODR_INTERNAL_ABSTRACT_DOCUMENT_ELEMENT_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/abstract/file.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_ABSTRACT_FILE_HPP
#define ODR_INTERNAL_ABSTRACT_FILE_HPP
#pragma once

#include <odr/file.hpp>

Expand Down Expand Up @@ -97,5 +96,3 @@ class PdfFile : public DecodedFile {
};

} // namespace odr::internal::abstract

#endif // ODR_INTERNAL_ABSTRACT_FILE_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/abstract/filesystem.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_ABSTRACT_FILESYSTEM_HPP
#define ODR_INTERNAL_ABSTRACT_FILESYSTEM_HPP
#pragma once

#include <cstdint>
#include <memory>
Expand Down Expand Up @@ -65,5 +64,3 @@ class WriteableFilesystem {
class Filesystem : public ReadableFilesystem, public WriteableFilesystem {};

} // namespace odr::internal::abstract

#endif // ODR_INTERNAL_ABSTRACT_FILESYSTEM_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/abstract/html_service.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_ABSTRACT_HTML_SERVICE_HPP
#define ODR_INTERNAL_ABSTRACT_HTML_SERVICE_HPP
#pragma once

#include <odr/html_service.hpp>

Expand Down Expand Up @@ -42,5 +41,3 @@ class HtmlFragment {
};

} // namespace odr::internal::abstract

#endif // ODR_INTERNAL_ABSTRACT_HTML_SERVICE_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/abstract/sheet_element.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_ABSTRACT_SHEET_ELEMENT_HPP
#define ODR_INTERNAL_ABSTRACT_SHEET_ELEMENT_HPP
#pragma once

#include <odr/internal/abstract/document_element.hpp>

Expand Down Expand Up @@ -47,5 +46,3 @@ class SheetCell : public virtual Element {
};

} // namespace odr::internal::abstract

#endif // ODR_INTERNAL_ABSTRACT_SHEET_ELEMENT_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/cfb/cfb_archive.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_CFB_ARCHIVE_HPP
#define ODR_INTERNAL_CFB_ARCHIVE_HPP
#pragma once

#include <odr/internal/abstract/archive.hpp>
#include <odr/internal/common/file.hpp>
Expand Down Expand Up @@ -43,5 +42,3 @@ class CfbArchive final : public abstract::Archive {
};

} // namespace odr::internal::cfb

#endif // ODR_INTERNAL_CFB_ARCHIVE_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/cfb/cfb_file.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_CFB_FILE_HPP
#define ODR_INTERNAL_CFB_FILE_HPP
#pragma once

#include <odr/internal/abstract/file.hpp>

Expand Down Expand Up @@ -35,5 +34,3 @@ class CfbFile final : public abstract::ArchiveFile {
};

} // namespace odr::internal::cfb

#endif // ODR_INTERNAL_CFB_FILE_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/cfb/cfb_impl.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_CFB_IMPL_HPP
#define ODR_INTERNAL_CFB_IMPL_HPP
#pragma once

#include <cstdint>
#include <functional>
Expand Down Expand Up @@ -181,5 +180,3 @@ class PropertySetStream final {
};

} // namespace odr::internal::cfb::impl

#endif // ODR_INTERNAL_CFB_IMPL_HPP
9 changes: 3 additions & 6 deletions src/odr/internal/cfb/cfb_util.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_CFB_UTIL_HPP
#define ODR_INTERNAL_CFB_UTIL_HPP
#pragma once

#include <odr/file.hpp>

Expand Down Expand Up @@ -45,8 +44,8 @@ class Archive final : public std::enable_shared_from_this<Archive> {
: m_parent{&parent}, m_entry{&entry}, m_path{"/"} {}
Entry(const Archive &parent, const impl::CompoundFileEntry &entry,
const common::Path &parent_path)
: m_parent{&parent}, m_entry{&entry}, m_path{parent_path.join(name())} {
}
: m_parent{&parent}, m_entry{&entry},
m_path{parent_path.join(common::Path(name()))} {}
~Entry() = default;
Entry &operator=(const Entry &) = default;
Entry &operator=(Entry &&) noexcept = default;
Expand Down Expand Up @@ -136,5 +135,3 @@ class Archive final : public std::enable_shared_from_this<Archive> {
};

} // namespace odr::internal::cfb::util

#endif // ODR_INTERNAL_CFB_UTIL_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/common/document.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_COMMON_DOCUMENT_HPP
#define ODR_INTERNAL_COMMON_DOCUMENT_HPP
#pragma once

#include <odr/internal/abstract/document.hpp>

Expand Down Expand Up @@ -52,5 +51,3 @@ template <typename element_t> class TemplateDocument : public Document {
};

} // namespace odr::internal::common

#endif // ODR_INTERNAL_COMMON_DOCUMENT_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/common/document_element.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_COMMON_DOCUMENT_ELEMENT_HPP
#define ODR_INTERNAL_COMMON_DOCUMENT_ELEMENT_HPP
#pragma once

#include <odr/internal/abstract/document_element.hpp>

Expand Down Expand Up @@ -59,5 +58,3 @@ class Table : public virtual Element, public abstract::Table {
};

} // namespace odr::internal::common

#endif // ODR_INTERNAL_COMMON_DOCUMENT_ELEMENT_HPP
5 changes: 1 addition & 4 deletions src/odr/internal/common/file.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_COMMON_FILE_HPP
#define ODR_INTERNAL_COMMON_FILE_HPP
#pragma once

#include <odr/internal/abstract/file.hpp>
#include <odr/internal/common/path.hpp>
Expand Down Expand Up @@ -52,5 +51,3 @@ class MemoryFile final : public abstract::File {
};

} // namespace odr::internal::common

#endif // ODR_INTERNAL_COMMON_FILE_HPP
3 changes: 1 addition & 2 deletions src/odr/internal/common/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <fstream>
#include <map>
#include <system_error>
#include <utility>

namespace odr::internal::common {

Expand Down Expand Up @@ -65,7 +64,7 @@ class SystemFileWalker final : public abstract::FileWalker {
SystemFilesystem::SystemFilesystem(Path root) : m_root{std::move(root)} {}

Path SystemFilesystem::to_system_path_(const Path &path) const {
return m_root.join(path.rebase("/"));
return m_root.join(path.rebase(Path("/")));
}

bool SystemFilesystem::exists(const Path &path) const {
Expand Down
5 changes: 1 addition & 4 deletions src/odr/internal/common/filesystem.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ODR_INTERNAL_COMMON_FILESYSTEM_HPP
#define ODR_INTERNAL_COMMON_FILESYSTEM_HPP
#pragma once

#include <odr/internal/abstract/filesystem.hpp>
#include <odr/internal/common/path.hpp>
Expand Down Expand Up @@ -74,5 +73,3 @@ class VirtualFilesystem final : public abstract::Filesystem {
};

} // namespace odr::internal::common

#endif // ODR_INTERNAL_COMMON_FILESYSTEM_HPP
Loading

0 comments on commit dac17e4

Please sign in to comment.