FSTDocumentKey.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. @class FSTResourcePath;
  18. NS_ASSUME_NONNULL_BEGIN
  19. /** FSTDocumentKey represents the location of a document in the Firestore database. */
  20. @interface FSTDocumentKey : NSObject <NSCopying>
  21. /**
  22. * Creates and returns a new document key with the given path.
  23. *
  24. * @param path The path to the document.
  25. * @return A new instance of FSTDocumentKey.
  26. */
  27. + (instancetype)keyWithPath:(FSTResourcePath *)path;
  28. /**
  29. * Creates and returns a new document key with a path with the given segments.
  30. *
  31. * @param segments The segments of the path to the document.
  32. * @return A new instance of FSTDocumentKey.
  33. */
  34. + (instancetype)keyWithSegments:(NSArray<NSString *> *)segments;
  35. /**
  36. * Creates and returns a new document key from the given resource path string.
  37. *
  38. * @param resourcePath The slash-separated segments of the resource's path.
  39. * @return A new instance of FSTDocumentKey.
  40. */
  41. + (instancetype)keyWithPathString:(NSString *)resourcePath;
  42. /** Returns true iff the given path is a path to a document. */
  43. + (BOOL)isDocumentKey:(FSTResourcePath *)path;
  44. - (BOOL)isEqualToKey:(FSTDocumentKey *)other;
  45. - (NSComparisonResult)compare:(FSTDocumentKey *)other;
  46. /** The path to the document. */
  47. @property(strong, nonatomic, readonly) FSTResourcePath *path;
  48. @end
  49. extern const NSComparator FSTDocumentKeyComparator;
  50. /** The field path string that represents the document's key. */
  51. extern NSString *const kDocumentKeyPath;
  52. NS_ASSUME_NONNULL_END