File: DBStoneSerializers.h

package info (click to toggle)
python-stone 3.3.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,956 kB
  • sloc: python: 21,786; objc: 498; sh: 29; makefile: 11
file content (86 lines) | stat: -rw-r--r-- 3,226 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
///
/// Copyright (c) 2016 Dropbox, Inc. All rights reserved.
///

#import <Foundation/Foundation.h>

#import "DBSerializableProtocol.h"

NS_ASSUME_NONNULL_BEGIN

///
/// Category to ensure `NSArray` class "implements" `DBSerializable` protocol, which is
/// required for all Obj-C SDK API route arguments. This avoids a compiler warning for
/// `NSArray` route arguments.
///
@interface NSArray (DBSerializable) <DBSerializable>

+ (nullable NSDictionary<NSString *, id> *)serialize:(id)obj;

+ (id)deserialize:(NSDictionary<NSString *, id> *)dict;

@end

///
/// Category to ensure `NSString` class "implements" `DBSerializable` protocol, which is
/// required for all Obj-C SDK API route arguments. This avoids a compiler warning for
/// `NSString` route arguments.
///
@interface NSString (DBSerializable) <DBSerializable>

+ (nullable NSDictionary<NSString *, id> *)serialize:(id)obj;

+ (id)deserialize:(NSDictionary<NSString *, id> *)dict;

@end

///
/// Serializer functions used by the SDK to serialize/deserialize `NSDate` types.
///
@interface DBNSDateSerializer : NSObject

/// Returns a json-compatible `NSString` that represents an `NSDate` type based on the supplied
/// `NSDate` object and date format string.
+ (NSString *)serialize:(NSDate *)value dateFormat:(NSString *)dateFormat;

/// Returns an `NSDate` object from the supplied `NSString`-representation of an `NSDate` object and
/// the supplied date format string.
+ (NSDate *)deserialize:(NSString *)value dateFormat:(NSString *)dateFormat;

@end

///
/// Serializer functions used by the SDK to serialize/deserialize `NSArray` types.
///
@interface DBArraySerializer : NSObject

/// Applies a serialization block to each element in the array and returns a new array with
/// all elements serialized. The serialization block either serializes the object, or if the
/// object is a wrapper for a primitive type, it leaves it unchanged.
+ (NSArray *)serialize:(NSArray *)value withBlock:(id (^_Nonnull)(id))serializeBlock;

/// Applies a deserialization block to each element in the array and returns a new array with
/// all elements deserialized. The serialization block either deserializes the object, or if the
/// object is a wrapper for a primitive type, it leaves it unchanged.
+ (NSArray *)deserialize:(NSArray *)jsonData withBlock:(id (^_Nonnull)(id))deserializeBlock;

@end

///
/// Serializer functions used by the SDK to serialize/deserialize `NSArray` types.
///
@interface DBMapSerializer : NSObject

/// Applies a serialization block to each element in the map and returns a new map with
/// all elements serialized. The serialization block either serializes the object, or if the
/// object is a wrapper for a primitive type, it leaves it unchanged.
+ (NSDictionary *)serialize:(NSDictionary *)value withBlock:(id (^_Nonnull)(id))serializeBlock;

/// Applies a deserialization block to each element in the map and returns a new map with
/// all elements deserialized. The serialization block either deserializes the object, or if the
/// object is a wrapper for a primitive type, it leaves it unchanged.
+ (NSDictionary *)deserialize:(NSDictionary *)jsonData withBlock:(id (^_Nonnull)(id))deserializeBlock;

@end

NS_ASSUME_NONNULL_END