RLMResults_Private.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #import "RLMResults_Private.h"
  19. #import "results.hpp"
  20. class RLMClassInfo;
  21. NS_ASSUME_NONNULL_BEGIN
  22. @interface RLMResults () {
  23. @protected
  24. realm::Results _results;
  25. }
  26. /**
  27. Initialize a 'raw' `RLMResults` using only an object store level Results.
  28. This is only meant for applications where a results collection is being backed
  29. by an object store object class that has no binding-level equivalent. The
  30. consumer is responsible for bridging between the underlying objects and whatever
  31. binding-level class is being vended out.
  32. */
  33. - (instancetype)initWithResults:(realm::Results)results;
  34. - (instancetype)initWithObjectInfo:(RLMClassInfo&)info results:(realm::Results&&)results;
  35. + (instancetype)resultsWithObjectInfo:(RLMClassInfo&)info results:(realm::Results&&)results;
  36. - (instancetype)subresultsWithResults:(realm::Results)results;
  37. @end
  38. NS_ASSUME_NONNULL_END
  39. // Utility functions
  40. [[gnu::noinline]]
  41. [[noreturn]]
  42. void RLMThrowResultsError(NSString * _Nullable aggregateMethod);
  43. #pragma clang diagnostic push
  44. #pragma clang diagnostic ignored "-Wnullability-completeness"
  45. template<typename Function>
  46. static auto translateRLMResultsErrors(Function&& f, NSString *aggregateMethod=nil) {
  47. try {
  48. return f();
  49. }
  50. catch (...) {
  51. RLMThrowResultsError(aggregateMethod);
  52. }
  53. }
  54. #pragma clang diagnostic pop