Repository: realm/realm-swift
File: Realm/RLMQueryUtil.hpp (C++)

Code before:
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2014 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

#import <Foundation/Foundation.h>
#import <tightdb/table.hpp>
#import <tightdb/table_view.hpp>
#import <tightdb/query.hpp>

#import "RLMObjectSchema.h"
#import "RLMSchema.h"

extern NSString *const RLMPropertiesComparisonTypeMismatchException;
extern NSString *const RLMUnsupportedTypesFoundInPropertyComparisonException;

// apply the given predicate to the passed in query, returning the updated query
void RLMUpdateQueryWithPredicate(tightdb::Query *query, id predicate, RLMSchema * schema,
                                 RLMObjectSchema *objectSchema);

// sort an existing view by the specified property name and direction
void RLMUpdateViewWithOrder(tightdb::TableView &view, RLMObjectSchema *schema, NSString *property, BOOL ascending);

// validate and returns a property used for sorting - throw for invalid propty types or names
RLMProperty *RLMValidatedPropertyForSort(RLMObjectSchema *schema, NSString *propName);

// return column index - throw for invalid column name
NSUInteger RLMValidatedColumnIndex(RLMObjectSchema *schema, NSString *columnName);

// predicate exception
NSException *RLMPredicateException(NSString *name, NSString *reason);

// This macro validates predicate format with optional arguments
#define RLM_VARARG(PREDICATE_FORMAT, ARGS) \
va_start(ARGS, PREDICATE_FORMAT);          \
va_end(ARGS);                              \
if (PREDICATE_FORMAT && ![PREDICATE_FORMAT isKindOfClass:[NSString class]]) {         \
    NSString *reason = @"predicate must be an NSString with optional format va_list"; \
    [NSException exceptionWithName:@"RLMException" reason:reason userInfo:nil];       \
}


Review comment (suggestion):
New core release will be made later today. You can prep this to use core
0.81.0.

On Tue, Aug 12, 2014 at 3:47 PM, JP Simard notifications@github.com wrote:

> In Realm/RLMQueryUtil.hpp:
> 
> > @@ -34,8 +34,11 @@ void RLMUpdateQueryWithPredicate(tightdb::Query *query, id predicate, RLMSchema
> >  // sort an existing view by the specified property name and direction
> >  void RLMUpdateViewWithOrder(tightdb::TableView &view, RLMObjectSchema *schema, NSString *property, BOOL ascending);
> > 
> > -NSUInteger RLMValidatedColumnIndex(RLMObjectSchema *desc, NSString *columnName);
> > +// validate and returns a property used for sorting - throw for invalid propty types or names
> 
> Property typo
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/realm/realm-cocoa/pull/770/files#r16113422.


Code after:
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2014 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

#import <Foundation/Foundation.h>
#import <tightdb/table.hpp>
#import <tightdb/table_view.hpp>
#import <tightdb/query.hpp>

#import "RLMObjectSchema.h"
#import "RLMSchema.h"

extern NSString *const RLMPropertiesComparisonTypeMismatchException;
extern NSString *const RLMUnsupportedTypesFoundInPropertyComparisonException;

// apply the given predicate to the passed in query, returning the updated query
void RLMUpdateQueryWithPredicate(tightdb::Query *query, id predicate, RLMSchema * schema,
                                 RLMObjectSchema *objectSchema);

// sort an existing view by the specified property name and direction
void RLMUpdateViewWithOrder(tightdb::TableView &view, RLMObjectSchema *schema, NSString *property, BOOL ascending);

// validate and returns a property used for sorting - throw for invalid property types or names
RLMProperty *RLMValidatedPropertyForSort(RLMObjectSchema *schema, NSString *propName);

// return column index - throw for invalid column name
NSUInteger RLMValidatedColumnIndex(RLMObjectSchema *schema, NSString *columnName);

// This macro validates predicate format with optional arguments
#define RLM_VARARG(PREDICATE_FORMAT, ARGS) \
va_start(ARGS, PREDICATE_FORMAT);          \
va_end(ARGS);                              \
if (PREDICATE_FORMAT && ![PREDICATE_FORMAT isKindOfClass:[NSString class]]) {         \
    NSString *reason = @"predicate must be an NSString with optional format va_list"; \
    [NSException exceptionWithName:@"RLMException" reason:reason userInfo:nil];       \
}