From cec8667e35e95f82a3d6f1a5329d3ff090b3f457 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Tue, 26 Apr 2016 16:30:04 -0700 Subject: [PATCH] create RealmObject class and make isValid a member --- src/object_accessor.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/object_accessor.hpp b/src/object_accessor.hpp index fc86a62c..9727fe45 100644 --- a/src/object_accessor.hpp +++ b/src/object_accessor.hpp @@ -48,7 +48,7 @@ namespace realm { const ObjectSchema &get_object_schema() { return *m_object_schema; } Row row() { return m_row; } - bool is_valid() { return m_row.is_attached(); } + bool is_valid() const { return m_row.is_attached(); } private: SharedRealm m_realm; @@ -147,9 +147,7 @@ namespace realm { // template inline void Object::set_property_value(ContextType ctx, std::string prop_name, ValueType value, bool try_update) - { - verify_attached(); - + { const Property *prop = m_object_schema->property_for_name(prop_name); if (!prop) { throw InvalidPropertyException(m_object_schema->name, prop_name, @@ -161,8 +159,6 @@ namespace realm { template inline ValueType Object::get_property_value(ContextType ctx, std::string prop_name) { - verify_attached(); - const Property *prop = m_object_schema->property_for_name(prop_name); if (!prop) { throw InvalidPropertyException(m_object_schema->name, prop_name, @@ -176,6 +172,8 @@ namespace realm { { using Accessor = NativeAccessor; + verify_attached(); + if (!m_realm->is_in_transaction()) { throw MutationOutsideTransactionException("Can only set property values within a transaction."); } @@ -240,6 +238,8 @@ namespace realm { { using Accessor = NativeAccessor; + verify_attached(); + size_t column = property.table_column; if (property.is_nullable && m_row.is_null(column)) { return Accessor::null_value(ctx);