USe more const refs to avoid copies
This commit is contained in:
parent
dbac77f69b
commit
7de20ea3a6
|
@ -19,8 +19,8 @@
|
||||||
#include "object_store.hpp"
|
#include "object_store.hpp"
|
||||||
|
|
||||||
#include <realm/group.hpp>
|
#include <realm/group.hpp>
|
||||||
#include <realm/table.hpp>
|
|
||||||
#include <realm/link_view.hpp>
|
#include <realm/link_view.hpp>
|
||||||
|
#include <realm/table.hpp>
|
||||||
#include <realm/table_view.hpp>
|
#include <realm/table_view.hpp>
|
||||||
#include <realm/util/assert.hpp>
|
#include <realm/util/assert.hpp>
|
||||||
|
|
||||||
|
@ -479,41 +479,41 @@ InvalidSchemaVersionException::InvalidSchemaVersionException(uint64_t old_versio
|
||||||
m_what = "Provided schema version " + std::to_string(old_version) + " is less than last set version " + std::to_string(new_version) + ".";
|
m_what = "Provided schema version " + std::to_string(old_version) + " is less than last set version " + std::to_string(new_version) + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
DuplicatePrimaryKeyValueException::DuplicatePrimaryKeyValueException(std::string object_type, Property const& property) :
|
DuplicatePrimaryKeyValueException::DuplicatePrimaryKeyValueException(std::string const& object_type, Property const& property) :
|
||||||
m_object_type(object_type), m_property(property)
|
m_object_type(object_type), m_property(property)
|
||||||
{
|
{
|
||||||
m_what = "Primary key property '" + property.name + "' has duplicate values after migration.";
|
m_what = "Primary key property '" + property.name + "' has duplicate values after migration.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SchemaValidationException::SchemaValidationException(std::vector<ObjectSchemaValidationException> errors) :
|
SchemaValidationException::SchemaValidationException(std::vector<ObjectSchemaValidationException> const& errors) :
|
||||||
m_validation_errors(errors)
|
m_validation_errors(errors)
|
||||||
{
|
{
|
||||||
m_what ="Migration is required due to the following errors: ";
|
m_what ="Migration is required due to the following errors: ";
|
||||||
for (auto error : errors) {
|
for (auto const& error : errors) {
|
||||||
m_what += std::string("\n- ") + error.what();
|
m_what += std::string("\n- ") + error.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyTypeNotIndexableException::PropertyTypeNotIndexableException(std::string object_type, Property const& property) :
|
PropertyTypeNotIndexableException::PropertyTypeNotIndexableException(std::string const& object_type, Property const& property) :
|
||||||
ObjectSchemaPropertyException(object_type, property)
|
ObjectSchemaPropertyException(object_type, property)
|
||||||
{
|
{
|
||||||
m_what = "Can't index property " + object_type + "." + property.name + ": indexing a property of type '" + string_for_property_type(property.type) + "' is currently not supported";
|
m_what = "Can't index property " + object_type + "." + property.name + ": indexing a property of type '" + string_for_property_type(property.type) + "' is currently not supported";
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtraPropertyException::ExtraPropertyException(std::string object_type, Property const& property) :
|
ExtraPropertyException::ExtraPropertyException(std::string const& object_type, Property const& property) :
|
||||||
ObjectSchemaPropertyException(object_type, property)
|
ObjectSchemaPropertyException(object_type, property)
|
||||||
{
|
{
|
||||||
m_what = "Property '" + property.name + "' has been added to latest object model.";
|
m_what = "Property '" + property.name + "' has been added to latest object model.";
|
||||||
}
|
}
|
||||||
|
|
||||||
MissingPropertyException::MissingPropertyException(std::string object_type, Property const& property) :
|
MissingPropertyException::MissingPropertyException(std::string const& object_type, Property const& property) :
|
||||||
ObjectSchemaPropertyException(object_type, property)
|
ObjectSchemaPropertyException(object_type, property)
|
||||||
{
|
{
|
||||||
m_what = "Property '" + property.name + "' is missing from latest object model.";
|
m_what = "Property '" + property.name + "' is missing from latest object model.";
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidNullabilityException::InvalidNullabilityException(std::string object_type, Property const& property) :
|
InvalidNullabilityException::InvalidNullabilityException(std::string const& object_type, Property const& property) :
|
||||||
ObjectSchemaPropertyException(object_type, property)
|
ObjectSchemaPropertyException(object_type, property)
|
||||||
{
|
{
|
||||||
#if REALM_NULL_STRINGS == 1
|
#if REALM_NULL_STRINGS == 1
|
||||||
|
@ -532,13 +532,13 @@ InvalidNullabilityException::InvalidNullabilityException(std::string object_type
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MissingObjectTypeException::MissingObjectTypeException(std::string object_type, Property const& property) :
|
MissingObjectTypeException::MissingObjectTypeException(std::string const& object_type, Property const& property) :
|
||||||
ObjectSchemaPropertyException(object_type, property)
|
ObjectSchemaPropertyException(object_type, property)
|
||||||
{
|
{
|
||||||
m_what = "Target type '" + property.object_type + "' doesn't exist for property '" + property.name + "'.";
|
m_what = "Target type '" + property.object_type + "' doesn't exist for property '" + property.name + "'.";
|
||||||
}
|
}
|
||||||
|
|
||||||
MismatchedPropertiesException::MismatchedPropertiesException(std::string object_type, Property const& old_property, Property const& new_property) :
|
MismatchedPropertiesException::MismatchedPropertiesException(std::string const& object_type, Property const& old_property, Property const& new_property) :
|
||||||
ObjectSchemaValidationException(object_type), m_old_property(old_property), m_new_property(new_property)
|
ObjectSchemaValidationException(object_type), m_old_property(old_property), m_new_property(new_property)
|
||||||
{
|
{
|
||||||
if (new_property.type != old_property.type) {
|
if (new_property.type != old_property.type) {
|
||||||
|
@ -553,7 +553,7 @@ MismatchedPropertiesException::MismatchedPropertiesException(std::string object_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangedPrimaryKeyException::ChangedPrimaryKeyException(std::string object_type, std::string old_primary, std::string new_primary) : ObjectSchemaValidationException(object_type), m_old_primary(old_primary), m_new_primary(new_primary)
|
ChangedPrimaryKeyException::ChangedPrimaryKeyException(std::string const& object_type, std::string const& old_primary, std::string const& new_primary) : ObjectSchemaValidationException(object_type), m_old_primary(old_primary), m_new_primary(new_primary)
|
||||||
{
|
{
|
||||||
if (old_primary.size()) {
|
if (old_primary.size()) {
|
||||||
m_what = "Property '" + old_primary + "' is no longer a primary key.";
|
m_what = "Property '" + old_primary + "' is no longer a primary key.";
|
||||||
|
@ -563,13 +563,13 @@ ChangedPrimaryKeyException::ChangedPrimaryKeyException(std::string object_type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidPrimaryKeyException::InvalidPrimaryKeyException(std::string object_type, std::string primary) :
|
InvalidPrimaryKeyException::InvalidPrimaryKeyException(std::string const& object_type, std::string const& primary) :
|
||||||
ObjectSchemaValidationException(object_type), m_primary_key(primary)
|
ObjectSchemaValidationException(object_type), m_primary_key(primary)
|
||||||
{
|
{
|
||||||
m_what = "Specified primary key property '" + primary + "' does not exist.";
|
m_what = "Specified primary key property '" + primary + "' does not exist.";
|
||||||
}
|
}
|
||||||
|
|
||||||
DuplicatePrimaryKeysException::DuplicatePrimaryKeysException(std::string object_type) : ObjectSchemaValidationException(object_type)
|
DuplicatePrimaryKeysException::DuplicatePrimaryKeysException(std::string const& object_type) : ObjectSchemaValidationException(object_type)
|
||||||
{
|
{
|
||||||
m_what = "Duplicate primary keys for object '" + object_type + "'.";
|
m_what = "Duplicate primary keys for object '" + object_type + "'.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,14 @@
|
||||||
#ifndef REALM_OBJECT_STORE_HPP
|
#ifndef REALM_OBJECT_STORE_HPP
|
||||||
#define REALM_OBJECT_STORE_HPP
|
#define REALM_OBJECT_STORE_HPP
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <functional>
|
|
||||||
#include <realm/link_view.hpp>
|
|
||||||
#include <realm/group.hpp>
|
|
||||||
|
|
||||||
#include "object_schema.hpp"
|
#include "object_schema.hpp"
|
||||||
#include "property.hpp"
|
#include "property.hpp"
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#include <realm/group.hpp>
|
||||||
|
#include <realm/link_view.hpp>
|
||||||
|
|
||||||
namespace realm {
|
namespace realm {
|
||||||
class ObjectSchemaValidationException;
|
class ObjectSchemaValidationException;
|
||||||
using Schema = std::vector<ObjectSchema>;
|
using Schema = std::vector<ObjectSchema>;
|
||||||
|
@ -137,7 +137,7 @@ namespace realm {
|
||||||
|
|
||||||
class DuplicatePrimaryKeyValueException : public MigrationException {
|
class DuplicatePrimaryKeyValueException : public MigrationException {
|
||||||
public:
|
public:
|
||||||
DuplicatePrimaryKeyValueException(std::string object_type, Property const& property);
|
DuplicatePrimaryKeyValueException(std::string const& object_type, Property const& property);
|
||||||
std::string object_type() const { return m_object_type; }
|
std::string object_type() const { return m_object_type; }
|
||||||
Property const& property() const { return m_property; }
|
Property const& property() const { return m_property; }
|
||||||
private:
|
private:
|
||||||
|
@ -148,16 +148,16 @@ namespace realm {
|
||||||
// Schema validation exceptions
|
// Schema validation exceptions
|
||||||
class SchemaValidationException : public ObjectStoreException {
|
class SchemaValidationException : public ObjectStoreException {
|
||||||
public:
|
public:
|
||||||
SchemaValidationException(std::vector<ObjectSchemaValidationException> errors);
|
SchemaValidationException(std::vector<ObjectSchemaValidationException> const& errors);
|
||||||
std::vector<ObjectSchemaValidationException> &validation_errors() { return m_validation_errors; }
|
std::vector<ObjectSchemaValidationException> const& validation_errors() const { return m_validation_errors; }
|
||||||
private:
|
private:
|
||||||
std::vector<ObjectSchemaValidationException> m_validation_errors;
|
std::vector<ObjectSchemaValidationException> m_validation_errors;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectSchemaValidationException : public ObjectStoreException {
|
class ObjectSchemaValidationException : public ObjectStoreException {
|
||||||
public:
|
public:
|
||||||
ObjectSchemaValidationException(std::string object_type) : m_object_type(object_type) {}
|
ObjectSchemaValidationException(std::string const& object_type) : m_object_type(object_type) {}
|
||||||
ObjectSchemaValidationException(std::string object_type, std::string message) :
|
ObjectSchemaValidationException(std::string const& object_type, std::string const& message) :
|
||||||
m_object_type(object_type) { m_what = message; }
|
m_object_type(object_type) { m_what = message; }
|
||||||
std::string object_type() const { return m_object_type; }
|
std::string object_type() const { return m_object_type; }
|
||||||
protected:
|
protected:
|
||||||
|
@ -166,7 +166,7 @@ namespace realm {
|
||||||
|
|
||||||
class ObjectSchemaPropertyException : public ObjectSchemaValidationException {
|
class ObjectSchemaPropertyException : public ObjectSchemaValidationException {
|
||||||
public:
|
public:
|
||||||
ObjectSchemaPropertyException(std::string object_type, Property const& property) :
|
ObjectSchemaPropertyException(std::string const& object_type, Property const& property) :
|
||||||
ObjectSchemaValidationException(object_type), m_property(property) {}
|
ObjectSchemaValidationException(object_type), m_property(property) {}
|
||||||
Property const& property() const { return m_property; }
|
Property const& property() const { return m_property; }
|
||||||
private:
|
private:
|
||||||
|
@ -175,37 +175,37 @@ namespace realm {
|
||||||
|
|
||||||
class PropertyTypeNotIndexableException : public ObjectSchemaPropertyException {
|
class PropertyTypeNotIndexableException : public ObjectSchemaPropertyException {
|
||||||
public:
|
public:
|
||||||
PropertyTypeNotIndexableException(std::string object_type, Property const& property);
|
PropertyTypeNotIndexableException(std::string const& object_type, Property const& property);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExtraPropertyException : public ObjectSchemaPropertyException {
|
class ExtraPropertyException : public ObjectSchemaPropertyException {
|
||||||
public:
|
public:
|
||||||
ExtraPropertyException(std::string object_type, Property const& property);
|
ExtraPropertyException(std::string const& object_type, Property const& property);
|
||||||
};
|
};
|
||||||
|
|
||||||
class MissingPropertyException : public ObjectSchemaPropertyException {
|
class MissingPropertyException : public ObjectSchemaPropertyException {
|
||||||
public:
|
public:
|
||||||
MissingPropertyException(std::string object_type, Property const& property);
|
MissingPropertyException(std::string const& object_type, Property const& property);
|
||||||
};
|
};
|
||||||
|
|
||||||
class InvalidNullabilityException : public ObjectSchemaPropertyException {
|
class InvalidNullabilityException : public ObjectSchemaPropertyException {
|
||||||
public:
|
public:
|
||||||
InvalidNullabilityException(std::string object_type, Property const& property);
|
InvalidNullabilityException(std::string const& object_type, Property const& property);
|
||||||
};
|
};
|
||||||
|
|
||||||
class MissingObjectTypeException : public ObjectSchemaPropertyException {
|
class MissingObjectTypeException : public ObjectSchemaPropertyException {
|
||||||
public:
|
public:
|
||||||
MissingObjectTypeException(std::string object_type, Property const& property);
|
MissingObjectTypeException(std::string const& object_type, Property const& property);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DuplicatePrimaryKeysException : public ObjectSchemaValidationException {
|
class DuplicatePrimaryKeysException : public ObjectSchemaValidationException {
|
||||||
public:
|
public:
|
||||||
DuplicatePrimaryKeysException(std::string object_type);
|
DuplicatePrimaryKeysException(std::string const& object_type);
|
||||||
};
|
};
|
||||||
|
|
||||||
class MismatchedPropertiesException : public ObjectSchemaValidationException {
|
class MismatchedPropertiesException : public ObjectSchemaValidationException {
|
||||||
public:
|
public:
|
||||||
MismatchedPropertiesException(std::string object_type, Property const& old_property, Property const& new_property);
|
MismatchedPropertiesException(std::string const& object_type, Property const& old_property, Property const& new_property);
|
||||||
Property const& old_property() const { return m_old_property; }
|
Property const& old_property() const { return m_old_property; }
|
||||||
Property const& new_property() const { return m_new_property; }
|
Property const& new_property() const { return m_new_property; }
|
||||||
private:
|
private:
|
||||||
|
@ -214,7 +214,7 @@ namespace realm {
|
||||||
|
|
||||||
class ChangedPrimaryKeyException : public ObjectSchemaValidationException {
|
class ChangedPrimaryKeyException : public ObjectSchemaValidationException {
|
||||||
public:
|
public:
|
||||||
ChangedPrimaryKeyException(std::string object_type, std::string old_primary, std::string new_primary);
|
ChangedPrimaryKeyException(std::string const& object_type, std::string const& old_primary, std::string const& new_primary);
|
||||||
std::string old_primary() const { return m_old_primary; }
|
std::string old_primary() const { return m_old_primary; }
|
||||||
std::string new_primary() const { return m_new_primary; }
|
std::string new_primary() const { return m_new_primary; }
|
||||||
private:
|
private:
|
||||||
|
@ -223,7 +223,7 @@ namespace realm {
|
||||||
|
|
||||||
class InvalidPrimaryKeyException : public ObjectSchemaValidationException {
|
class InvalidPrimaryKeyException : public ObjectSchemaValidationException {
|
||||||
public:
|
public:
|
||||||
InvalidPrimaryKeyException(std::string object_type, std::string primary_key);
|
InvalidPrimaryKeyException(std::string const& object_type, std::string const& primary_key);
|
||||||
std::string primary_key() const { return m_primary_key; }
|
std::string primary_key() const { return m_primary_key; }
|
||||||
private:
|
private:
|
||||||
std::string m_primary_key;
|
std::string m_primary_key;
|
||||||
|
|
Loading…
Reference in New Issue