2015-05-01 12:57:16 +00:00
|
|
|
// Protocol Buffers - Google's data interchange format
|
|
|
|
// Copyright 2008 Google Inc. All rights reserved.
|
|
|
|
// https://developers.google.com/protocol-buffers/
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following disclaimer
|
|
|
|
// in the documentation and/or other materials provided with the
|
|
|
|
// distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived from
|
|
|
|
// this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
2015-06-08 20:24:57 +00:00
|
|
|
#import "GPBRuntimeTypes.h"
|
2015-05-01 12:57:16 +00:00
|
|
|
|
|
|
|
@class GPBEnumDescriptor;
|
|
|
|
@class GPBFieldDescriptor;
|
|
|
|
@class GPBFileDescriptor;
|
|
|
|
@class GPBOneofDescriptor;
|
|
|
|
|
2015-06-16 20:45:14 +00:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Syntax used in the proto file. */
|
2016-03-17 14:04:21 +00:00
|
|
|
typedef NS_ENUM(uint8_t, GPBFileSyntax) {
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Unknown syntax. */
|
2015-05-01 12:57:16 +00:00
|
|
|
GPBFileSyntaxUnknown = 0,
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Proto2 syntax. */
|
2015-05-01 12:57:16 +00:00
|
|
|
GPBFileSyntaxProto2 = 2,
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Proto3 syntax. */
|
2015-05-01 12:57:16 +00:00
|
|
|
GPBFileSyntaxProto3 = 3,
|
|
|
|
};
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Type of proto field. */
|
2016-03-17 14:04:21 +00:00
|
|
|
typedef NS_ENUM(uint8_t, GPBFieldType) {
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Optional/required field. Only valid for proto2 fields. */
|
|
|
|
GPBFieldTypeSingle,
|
|
|
|
/** Repeated field. */
|
|
|
|
GPBFieldTypeRepeated,
|
|
|
|
/** Map field. */
|
|
|
|
GPBFieldTypeMap,
|
2015-05-01 12:57:16 +00:00
|
|
|
};
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/**
|
|
|
|
* Describes a proto message.
|
|
|
|
**/
|
2015-05-01 12:57:16 +00:00
|
|
|
@interface GPBDescriptor : NSObject<NSCopying>
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Name of the message. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly, copy) NSString *name;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Fields declared in the message. */
|
2015-11-30 19:38:04 +00:00
|
|
|
@property(nonatomic, readonly, strong, nullable) NSArray<GPBFieldDescriptor*> *fields;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Oneofs declared in the message. */
|
2015-11-30 19:38:04 +00:00
|
|
|
@property(nonatomic, readonly, strong, nullable) NSArray<GPBOneofDescriptor*> *oneofs;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Extension range declared for the message. */
|
2015-06-16 20:45:14 +00:00
|
|
|
@property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRanges;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Number of extension ranges declared for the message. */
|
2016-03-17 14:04:21 +00:00
|
|
|
@property(nonatomic, readonly) uint32_t extensionRangesCount;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Descriptor for the file where the message was defined. */
|
2019-06-05 14:24:05 +00:00
|
|
|
@property(nonatomic, readonly) GPBFileDescriptor *file;
|
2015-05-01 12:57:16 +00:00
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Whether the message is in wire format or not. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** The class of this message. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly) Class messageClass;
|
2016-08-16 15:26:49 +00:00
|
|
|
/** Containing message descriptor if this message is nested, or nil otherwise. */
|
|
|
|
@property(readonly, nullable) GPBDescriptor *containingType;
|
|
|
|
/**
|
|
|
|
* Fully qualified name for this message (package.message). Can be nil if the
|
|
|
|
* value is unable to be computed.
|
|
|
|
*/
|
|
|
|
@property(readonly, nullable) NSString *fullName;
|
2015-05-01 12:57:16 +00:00
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/**
|
|
|
|
* Gets the field for the given number.
|
|
|
|
*
|
|
|
|
* @param fieldNumber The number for the field to get.
|
|
|
|
*
|
|
|
|
* @return The field descriptor for the given number, or nil if not found.
|
|
|
|
**/
|
2015-06-16 20:45:14 +00:00
|
|
|
- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
|
2016-08-08 14:15:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the field for the given name.
|
|
|
|
*
|
|
|
|
* @param name The name for the field to get.
|
|
|
|
*
|
|
|
|
* @return The field descriptor for the given name, or nil if not found.
|
|
|
|
**/
|
2015-06-16 20:45:14 +00:00
|
|
|
- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
|
2016-08-08 14:15:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the oneof for the given name.
|
|
|
|
*
|
|
|
|
* @param name The name for the oneof to get.
|
|
|
|
*
|
|
|
|
* @return The oneof descriptor for the given name, or nil if not found.
|
|
|
|
**/
|
2015-06-16 20:45:14 +00:00
|
|
|
- (nullable GPBOneofDescriptor *)oneofWithName:(NSString *)name;
|
2015-05-01 12:57:16 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/**
|
|
|
|
* Describes a proto file.
|
|
|
|
**/
|
2015-05-01 12:57:16 +00:00
|
|
|
@interface GPBFileDescriptor : NSObject
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/** The package declared in the proto file. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly, copy) NSString *package;
|
2016-08-16 15:26:49 +00:00
|
|
|
/** The objc prefix declared in the proto file. */
|
|
|
|
@property(nonatomic, readonly, copy, nullable) NSString *objcPrefix;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** The syntax of the proto file. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly) GPBFileSyntax syntax;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/**
|
|
|
|
* Describes a oneof field.
|
|
|
|
**/
|
2015-05-01 12:57:16 +00:00
|
|
|
@interface GPBOneofDescriptor : NSObject
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Name of the oneof field. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly) NSString *name;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Fields declared in the oneof. */
|
2015-11-30 19:38:04 +00:00
|
|
|
@property(nonatomic, readonly) NSArray<GPBFieldDescriptor*> *fields;
|
2015-05-01 12:57:16 +00:00
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/**
|
|
|
|
* Gets the field for the given number.
|
|
|
|
*
|
|
|
|
* @param fieldNumber The number for the field to get.
|
|
|
|
*
|
|
|
|
* @return The field descriptor for the given number, or nil if not found.
|
|
|
|
**/
|
2015-06-16 20:45:14 +00:00
|
|
|
- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
|
2016-08-08 14:15:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the field for the given name.
|
|
|
|
*
|
|
|
|
* @param name The name for the field to get.
|
|
|
|
*
|
|
|
|
* @return The field descriptor for the given name, or nil if not found.
|
|
|
|
**/
|
2015-06-16 20:45:14 +00:00
|
|
|
- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
|
2016-08-08 14:15:02 +00:00
|
|
|
|
2015-05-01 12:57:16 +00:00
|
|
|
@end
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/**
|
|
|
|
* Describes a proto field.
|
|
|
|
**/
|
2015-05-01 12:57:16 +00:00
|
|
|
@interface GPBFieldDescriptor : NSObject
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Name of the field. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly, copy) NSString *name;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Number associated with the field. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly) uint32_t number;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Data type contained in the field. */
|
2015-06-08 20:24:57 +00:00
|
|
|
@property(nonatomic, readonly) GPBDataType dataType;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Whether it has a default value or not. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly) BOOL hasDefaultValue;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Default value for the field. */
|
2015-06-08 20:24:57 +00:00
|
|
|
@property(nonatomic, readonly) GPBGenericValue defaultValue;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Whether this field is required. Only valid for proto2 fields. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly, getter=isRequired) BOOL required;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Whether this field is optional. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly, getter=isOptional) BOOL optional;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Type of field (single, repeated, map). */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly) GPBFieldType fieldType;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Type of the key if the field is a map. The value's type is -fieldType. */
|
2015-06-08 20:24:57 +00:00
|
|
|
@property(nonatomic, readonly) GPBDataType mapKeyDataType;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Whether the field is packable. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly, getter=isPackable) BOOL packable;
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/** The containing oneof if this field is part of one, nil otherwise. */
|
2019-06-05 14:24:05 +00:00
|
|
|
@property(nonatomic, readonly, nullable) GPBOneofDescriptor *containingOneof;
|
2015-05-01 12:57:16 +00:00
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Class of the message if the field is of message type. */
|
2019-06-05 14:24:05 +00:00
|
|
|
@property(nonatomic, readonly, nullable) Class msgClass;
|
2015-05-01 12:57:16 +00:00
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Descriptor for the enum if this field is an enum. */
|
2015-06-16 20:45:14 +00:00
|
|
|
@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
|
2015-05-01 12:57:16 +00:00
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/**
|
|
|
|
* Checks whether the given enum raw value is a valid enum value.
|
|
|
|
*
|
|
|
|
* @param value The raw enum value to check.
|
|
|
|
*
|
|
|
|
* @return YES if value is a valid enum raw value.
|
|
|
|
**/
|
2015-05-01 12:57:16 +00:00
|
|
|
- (BOOL)isValidEnumValue:(int32_t)value;
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/** @return Name for the text format, or nil if not known. */
|
2015-06-16 20:45:14 +00:00
|
|
|
- (nullable NSString *)textFormatName;
|
2015-05-01 12:57:16 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/**
|
|
|
|
* Describes a proto enum.
|
|
|
|
**/
|
2015-05-01 12:57:16 +00:00
|
|
|
@interface GPBEnumDescriptor : NSObject
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Name of the enum. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly, copy) NSString *name;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Function that validates that raw values are valid enum values. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly) GPBEnumValidationFunc enumVerifier;
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/**
|
|
|
|
* Returns the enum value name for the given raw enum.
|
|
|
|
*
|
2018-05-29 12:08:00 +00:00
|
|
|
* Note that there can be more than one name corresponding to a given value
|
|
|
|
* if the allow_alias option is used.
|
|
|
|
*
|
2016-08-08 14:15:02 +00:00
|
|
|
* @param number The raw enum value.
|
|
|
|
*
|
2018-05-29 12:08:00 +00:00
|
|
|
* @return The first name that matches the enum value passed, or nil if not valid.
|
2016-08-08 14:15:02 +00:00
|
|
|
**/
|
2015-06-16 20:45:14 +00:00
|
|
|
- (nullable NSString *)enumNameForValue:(int32_t)number;
|
2016-08-08 14:15:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the enum raw value for the given enum name.
|
|
|
|
*
|
|
|
|
* @param outValue A pointer where the value will be set.
|
|
|
|
* @param name The enum name for which to get the raw value.
|
|
|
|
*
|
|
|
|
* @return YES if a value was copied into the pointer, NO otherwise.
|
|
|
|
**/
|
2015-06-16 20:45:14 +00:00
|
|
|
- (BOOL)getValue:(nullable int32_t *)outValue forEnumName:(NSString *)name;
|
2015-05-01 12:57:16 +00:00
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/**
|
|
|
|
* Returns the text format for the given raw enum value.
|
|
|
|
*
|
|
|
|
* @param number The raw enum value.
|
|
|
|
*
|
2018-05-29 12:08:00 +00:00
|
|
|
* @return The first text format name which matches the enum value, or nil if not valid.
|
2016-08-08 14:15:02 +00:00
|
|
|
**/
|
2015-06-16 20:45:14 +00:00
|
|
|
- (nullable NSString *)textFormatNameForValue:(int32_t)number;
|
2016-08-08 14:15:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the enum raw value for the given text format name.
|
|
|
|
*
|
|
|
|
* @param outValue A pointer where the value will be set.
|
|
|
|
* @param textFormatName The text format name for which to get the raw value.
|
|
|
|
*
|
|
|
|
* @return YES if a value was copied into the pointer, NO otherwise.
|
|
|
|
**/
|
2016-06-25 00:40:29 +00:00
|
|
|
- (BOOL)getValue:(nullable int32_t *)outValue forEnumTextFormatName:(NSString *)textFormatName;
|
2015-05-01 12:57:16 +00:00
|
|
|
|
2018-05-29 12:08:00 +00:00
|
|
|
/**
|
|
|
|
* Gets the number of defined enum names.
|
|
|
|
*
|
|
|
|
* @return Count of the number of enum names, including any aliases.
|
|
|
|
*/
|
|
|
|
@property(nonatomic, readonly) uint32_t enumNameCount;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the enum name corresponding to the given index.
|
|
|
|
*
|
|
|
|
* @param index Index into the available names. The defined range is from 0
|
|
|
|
* to self.enumNameCount - 1.
|
|
|
|
*
|
|
|
|
* @returns The enum name at the given index, or nil if the index is out of range.
|
|
|
|
*/
|
|
|
|
- (nullable NSString *)getEnumNameForIndex:(uint32_t)index;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the enum text format name corresponding to the given index.
|
|
|
|
*
|
|
|
|
* @param index Index into the available names. The defined range is from 0
|
|
|
|
* to self.enumNameCount - 1.
|
|
|
|
*
|
|
|
|
* @returns The text format name at the given index, or nil if the index is out of range.
|
|
|
|
*/
|
|
|
|
- (nullable NSString *)getEnumTextFormatNameForIndex:(uint32_t)index;
|
|
|
|
|
2015-05-01 12:57:16 +00:00
|
|
|
@end
|
|
|
|
|
2016-08-08 14:15:02 +00:00
|
|
|
/**
|
|
|
|
* Describes a proto extension.
|
|
|
|
**/
|
2015-06-08 20:24:57 +00:00
|
|
|
@interface GPBExtensionDescriptor : NSObject<NSCopying>
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Field number under which the extension is stored. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly) uint32_t fieldNumber;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** The containing message class, i.e. the class extended by this extension. */
|
2015-06-08 20:24:57 +00:00
|
|
|
@property(nonatomic, readonly) Class containingMessageClass;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Data type contained in the extension. */
|
2015-06-08 20:24:57 +00:00
|
|
|
@property(nonatomic, readonly) GPBDataType dataType;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Whether the extension is repeated. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly, getter=isRepeated) BOOL repeated;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** Whether the extension is packable. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly, getter=isPackable) BOOL packable;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** The class of the message if the extension is of message type. */
|
2019-06-06 16:54:04 +00:00
|
|
|
@property(nonatomic, readonly) Class msgClass;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** The singleton name for the extension. */
|
2015-05-01 12:57:16 +00:00
|
|
|
@property(nonatomic, readonly) NSString *singletonName;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** The enum descriptor if the extension is of enum type. */
|
2015-06-16 20:45:14 +00:00
|
|
|
@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
|
2016-08-08 14:15:02 +00:00
|
|
|
/** The default value for the extension. */
|
2016-05-25 17:46:00 +00:00
|
|
|
@property(nonatomic, readonly, nullable) id defaultValue;
|
2016-08-08 14:15:02 +00:00
|
|
|
|
2015-05-01 12:57:16 +00:00
|
|
|
@end
|
2015-06-16 20:45:14 +00:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|