mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-12 15:24:18 +00:00
Strip all trailing whitespace from files
This commit is contained in:
parent
d163d68b83
commit
af0db71187
@ -65,10 +65,10 @@ public:
|
|||||||
// Should only be called in test code, as continuing to use the previously
|
// Should only be called in test code, as continuing to use the previously
|
||||||
// cached instances will have odd results
|
// cached instances will have odd results
|
||||||
static void clear_cache();
|
static void clear_cache();
|
||||||
|
|
||||||
// Clears all caches on existing coordinators
|
// Clears all caches on existing coordinators
|
||||||
static void clear_all_caches();
|
static void clear_all_caches();
|
||||||
|
|
||||||
// Explicit constructor/destructor needed for the unique_ptrs to forward-declared types
|
// Explicit constructor/destructor needed for the unique_ptrs to forward-declared types
|
||||||
RealmCoordinator();
|
RealmCoordinator();
|
||||||
~RealmCoordinator();
|
~RealmCoordinator();
|
||||||
|
@ -52,7 +52,7 @@ namespace realm {
|
|||||||
// determines if a realm with the given old schema needs non-migration
|
// determines if a realm with the given old schema needs non-migration
|
||||||
// changes to make it compatible with the given target schema
|
// changes to make it compatible with the given target schema
|
||||||
static bool needs_update(Schema const& old_schema, Schema const& schema);
|
static bool needs_update(Schema const& old_schema, Schema const& schema);
|
||||||
|
|
||||||
// updates a Realm from old_schema to the given target schema, creating and updating tables as needed
|
// updates a Realm from old_schema to the given target schema, creating and updating tables as needed
|
||||||
// passed in target schema is updated with the correct column mapping
|
// passed in target schema is updated with the correct column mapping
|
||||||
// optionally runs migration function if schema is out of date
|
// optionally runs migration function if schema is out of date
|
||||||
|
@ -112,7 +112,7 @@ struct ParserState
|
|||||||
{
|
{
|
||||||
return group_stack.back();
|
return group_stack.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate *last_predicate()
|
Predicate *last_predicate()
|
||||||
{
|
{
|
||||||
Predicate *pred = current_group();
|
Predicate *pred = current_group();
|
||||||
@ -121,12 +121,12 @@ struct ParserState
|
|||||||
}
|
}
|
||||||
return pred;
|
return pred;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_predicate_to_current_group(Predicate::Type type)
|
void add_predicate_to_current_group(Predicate::Type type)
|
||||||
{
|
{
|
||||||
current_group()->cpnd.sub_predicates.emplace_back(type, negate_next);
|
current_group()->cpnd.sub_predicates.emplace_back(type, negate_next);
|
||||||
negate_next = false;
|
negate_next = false;
|
||||||
|
|
||||||
if (current_group()->cpnd.sub_predicates.size() > 1) {
|
if (current_group()->cpnd.sub_predicates.size() > 1) {
|
||||||
if (next_type == Predicate::Type::Or) {
|
if (next_type == Predicate::Type::Or) {
|
||||||
apply_or();
|
apply_or();
|
||||||
@ -136,10 +136,10 @@ struct ParserState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool negate_next = false;
|
bool negate_next = false;
|
||||||
Predicate::Type next_type = Predicate::Type::And;
|
Predicate::Type next_type = Predicate::Type::And;
|
||||||
|
|
||||||
void add_expression(Expression && exp)
|
void add_expression(Expression && exp)
|
||||||
{
|
{
|
||||||
Predicate *current = last_predicate();
|
Predicate *current = last_predicate();
|
||||||
@ -151,32 +151,32 @@ struct ParserState
|
|||||||
last_predicate()->cmpr.expr[0] = std::move(exp);
|
last_predicate()->cmpr.expr[0] = std::move(exp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_or()
|
void apply_or()
|
||||||
{
|
{
|
||||||
Predicate *group = current_group();
|
Predicate *group = current_group();
|
||||||
if (group->type == Predicate::Type::Or) {
|
if (group->type == Predicate::Type::Or) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert to OR
|
// convert to OR
|
||||||
group->type = Predicate::Type::Or;
|
group->type = Predicate::Type::Or;
|
||||||
if (group->cpnd.sub_predicates.size() > 2) {
|
if (group->cpnd.sub_predicates.size() > 2) {
|
||||||
// split the current group into an AND group ORed with the last subpredicate
|
// split the current group into an AND group ORed with the last subpredicate
|
||||||
Predicate new_sub(Predicate::Type::And);
|
Predicate new_sub(Predicate::Type::And);
|
||||||
new_sub.cpnd.sub_predicates = std::move(group->cpnd.sub_predicates);
|
new_sub.cpnd.sub_predicates = std::move(group->cpnd.sub_predicates);
|
||||||
|
|
||||||
group->cpnd.sub_predicates = { new_sub, std::move(new_sub.cpnd.sub_predicates.back()) };
|
group->cpnd.sub_predicates = { new_sub, std::move(new_sub.cpnd.sub_predicates.back()) };
|
||||||
group->cpnd.sub_predicates[0].cpnd.sub_predicates.pop_back();
|
group->cpnd.sub_predicates[0].cpnd.sub_predicates.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_and()
|
void apply_and()
|
||||||
{
|
{
|
||||||
if (current_group()->type == Predicate::Type::And) {
|
if (current_group()->type == Predicate::Type::And) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &sub_preds = current_group()->cpnd.sub_predicates;
|
auto &sub_preds = current_group()->cpnd.sub_predicates;
|
||||||
auto second_last = sub_preds.end() - 2;
|
auto second_last = sub_preds.end() - 2;
|
||||||
if (second_last->type == Predicate::Type::And && !second_last->negate) {
|
if (second_last->type == Predicate::Type::And && !second_last->negate) {
|
||||||
|
@ -462,7 +462,7 @@ void update_query_with_predicate(Query &query, const Predicate &pred, Arguments
|
|||||||
if (pred.negate) {
|
if (pred.negate) {
|
||||||
query.Not();
|
query.Not();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pred.type) {
|
switch (pred.type) {
|
||||||
case Predicate::Type::And:
|
case Predicate::Type::And:
|
||||||
query.group();
|
query.group();
|
||||||
@ -474,7 +474,7 @@ void update_query_with_predicate(Query &query, const Predicate &pred, Arguments
|
|||||||
}
|
}
|
||||||
query.end_group();
|
query.end_group();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Predicate::Type::Or:
|
case Predicate::Type::Or:
|
||||||
query.group();
|
query.group();
|
||||||
for (auto &sub : pred.cpnd.sub_predicates) {
|
for (auto &sub : pred.cpnd.sub_predicates) {
|
||||||
@ -486,7 +486,7 @@ void update_query_with_predicate(Query &query, const Predicate &pred, Arguments
|
|||||||
}
|
}
|
||||||
query.end_group();
|
query.end_group();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Predicate::Type::Comparison: {
|
case Predicate::Type::Comparison: {
|
||||||
add_comparison_to_query(query, pred, arguments, schema, type);
|
add_comparison_to_query(query, pred, arguments, schema, type);
|
||||||
break;
|
break;
|
||||||
@ -494,11 +494,11 @@ void update_query_with_predicate(Query &query, const Predicate &pred, Arguments
|
|||||||
case Predicate::Type::True:
|
case Predicate::Type::True:
|
||||||
query.and_query(std::unique_ptr<realm::Expression>(new TrueExpression));
|
query.and_query(std::unique_ptr<realm::Expression>(new TrueExpression));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Predicate::Type::False:
|
case Predicate::Type::False:
|
||||||
query.and_query(std::unique_ptr<realm::Expression>(new FalseExpression));
|
query.and_query(std::unique_ptr<realm::Expression>(new FalseExpression));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("Invalid predicate type");
|
throw std::runtime_error("Invalid predicate type");
|
||||||
}
|
}
|
||||||
@ -507,7 +507,7 @@ void update_query_with_predicate(Query &query, const Predicate &pred, Arguments
|
|||||||
void apply_predicate(Query &query, const Predicate &predicate, Arguments &arguments, const Schema &schema, const std::string &objectType)
|
void apply_predicate(Query &query, const Predicate &predicate, Arguments &arguments, const Schema &schema, const std::string &objectType)
|
||||||
{
|
{
|
||||||
update_query_with_predicate(query, predicate, arguments, schema, objectType);
|
update_query_with_predicate(query, predicate, arguments, schema, objectType);
|
||||||
|
|
||||||
// Test the constructed query in core
|
// Test the constructed query in core
|
||||||
std::string validateMessage = query.validate();
|
std::string validateMessage = query.validate();
|
||||||
precondition(validateMessage.empty(), validateMessage.c_str());
|
precondition(validateMessage.empty(), validateMessage.c_str());
|
||||||
|
@ -83,10 +83,10 @@ public:
|
|||||||
|
|
||||||
// Get the Realm
|
// Get the Realm
|
||||||
SharedRealm get_realm() const { return m_realm; }
|
SharedRealm get_realm() const { return m_realm; }
|
||||||
|
|
||||||
// Object schema describing the vendored object type
|
// Object schema describing the vendored object type
|
||||||
const ObjectSchema &get_object_schema() const { return *m_object_schema; }
|
const ObjectSchema &get_object_schema() const { return *m_object_schema; }
|
||||||
|
|
||||||
// Get a query which will match the same rows as is contained in this Results
|
// Get a query which will match the same rows as is contained in this Results
|
||||||
// Returned query will not be valid if the current mode is Empty
|
// Returned query will not be valid if the current mode is Empty
|
||||||
Query get_query() const;
|
Query get_query() const;
|
||||||
|
@ -231,7 +231,7 @@ namespace realm {
|
|||||||
public:
|
public:
|
||||||
UnitializedRealmException(std::string message) : std::runtime_error(message) {}
|
UnitializedRealmException(std::string message) : std::runtime_error(message) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class InvalidEncryptionKeyException : public std::runtime_error {
|
class InvalidEncryptionKeyException : public std::runtime_error {
|
||||||
public:
|
public:
|
||||||
InvalidEncryptionKeyException() : std::runtime_error("Encryption key must be 64 bytes.") {}
|
InvalidEncryptionKeyException() : std::runtime_error("Encryption key must be 64 bytes.") {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user