Skip to content

Commit

Permalink
revert element id
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Dec 3, 2023
1 parent e602a30 commit 8357a65
Show file tree
Hide file tree
Showing 32 changed files with 947 additions and 1,405 deletions.
219 changes: 93 additions & 126 deletions src/odr/document_element.cpp

Large diffs are not rendered by default.

36 changes: 11 additions & 25 deletions src/odr/document_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ class Circle;
class CustomShape;
class Image;

using ElementIdentifier = std::uint64_t;
using ColumnIndex = std::uint32_t;
using RowIndex = std::uint32_t;
using InternalElement =
std::pair<internal::abstract::Element *, ElementIdentifier>;
template <typename T>
using TypedInternalElement = std::pair<T *, ElementIdentifier>;

enum class ElementType {
none,

Expand Down Expand Up @@ -133,7 +125,7 @@ enum class ValueType {
class Element {
public:
Element();
Element(const internal::abstract::Document *, InternalElement);
Element(const internal::abstract::Document *, internal::abstract::Element *);

bool operator==(const Element &rhs) const;
bool operator!=(const Element &rhs) const;
Expand Down Expand Up @@ -174,11 +166,9 @@ class Element {

protected:
const internal::abstract::Document *m_document{nullptr};
InternalElement m_element;
internal::abstract::Element *m_element{nullptr};

bool exists_() const;
internal::abstract::Element *element_() const;
ElementIdentifier id_() const;
};

class ElementIterator {
Expand All @@ -190,7 +180,8 @@ class ElementIterator {
using iterator_category = std::forward_iterator_tag;

ElementIterator();
ElementIterator(const internal::abstract::Document *, InternalElement);
ElementIterator(const internal::abstract::Document *,
internal::abstract::Element *);

bool operator==(const ElementIterator &rhs) const;
bool operator!=(const ElementIterator &rhs) const;
Expand All @@ -202,11 +193,9 @@ class ElementIterator {

private:
const internal::abstract::Document *m_document{nullptr};
InternalElement m_element;
internal::abstract::Element *m_element{nullptr};

bool exists_() const;
internal::abstract::Element *element_() const;
ElementIdentifier id_() const;
};

class ElementRange {
Expand All @@ -227,9 +216,8 @@ template <typename T> class TypedElement : public Element {
public:
TypedElement() = default;
TypedElement(const internal::abstract::Document *document,
InternalElement element)
: Element(document, element), m_typed_element{
dynamic_cast<T *>(element.first)} {}
internal::abstract::Element *element)
: Element(document, element), m_element{dynamic_cast<T *>(element)} {}

bool operator==(const TypedElement &rhs) const {
return m_element == rhs.m_element;
Expand All @@ -239,9 +227,7 @@ template <typename T> class TypedElement : public Element {
}

protected:
T *m_typed_element;

T *element_() const { return m_typed_element; }
T *m_element;
};

class TextRoot final : public TypedElement<internal::abstract::TextRoot> {
Expand Down Expand Up @@ -274,9 +260,9 @@ class Sheet final : public TypedElement<internal::abstract::Sheet> {
[[nodiscard]] TableDimensions
content(std::optional<TableDimensions> range) const;

[[nodiscard]] TableColumn column(ColumnIndex column) const;
[[nodiscard]] TableRow row(RowIndex row) const;
[[nodiscard]] TableCell cell(ColumnIndex column, RowIndex row) const;
[[nodiscard]] TableColumn column(std::uint32_t column) const;
[[nodiscard]] TableRow row(std::uint32_t row) const;
[[nodiscard]] TableCell cell(std::uint32_t column, std::uint32_t row) const;

[[nodiscard]] ElementRange shapes() const;

Expand Down
3 changes: 1 addition & 2 deletions src/odr/internal/abstract/document.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class Document {
files() const noexcept = 0;

/// \return cursor to the root element of the document.
[[nodiscard]] virtual std::pair<Element *, ElementIdentifier>
root_element() const = 0;
[[nodiscard]] virtual Element *root_element() const = 0;
};

} // namespace odr::internal::abstract
Expand Down
Loading

0 comments on commit 8357a65

Please sign in to comment.