FSTDocumentKey.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #include <initializer_list>
  18. #include "Firestore/core/src/firebase/firestore/model/resource_path.h"
  19. NS_ASSUME_NONNULL_BEGIN
  20. /** FSTDocumentKey represents the location of a document in the Firestore database. */
  21. @interface FSTDocumentKey : NSObject <NSCopying>
  22. /**
  23. * Creates and returns a new document key with the given path.
  24. *
  25. * @param path The path to the document.
  26. * @return A new instance of FSTDocumentKey.
  27. */
  28. + (instancetype)keyWithPath:(firebase::firestore::model::ResourcePath)path;
  29. /**
  30. * Creates and returns a new document key with a path with the given segments.
  31. *
  32. * @param segments The segments of the path to the document.
  33. * @return A new instance of FSTDocumentKey.
  34. */
  35. + (instancetype)keyWithSegments:(std::initializer_list<std::string>)segments;
  36. /**
  37. * Creates and returns a new document key from the given resource path string.
  38. *
  39. * @param resourcePath The slash-separated segments of the resource's path.
  40. * @return A new instance of FSTDocumentKey.
  41. */
  42. + (instancetype)keyWithPathString:(NSString *)resourcePath;
  43. /** Returns true iff the given path is a path to a document. */
  44. + (BOOL)isDocumentKey:(const firebase::firestore::model::ResourcePath &)path;
  45. - (BOOL)isEqualToKey:(FSTDocumentKey *)other;
  46. - (NSComparisonResult)compare:(FSTDocumentKey *)other;
  47. /** The path to the document. */
  48. - (const firebase::firestore::model::ResourcePath &)path;
  49. @end
  50. extern const NSComparator FSTDocumentKeyComparator;
  51. /** The field path string that represents the document's key. */
  52. extern NSString *const kDocumentKeyPath;
  53. NS_ASSUME_NONNULL_END