diff options
Diffstat (limited to 'objectivec/GPBWellKnownTypes.h')
-rw-r--r-- | objectivec/GPBWellKnownTypes.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/objectivec/GPBWellKnownTypes.h b/objectivec/GPBWellKnownTypes.h index c98594a2..050f85f6 100644 --- a/objectivec/GPBWellKnownTypes.h +++ b/objectivec/GPBWellKnownTypes.h @@ -30,8 +30,10 @@ #import <Foundation/Foundation.h> -#import "google/protobuf/Timestamp.pbobjc.h" +#import "google/protobuf/Any.pbobjc.h" #import "google/protobuf/Duration.pbobjc.h" +#import "google/protobuf/Timestamp.pbobjc.h" + NS_ASSUME_NONNULL_BEGIN @@ -49,4 +51,22 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)timeIntervalSince1970; @end +// Extension to GPBAny to support packing and unpacking for arbitrary messages. +@interface GPBAny (GPBWellKnownTypes) +// Initialize GPBAny instance with the given message. e.g., for google.protobuf.foo, type +// url will be "type.googleapis.com/google.protobuf.foo" and value will be serialized foo. +- (instancetype)initWithMessage:(GPBMessage*)message; +// Serialize the given message to the value in GPBAny. Type url will also be updated. +- (void)setMessage:(GPBMessage*)message; +// Parse the value in GPBAny to the given message. If messageClass message doesn't match the +// type url in GPBAny, nil is returned. +- (GPBMessage*)messageOfClass:(Class)messageClass; +// True if the given type matches the type url in GPBAny. +- (BOOL)wrapsMessageOfClass:(Class)messageClass; +@end + +// Common prefix of type url in GPBAny, which is @"type.googleapis.com/". All valid +// type urls in any should start with this prefix. +extern NSString *const GPBTypeGoogleApisComPrefix; + NS_ASSUME_NONNULL_END |