FSTUserDataConverter.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <vector>
  18. #include "Firestore/core/src/firebase/firestore/core/user_data.h"
  19. #include "Firestore/core/src/firebase/firestore/model/database_id.h"
  20. #include "Firestore/core/src/firebase/firestore/model/document_key.h"
  21. #include "Firestore/core/src/firebase/firestore/model/field_mask.h"
  22. #include "Firestore/core/src/firebase/firestore/model/field_transform.h"
  23. #include "Firestore/core/src/firebase/firestore/model/precondition.h"
  24. @class FSTObjectValue;
  25. @class FSTFieldValue;
  26. @class FSTMutation;
  27. NS_ASSUME_NONNULL_BEGIN
  28. /**
  29. * An internal representation of FIRDocumentReference, representing a key in a specific database.
  30. * This is necessary because keys assume a database from context (usually the current one).
  31. * FSTDocumentKeyReference binds a key to a specific databaseID.
  32. *
  33. * TODO(b/64160088): Make DocumentKey aware of the specific databaseID it is tied to.
  34. */
  35. @interface FSTDocumentKeyReference : NSObject
  36. - (instancetype)init NS_UNAVAILABLE;
  37. - (instancetype)initWithKey:(firebase::firestore::model::DocumentKey)key
  38. databaseID:(const firebase::firestore::model::DatabaseId *)databaseID
  39. NS_DESIGNATED_INITIALIZER;
  40. - (const firebase::firestore::model::DocumentKey &)key;
  41. // Does not own the DatabaseId instance.
  42. @property(nonatomic, assign, readonly) const firebase::firestore::model::DatabaseId *databaseID;
  43. @end
  44. /**
  45. * An interface that allows arbitrary pre-converting of user data.
  46. *
  47. * Returns the converted value (can return back the input to act as a no-op).
  48. */
  49. typedef id _Nullable (^FSTPreConverterBlock)(id _Nullable);
  50. /**
  51. * Helper for parsing raw user input (provided via the API) into internal model classes.
  52. */
  53. @interface FSTUserDataConverter : NSObject
  54. - (instancetype)init NS_UNAVAILABLE;
  55. - (instancetype)initWithDatabaseID:(const firebase::firestore::model::DatabaseId *)databaseID
  56. preConverter:(FSTPreConverterBlock)preConverter NS_DESIGNATED_INITIALIZER;
  57. /** Parse document data from a non-merge setData call.*/
  58. - (firebase::firestore::core::ParsedSetData)parsedSetData:(id)input;
  59. /** Parse document data from a setData call with `merge:YES`. */
  60. - (firebase::firestore::core::ParsedSetData)parsedMergeData:(id)input
  61. fieldMask:(nullable NSArray<id> *)fieldMask;
  62. /** Parse update data from an updateData call. */
  63. - (firebase::firestore::core::ParsedUpdateData)parsedUpdateData:(id)input;
  64. /** Parse a "query value" (e.g. value in a where filter or a value in a cursor bound). */
  65. - (FSTFieldValue *)parsedQueryValue:(id)input;
  66. @end
  67. NS_ASSUME_NONNULL_END