From 1390d6a76e0162b87d102d04b1f82c403919df78 Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Mon, 2 Jul 2018 11:09:41 +1200 Subject: [PATCH] unimplemented functions in range and path --- source/utils/path.cpp | 16 ++++++++++++++++ source/worksheet/range.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/source/utils/path.cpp b/source/utils/path.cpp index e846a6e5..b67ab977 100644 --- a/source/utils/path.cpp +++ b/source/utils/path.cpp @@ -141,6 +141,22 @@ path::path(const std::string &path_string) { } +path::path(const std::string &path_string, char sep) + : internal_(path_string) +{ + char curr_sep = guess_separator(); + if (curr_sep != sep) + { + for (char& c : internal_) // simple find and replace + { + if (c == curr_sep) + { + c = sep; + } + } + } +} + // general attributes bool path::is_relative() const diff --git a/source/worksheet/range.cpp b/source/worksheet/range.cpp index 1226cc0b..7649edc7 100644 --- a/source/worksheet/range.cpp +++ b/source/worksheet/range.cpp @@ -69,6 +69,11 @@ cell_vector range::operator[](std::size_t index) return vector(index); } +const cell_vector range::operator[](std::size_t index) const +{ + return vector(index); +} + const worksheet &range::target_worksheet() const { return ws_; @@ -112,6 +117,22 @@ cell_vector range::vector(std::size_t vector_index) return cell_vector(ws_, cursor, ref_, order_, skip_null_, false); } +const cell_vector range::vector(std::size_t vector_index) const +{ + auto cursor = ref_.top_left(); + + if (order_ == major_order::row) + { + cursor.row(cursor.row() + static_cast(vector_index)); + } + else + { + cursor.column_index(cursor.column_index() + static_cast(vector_index)); + } + + return cell_vector(ws_, cursor, ref_, order_, skip_null_, false); +} + bool range::contains(const cell_reference &ref) { return ref_.top_left().column_index() <= ref.column_index() @@ -188,6 +209,11 @@ cell range::cell(const cell_reference &ref) return (*this)[ref.row() - 1][ref.column().index - 1]; } +const cell range::cell(const cell_reference &ref) const +{ + return (*this)[ref.row() - 1][ref.column().index - 1]; +} + cell_vector range::front() { return *begin();