Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: third_party/protobuf/objectivec/GPBWellKnownTypes.h

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2015 Google Inc. All rights reserved. 2 // Copyright 2015 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 12 matching lines...) Expand all
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 30
31 #import <Foundation/Foundation.h> 31 #import <Foundation/Foundation.h>
32 32
33 #import "google/protobuf/Duration.pbobjc.h" 33 // This CPP symbol can be defined to use imports that match up to the framework
34 #import "google/protobuf/Timestamp.pbobjc.h" 34 // imports needed when using CocoaPods.
35 #if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
36 #define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
37 #endif
38
39 #if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
40 #import <Protobuf/Any.pbobjc.h>
41 #import <Protobuf/Duration.pbobjc.h>
42 #import <Protobuf/Timestamp.pbobjc.h>
43 #else
44 #import "google/protobuf/Any.pbobjc.h"
45 #import "google/protobuf/Duration.pbobjc.h"
46 #import "google/protobuf/Timestamp.pbobjc.h"
47 #endif
35 48
36 NS_ASSUME_NONNULL_BEGIN 49 NS_ASSUME_NONNULL_BEGIN
37 50
38 // Extension to GPBTimestamp to work with standard Foundation time/date types. 51 #pragma mark - Errors
52
53 /** NSError domain used for errors. */
54 extern NSString *const GPBWellKnownTypesErrorDomain;
55
56 /** Error code for NSError with GPBWellKnownTypesErrorDomain. */
57 typedef NS_ENUM(NSInteger, GPBWellKnownTypesErrorCode) {
58 /** The type_url could not be computed for the requested GPBMessage class. */
59 GPBWellKnownTypesErrorCodeFailedToComputeTypeURL = -100,
60 /** type_url in a Any doesn’t match that of the requested GPBMessage class. */
61 GPBWellKnownTypesErrorCodeTypeURLMismatch = -101,
62 };
63
64 #pragma mark - GPBTimestamp
65
66 /**
67 * Category for GPBTimestamp to work with standard Foundation time/date types.
68 **/
39 @interface GPBTimestamp (GBPWellKnownTypes) 69 @interface GPBTimestamp (GBPWellKnownTypes)
70
71 /** The NSDate representation of this GPBTimestamp. */
40 @property(nonatomic, readwrite, strong) NSDate *date; 72 @property(nonatomic, readwrite, strong) NSDate *date;
73
74 /**
75 * The NSTimeInterval representation of this GPBTimestamp.
76 *
77 * @note: Not all second/nanos combinations can be represented in a
78 * NSTimeInterval, so getting this could be a lossy transform.
79 **/
41 @property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970; 80 @property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970;
81
82 /**
83 * Initializes a GPBTimestamp with the given NSDate.
84 *
85 * @param date The date to configure the GPBTimestamp with.
86 *
87 * @return A newly initialized GPBTimestamp.
88 **/
42 - (instancetype)initWithDate:(NSDate *)date; 89 - (instancetype)initWithDate:(NSDate *)date;
90
91 /**
92 * Initializes a GPBTimestamp with the given NSTimeInterval.
93 *
94 * @param timeIntervalSince1970 Time interval to configure the GPBTimestamp with .
95 *
96 * @return A newly initialized GPBTimestamp.
97 **/
43 - (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1 970; 98 - (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1 970;
99
44 @end 100 @end
45 101
46 // Extension to GPBDuration to work with standard Foundation time type. 102 #pragma mark - GPBDuration
103
104 /**
105 * Category for GPBDuration to work with standard Foundation time type.
106 **/
47 @interface GPBDuration (GBPWellKnownTypes) 107 @interface GPBDuration (GBPWellKnownTypes)
108
109 /**
110 * The NSTimeInterval representation of this GPBDuration.
111 *
112 * @note: Not all second/nanos combinations can be represented in a
113 * NSTimeInterval, so getting this could be a lossy transform.
114 **/
48 @property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970; 115 @property(nonatomic, readwrite) NSTimeInterval timeIntervalSince1970;
116
117 /**
118 * Initializes a GPBDuration with the given NSTimeInterval.
119 *
120 * @param timeIntervalSince1970 Time interval to configure the GPBDuration with.
121 *
122 * @return A newly initialized GPBDuration.
123 **/
49 - (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1 970; 124 - (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1 970;
125
50 @end 126 @end
51 127
128 #pragma mark - GPBAny
129
130 /**
131 * Category for GPBAny to help work with the message within the object.
132 **/
133 @interface GPBAny (GBPWellKnownTypes)
134
135 /**
136 * Convenience method to create a GPBAny containing the serialized message.
137 * This uses type.googleapis.com/ as the type_url's prefix.
138 *
139 * @param message The message to be packed into the GPBAny.
140 * @param errorPtr Pointer to an error that will be populated if something goes
141 * wrong.
142 *
143 * @return A newly configured GPBAny with the given message, or nil on failure.
144 */
145 + (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message
146 error:(NSError **)errorPtr;
147
148 /**
149 * Convenience method to create a GPBAny containing the serialized message.
150 *
151 * @param message The message to be packed into the GPBAny.
152 * @param typeURLPrefix The URL prefix to apply for type_url.
153 * @param errorPtr Pointer to an error that will be populated if something
154 * goes wrong.
155 *
156 * @return A newly configured GPBAny with the given message, or nil on failure.
157 */
158 + (nullable instancetype)anyWithMessage:(nonnull GPBMessage *)message
159 typeURLPrefix:(nonnull NSString *)typeURLPrefix
160 error:(NSError **)errorPtr;
161
162 /**
163 * Initializes a GPBAny to contain the serialized message. This uses
164 * type.googleapis.com/ as the type_url's prefix.
165 *
166 * @param message The message to be packed into the GPBAny.
167 * @param errorPtr Pointer to an error that will be populated if something goes
168 * wrong.
169 *
170 * @return A newly configured GPBAny with the given message, or nil on failure.
171 */
172 - (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message
173 error:(NSError **)errorPtr;
174
175 /**
176 * Initializes a GPBAny to contain the serialized message.
177 *
178 * @param message The message to be packed into the GPBAny.
179 * @param typeURLPrefix The URL prefix to apply for type_url.
180 * @param errorPtr Pointer to an error that will be populated if something
181 * goes wrong.
182 *
183 * @return A newly configured GPBAny with the given message, or nil on failure.
184 */
185 - (nullable instancetype)initWithMessage:(nonnull GPBMessage *)message
186 typeURLPrefix:(nonnull NSString *)typeURLPrefix
187 error:(NSError **)errorPtr;
188
189 /**
190 * Packs the serialized message into this GPBAny. This uses
191 * type.googleapis.com/ as the type_url's prefix.
192 *
193 * @param message The message to be packed into the GPBAny.
194 * @param errorPtr Pointer to an error that will be populated if something goes
195 * wrong.
196 *
197 * @return Whether the packing was successful or not.
198 */
199 - (BOOL)packWithMessage:(nonnull GPBMessage *)message
200 error:(NSError **)errorPtr;
201
202 /**
203 * Packs the serialized message into this GPBAny.
204 *
205 * @param message The message to be packed into the GPBAny.
206 * @param typeURLPrefix The URL prefix to apply for type_url.
207 * @param errorPtr Pointer to an error that will be populated if something
208 * goes wrong.
209 *
210 * @return Whether the packing was successful or not.
211 */
212 - (BOOL)packWithMessage:(nonnull GPBMessage *)message
213 typeURLPrefix:(nonnull NSString *)typeURLPrefix
214 error:(NSError **)errorPtr;
215
216 /**
217 * Unpacks the serialized message as if it was an instance of the given class.
218 *
219 * @note When checking type_url, the base URL is not checked, only the fully
220 * qualified name.
221 *
222 * @param messageClass The class to use to deserialize the contained message.
223 * @param errorPtr Pointer to an error that will be populated if something
224 * goes wrong.
225 *
226 * @return An instance of the given class populated with the contained data, or
227 * nil on failure.
228 */
229 - (nullable GPBMessage *)unpackMessageClass:(Class)messageClass
230 error:(NSError **)errorPtr;
231
232 @end
233
52 NS_ASSUME_NONNULL_END 234 NS_ASSUME_NONNULL_END
OLDNEW
« no previous file with comments | « third_party/protobuf/objectivec/GPBUtilities_PackagePrivate.h ('k') | third_party/protobuf/objectivec/GPBWellKnownTypes.m » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698