Expose the object class name from Results

This commit is contained in:
Thomas Goyne 2015-08-08 15:31:41 -07:00 committed by Ari Lazier
parent d1175fe364
commit d7fe9f9fb8
2 changed files with 13 additions and 3 deletions

View File

@ -160,7 +160,9 @@ size_t Results::index_of(Row const& row)
throw DetatchedAccessorException{}; throw DetatchedAccessorException{};
} }
if (m_table && row.get_table() != m_table) { 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()); return index_of(row.get_index());
} }
@ -310,6 +312,11 @@ TableView Results::get_tableview()
REALM_UNREACHABLE(); 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 Results Results::sort(realm::SortOrder&& sort) const
{ {
return Results(m_realm, get_query(), std::move(sort)); return Results(m_realm, get_query(), std::move(sort));

View File

@ -65,6 +65,9 @@ public:
// Get a tableview containing the same rows as this Results // Get a tableview containing the same rows as this Results
TableView get_tableview(); 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 // Get the size of this results
// Can be either O(1) or O(N) depending on the state of things // Can be either O(1) or O(N) depending on the state of things
size_t size(); size_t size();
@ -128,8 +131,8 @@ public:
// The input Row object belongs to a different table // The input Row object belongs to a different table
struct IncorrectTableException { struct IncorrectTableException {
const Table* expected; StringData expected;
const Table* actual; StringData actual;
}; };
// The requested aggregate operation is not supported for the column type // The requested aggregate operation is not supported for the column type