added iOS source code
[wl-app.git] / iOS / Pods / Realm / include / RLMResults_Private.hpp
1 ////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright 2017 Realm Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 ////////////////////////////////////////////////////////////////////////////
18
19 #import "RLMResults_Private.h"
20
21 #import "results.hpp"
22
23 class RLMClassInfo;
24
25 NS_ASSUME_NONNULL_BEGIN
26
27 @interface RLMResults () {
28 @protected
29     realm::Results _results;
30 }
31
32 /**
33  Initialize a 'raw' `RLMResults` using only an object store level Results.
34  This is only meant for applications where a results collection is being backed
35  by an object store object class that has no binding-level equivalent. The
36  consumer is responsible for bridging between the underlying objects and whatever
37  binding-level class is being vended out.
38  */
39 - (instancetype)initWithResults:(realm::Results)results;
40
41 + (instancetype)resultsWithObjectInfo:(RLMClassInfo&)info results:(realm::Results)results;
42 @end
43
44 NS_ASSUME_NONNULL_END
45
46 // Utility functions
47
48 [[gnu::noinline]]
49 [[noreturn]]
50 void RLMThrowResultsError(NSString * _Nullable aggregateMethod);
51
52 #pragma clang diagnostic push
53 #pragma clang diagnostic ignored "-Wnullability-completeness"
54 template<typename Function>
55 static auto translateRLMResultsErrors(Function&& f, NSString *aggregateMethod=nil) {
56     try {
57         return f();
58     }
59     catch (...) {
60         RLMThrowResultsError(aggregateMethod);
61     }
62 }
63 #pragma clang diagnostic pop