create RealmObject class and make isValid a member
This commit is contained in:
parent
75d8f5b759
commit
cec8667e35
|
@ -48,7 +48,7 @@ namespace realm {
|
||||||
const ObjectSchema &get_object_schema() { return *m_object_schema; }
|
const ObjectSchema &get_object_schema() { return *m_object_schema; }
|
||||||
Row row() { return m_row; }
|
Row row() { return m_row; }
|
||||||
|
|
||||||
bool is_valid() { return m_row.is_attached(); }
|
bool is_valid() const { return m_row.is_attached(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SharedRealm m_realm;
|
SharedRealm m_realm;
|
||||||
|
@ -148,8 +148,6 @@ namespace realm {
|
||||||
template <typename ValueType, typename ContextType>
|
template <typename ValueType, typename ContextType>
|
||||||
inline void Object::set_property_value(ContextType ctx, std::string prop_name, ValueType value, bool try_update)
|
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);
|
const Property *prop = m_object_schema->property_for_name(prop_name);
|
||||||
if (!prop) {
|
if (!prop) {
|
||||||
throw InvalidPropertyException(m_object_schema->name, prop_name,
|
throw InvalidPropertyException(m_object_schema->name, prop_name,
|
||||||
|
@ -161,8 +159,6 @@ namespace realm {
|
||||||
template <typename ValueType, typename ContextType>
|
template <typename ValueType, typename ContextType>
|
||||||
inline ValueType Object::get_property_value(ContextType ctx, std::string prop_name)
|
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);
|
const Property *prop = m_object_schema->property_for_name(prop_name);
|
||||||
if (!prop) {
|
if (!prop) {
|
||||||
throw InvalidPropertyException(m_object_schema->name, prop_name,
|
throw InvalidPropertyException(m_object_schema->name, prop_name,
|
||||||
|
@ -176,6 +172,8 @@ namespace realm {
|
||||||
{
|
{
|
||||||
using Accessor = NativeAccessor<ValueType, ContextType>;
|
using Accessor = NativeAccessor<ValueType, ContextType>;
|
||||||
|
|
||||||
|
verify_attached();
|
||||||
|
|
||||||
if (!m_realm->is_in_transaction()) {
|
if (!m_realm->is_in_transaction()) {
|
||||||
throw MutationOutsideTransactionException("Can only set property values within a transaction.");
|
throw MutationOutsideTransactionException("Can only set property values within a transaction.");
|
||||||
}
|
}
|
||||||
|
@ -240,6 +238,8 @@ namespace realm {
|
||||||
{
|
{
|
||||||
using Accessor = NativeAccessor<ValueType, ContextType>;
|
using Accessor = NativeAccessor<ValueType, ContextType>;
|
||||||
|
|
||||||
|
verify_attached();
|
||||||
|
|
||||||
size_t column = property.table_column;
|
size_t column = property.table_column;
|
||||||
if (property.is_nullable && m_row.is_null(column)) {
|
if (property.is_nullable && m_row.is_null(column)) {
|
||||||
return Accessor::null_value(ctx);
|
return Accessor::null_value(ctx);
|
||||||
|
|
Loading…
Reference in New Issue