FSTUserDataConverter.h 3.1 KB

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