2016-07-31 20:44:31 +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>
|
|
|
|
|
|
|
|
#import "GPBRuntimeTypes.h"
|
|
|
|
|
|
|
|
@class GPBEnumDescriptor;
|
|
|
|
@class GPBFieldDescriptor;
|
|
|
|
@class GPBFileDescriptor;
|
|
|
|
@class GPBOneofDescriptor;
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Syntax used in the proto file. */
|
2016-07-31 20:44:31 +00:00
|
|
|
typedef NS_ENUM(uint8_t, GPBFileSyntax) {
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Unknown syntax. */
|
2016-07-31 20:44:31 +00:00
|
|
|
GPBFileSyntaxUnknown = 0,
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Proto2 syntax. */
|
2016-07-31 20:44:31 +00:00
|
|
|
GPBFileSyntaxProto2 = 2,
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Proto3 syntax. */
|
2016-07-31 20:44:31 +00:00
|
|
|
GPBFileSyntaxProto3 = 3,
|
|
|
|
};
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Type of proto field. */
|
2016-07-31 20:44:31 +00:00
|
|
|
typedef NS_ENUM(uint8_t, GPBFieldType) {
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Optional/required field. Only valid for proto2 fields. */
|
|
|
|
GPBFieldTypeSingle,
|
|
|
|
/** Repeated field. */
|
|
|
|
GPBFieldTypeRepeated,
|
|
|
|
/** Map field. */
|
|
|
|
GPBFieldTypeMap,
|
2016-07-31 20:44:31 +00:00
|
|
|
};
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/**
|
|
|
|
* Describes a proto message.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
@interface GPBDescriptor : NSObject<NSCopying>
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Name of the message. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, copy) NSString *name;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Fields declared in the message. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, strong, nullable) NSArray<GPBFieldDescriptor*> *fields;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Oneofs declared in the message. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, strong, nullable) NSArray<GPBOneofDescriptor*> *oneofs;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Extension range declared for the message. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, nullable) const GPBExtensionRange *extensionRanges;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Number of extension ranges declared for the message. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) uint32_t extensionRangesCount;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Descriptor for the file where the message was defined. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, assign) GPBFileDescriptor *file;
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Whether the message is in wire format or not. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, getter=isWireFormat) BOOL wireFormat;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** The class of this message. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) Class messageClass;
|
2018-05-05 00:30:16 +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;
|
2016-07-31 20:44:31 +00:00
|
|
|
|
2018-05-05 00:30:16 +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.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
|
2018-05-05 00:30:16 +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.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
|
2018-05-05 00:30:16 +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.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
- (nullable GPBOneofDescriptor *)oneofWithName:(NSString *)name;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/**
|
|
|
|
* Describes a proto file.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
@interface GPBFileDescriptor : NSObject
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/** The package declared in the proto file. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, copy) NSString *package;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** The objc prefix declared in the proto file. */
|
|
|
|
@property(nonatomic, readonly, copy, nullable) NSString *objcPrefix;
|
|
|
|
/** The syntax of the proto file. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) GPBFileSyntax syntax;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/**
|
|
|
|
* Describes a oneof field.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
@interface GPBOneofDescriptor : NSObject
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Name of the oneof field. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) NSString *name;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Fields declared in the oneof. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) NSArray<GPBFieldDescriptor*> *fields;
|
|
|
|
|
2018-05-05 00:30:16 +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.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
- (nullable GPBFieldDescriptor *)fieldWithNumber:(uint32_t)fieldNumber;
|
2018-05-05 00:30:16 +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.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
- (nullable GPBFieldDescriptor *)fieldWithName:(NSString *)name;
|
2018-05-05 00:30:16 +00:00
|
|
|
|
2016-07-31 20:44:31 +00:00
|
|
|
@end
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/**
|
|
|
|
* Describes a proto field.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
@interface GPBFieldDescriptor : NSObject
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Name of the field. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, copy) NSString *name;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Number associated with the field. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) uint32_t number;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Data type contained in the field. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) GPBDataType dataType;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Whether it has a default value or not. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) BOOL hasDefaultValue;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Default value for the field. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) GPBGenericValue defaultValue;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Whether this field is required. Only valid for proto2 fields. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, getter=isRequired) BOOL required;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Whether this field is optional. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, getter=isOptional) BOOL optional;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Type of field (single, repeated, map). */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) GPBFieldType fieldType;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Type of the key if the field is a map. The value's type is -fieldType. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) GPBDataType mapKeyDataType;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Whether the field is packable. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, getter=isPackable) BOOL packable;
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/** The containing oneof if this field is part of one, nil otherwise. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, assign, nullable) GPBOneofDescriptor *containingOneof;
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Class of the message if the field is of message type. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, assign, nullable) Class msgClass;
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Descriptor for the enum if this field is an enum. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
|
|
|
|
|
2018-05-05 00:30:16 +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.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
- (BOOL)isValidEnumValue:(int32_t)value;
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/** @return Name for the text format, or nil if not known. */
|
2016-07-31 20:44:31 +00:00
|
|
|
- (nullable NSString *)textFormatName;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/**
|
|
|
|
* Describes a proto enum.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
@interface GPBEnumDescriptor : NSObject
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Name of the enum. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, copy) NSString *name;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Function that validates that raw values are valid enum values. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) GPBEnumValidationFunc enumVerifier;
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/**
|
|
|
|
* Returns the enum value name for the given raw enum.
|
|
|
|
*
|
|
|
|
* @param number The raw enum value.
|
|
|
|
*
|
|
|
|
* @return The name of the enum value passed, or nil if not valid.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
- (nullable NSString *)enumNameForValue:(int32_t)number;
|
2018-05-05 00:30:16 +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.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
- (BOOL)getValue:(nullable int32_t *)outValue forEnumName:(NSString *)name;
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/**
|
|
|
|
* Returns the text format for the given raw enum value.
|
|
|
|
*
|
|
|
|
* @param number The raw enum value.
|
|
|
|
*
|
|
|
|
* @return The text format name for the raw enum value, or nil if not valid.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
- (nullable NSString *)textFormatNameForValue:(int32_t)number;
|
|
|
|
|
2018-05-05 00:30:16 +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.
|
|
|
|
**/
|
|
|
|
- (BOOL)getValue:(nullable int32_t *)outValue forEnumTextFormatName:(NSString *)textFormatName;
|
|
|
|
|
2016-07-31 20:44:31 +00:00
|
|
|
@end
|
|
|
|
|
2018-05-05 00:30:16 +00:00
|
|
|
/**
|
|
|
|
* Describes a proto extension.
|
|
|
|
**/
|
2016-07-31 20:44:31 +00:00
|
|
|
@interface GPBExtensionDescriptor : NSObject<NSCopying>
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Field number under which the extension is stored. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) uint32_t fieldNumber;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** The containing message class, i.e. the class extended by this extension. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) Class containingMessageClass;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Data type contained in the extension. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) GPBDataType dataType;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Whether the extension is repeated. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, getter=isRepeated) BOOL repeated;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** Whether the extension is packable. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, getter=isPackable) BOOL packable;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** The class of the message if the extension is of message type. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, assign) Class msgClass;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** The singleton name for the extension. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly) NSString *singletonName;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** The enum descriptor if the extension is of enum type. */
|
2016-07-31 20:44:31 +00:00
|
|
|
@property(nonatomic, readonly, strong, nullable) GPBEnumDescriptor *enumDescriptor;
|
2018-05-05 00:30:16 +00:00
|
|
|
/** The default value for the extension. */
|
|
|
|
@property(nonatomic, readonly, nullable) id defaultValue;
|
|
|
|
|
2016-07-31 20:44:31 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|