// // CoreStoreBridge.h // CoreStore // // Copyright © 2016 John Rommel Estropia // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // #import #ifndef CoreStoreBridge_h #define CoreStoreBridge_h #if !__has_feature(objc_arc) #error CoreStore Objective-C utilities require ARC be enabled #endif #if !__has_extension(attribute_overloadable) #error CoreStore Objective-C utilities can only be used on platforms that support C function overloading #endif #define CS_OBJC_EXTERN extern #define CS_OBJC_OVERLOADABLE __attribute__((__overloadable__)) #define CS_OBJC_REQUIRES_NIL_TERMINATION(A, B) __attribute__((sentinel(A, B))) // MARK: - From @class CSFrom; /** @abstract Initializes a CSFrom clause with the specified entity class. @code MyPersonEntity *people = [transaction fetchAllFrom:From([MyPersonEntity class])]; @endcode @param entityClass the NSManagedObject class type to be created @result a CSFrom clause with the specified entity class */ CS_OBJC_EXTERN CS_OBJC_OVERLOADABLE CSFrom *_Nonnull From(Class _Nonnull entityClass); /** @abstract Initializes a CSFrom clause with the specified configurations. @code MyPersonEntity *people = [transaction fetchAllFrom:From([MyPersonEntity class], @[@"Configuration1"])]; @endcode @param entityClass the NSManagedObject class type to be created @param configurations an array of the NSPersistentStore configuration names to associate objects from. This parameter is required if multiple configurations contain the created NSManagedObject's entity type. Set to [NSNull null] to use the default configuration. @result a CSFrom clause with the specified configurations */ CS_OBJC_EXTERN CS_OBJC_OVERLOADABLE CSFrom *_Nonnull From(Class _Nonnull entityClass, NSArray *_Nonnull configurations); // MARK: - Where @class CSWhere; /** @abstract Initializes a CSWhere clause with a predicate that always evaluates to the specified boolean value @param value the boolean value for the predicate @result a CSWhere clause with a predicate that always evaluates to the specified boolean value */ CS_OBJC_EXTERN CS_OBJC_OVERLOADABLE CSWhere *_Nonnull Where(BOOL value); /** @abstract Initializes a CSWhere clause with a predicate using the specified string format and arguments @param format the format string for the predicate @param argumentArray the arguments for format @result a CSWhere clause with a predicate using the specified string format and arguments */ CS_OBJC_EXTERN CS_OBJC_OVERLOADABLE CSWhere *_Nonnull Where(NSString *_Nonnull format, ...); /** @abstract Initializes a CSWhere clause with an NSPredicate @param predicate the NSPredicate for the fetch or query @result a CSWhere clause with an NSPredicate */ CS_OBJC_EXTERN CS_OBJC_OVERLOADABLE CSWhere *_Nonnull Where(NSPredicate *_Nonnull predicate); // MARK: - GroupBy @class CSGroupBy; /** @abstract Initializes a CSGroupBy clause with a list of key path strings @param keyPaths a list of key path strings to group results with @result a CSGroupBy clause with a list of key path strings */ CS_OBJC_OVERLOADABLE CSGroupBy *_Nonnull GroupBy(NSArray *_Nonnull keyPaths); #endif /* CoreStoreBridge_h */