-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
101 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <odr/internal/common/document.hpp> | ||
|
||
#include <odr/internal/abstract/filesystem.hpp> | ||
#include <odr/internal/common/document_element.hpp> | ||
|
||
#include <utility> | ||
|
||
namespace odr::internal::common { | ||
|
||
Document::Document(FileType file_type, DocumentType document_type, | ||
std::shared_ptr<abstract::ReadableFilesystem> filesystem) | ||
: m_file_type{file_type}, m_document_type{document_type}, | ||
m_filesystem{std::move(filesystem)} {} | ||
|
||
FileType Document::file_type() const noexcept { return m_file_type; } | ||
|
||
DocumentType Document::document_type() const noexcept { | ||
return m_document_type; | ||
} | ||
|
||
std::shared_ptr<abstract::ReadableFilesystem> Document::files() const noexcept { | ||
return m_filesystem; | ||
} | ||
|
||
} // namespace odr::internal::common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef ODR_INTERNAL_COMMON_DOCUMENT_H | ||
#define ODR_INTERNAL_COMMON_DOCUMENT_H | ||
|
||
#include <odr/internal/abstract/document.hpp> | ||
|
||
#include <vector> | ||
|
||
namespace odr::internal::abstract { | ||
class ReadableFilesystem; | ||
} // namespace odr::internal::abstract | ||
|
||
namespace odr::internal::common { | ||
class Element; | ||
|
||
class Document : public abstract::Document { | ||
public: | ||
Document(FileType file_type, DocumentType document_type, | ||
std::shared_ptr<abstract::ReadableFilesystem> files); | ||
|
||
[[nodiscard]] FileType file_type() const noexcept final; | ||
[[nodiscard]] DocumentType document_type() const noexcept final; | ||
|
||
[[nodiscard]] std::shared_ptr<abstract::ReadableFilesystem> | ||
files() const noexcept final; | ||
|
||
protected: | ||
FileType m_file_type; | ||
DocumentType m_document_type; | ||
|
||
std::shared_ptr<abstract::ReadableFilesystem> m_filesystem; | ||
|
||
friend class Element; | ||
}; | ||
|
||
template <typename element_t> class TemplateDocument : public Document { | ||
public: | ||
TemplateDocument(FileType file_type, DocumentType document_type, | ||
std::shared_ptr<abstract::ReadableFilesystem> files) | ||
: Document(file_type, document_type, std::move(files)) {} | ||
|
||
[[nodiscard]] abstract::Element *root_element() const final { | ||
return m_root_element; | ||
} | ||
|
||
void register_element_(std::unique_ptr<element_t> element) { | ||
m_elements.push_back(std::move(element)); | ||
} | ||
|
||
protected: | ||
std::vector<std::unique_ptr<element_t>> m_elements; | ||
element_t *m_root_element{}; | ||
}; | ||
|
||
} // namespace odr::internal::common | ||
|
||
#endif // ODR_INTERNAL_COMMON_DOCUMENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.