From d7fe9f9fb840b6fc8d9591857f63be2b34dd868a Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sat, 8 Aug 2015 15:31:41 -0700 Subject: [PATCH] Expose the object class name from Results --- results.cpp | 9 ++++++++- results.hpp | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/results.cpp b/results.cpp index 42956d37..0ad41d39 100644 --- a/results.cpp +++ b/results.cpp @@ -160,7 +160,9 @@ size_t Results::index_of(Row const& row) throw DetatchedAccessorException{}; } if (m_table && row.get_table() != m_table) { - throw IncorrectTableException{m_table, row.get_table()}; + throw IncorrectTableException{ + ObjectStore::object_type_for_table_name(m_table->get_name()), + ObjectStore::object_type_for_table_name(row.get_table()->get_name())}; } return index_of(row.get_index()); } @@ -310,6 +312,11 @@ TableView Results::get_tableview() REALM_UNREACHABLE(); } +StringData Results::get_object_type() const noexcept +{ + return ObjectStore::object_type_for_table_name(m_table->get_name()); +} + Results Results::sort(realm::SortOrder&& sort) const { return Results(m_realm, get_query(), std::move(sort)); diff --git a/results.hpp b/results.hpp index 895c084c..b239f440 100644 --- a/results.hpp +++ b/results.hpp @@ -65,6 +65,9 @@ public: // Get a tableview containing the same rows as this Results TableView get_tableview(); + // Get the object type which will be returned by get() + StringData get_object_type() const noexcept; + // Get the size of this results // Can be either O(1) or O(N) depending on the state of things size_t size(); @@ -128,8 +131,8 @@ public: // The input Row object belongs to a different table struct IncorrectTableException { - const Table* expected; - const Table* actual; + StringData expected; + StringData actual; }; // The requested aggregate operation is not supported for the column type