blob: 1301b4368815cf0df3ed8508ccea2ef17f83ed40 [file] [log] [blame]
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc. All rights reserved.
3// https://developers.google.com/protocol-buffers/
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above
12// copyright notice, this list of conditions and the following disclaimer
13// in the documentation and/or other materials provided with the
14// distribution.
15// * Neither the name of Google Inc. nor the names of its
16// contributors may be used to endorse or promote products derived from
17// this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
30
31#import <Foundation/Foundation.h>
32
Thomas Van Lentend846b0b2015-06-08 16:24:57 -040033#import "GPBArray.h"
Thomas Van Lenten30650d82015-05-01 08:57:16 -040034#import "GPBMessage.h"
Thomas Van Lentend846b0b2015-06-08 16:24:57 -040035#import "GPBRuntimeTypes.h"
Thomas Van Lenten30650d82015-05-01 08:57:16 -040036
37CF_EXTERN_C_BEGIN
38
Thomas Van Lenten8c889572015-06-16 16:45:14 -040039NS_ASSUME_NONNULL_BEGIN
40
Thomas Van Lentend846b0b2015-06-08 16:24:57 -040041// Generates a string that should be a valid "Text Format" for the C++ version
Thomas Van Lenten30650d82015-05-01 08:57:16 -040042// of Protocol Buffers. lineIndent can be nil if no additional line indent is
43// needed. The comments provide the names according to the ObjC library, they
44// most likely won't exactly match the original .proto file.
Thomas Van Lenten8c889572015-06-16 16:45:14 -040045NSString *GPBTextFormatForMessage(GPBMessage *message,
46 NSString * __nullable lineIndent);
Thomas Van Lenten30650d82015-05-01 08:57:16 -040047NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *unknownSet,
Thomas Van Lenten8c889572015-06-16 16:45:14 -040048 NSString * __nullable lineIndent);
Thomas Van Lenten30650d82015-05-01 08:57:16 -040049
Thomas Van Lentend846b0b2015-06-08 16:24:57 -040050//
51// Test if the given field is set on a message.
52//
53BOOL GPBMessageHasFieldNumberSet(GPBMessage *self, uint32_t fieldNumber);
54BOOL GPBMessageHasFieldSet(GPBMessage *self, GPBFieldDescriptor *field);
55
56//
57// Clear the given field of a message.
58//
59void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field);
60
61//%PDDM-EXPAND GPB_ACCESSORS()
62// This block of code is generated, do not edit it directly.
63
64
65//
66// Get/Set the given field of a message.
67//
68
69// Single Fields
70
71NSData *GPBGetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field);
72void GPBSetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field, NSData *value);
73
74NSString *GPBGetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field);
75void GPBSetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field, NSString *value);
76
77GPBMessage *GPBGetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field);
78void GPBSetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
79
80GPBMessage *GPBGetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field);
81void GPBSetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value);
82
83BOOL GPBGetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field);
84void GPBSetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field, BOOL value);
85
86int32_t GPBGetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
87void GPBSetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
88
89uint32_t GPBGetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field);
90void GPBSetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field, uint32_t value);
91
92int64_t GPBGetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
93void GPBSetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field, int64_t value);
94
95uint64_t GPBGetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field);
96void GPBSetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field, uint64_t value);
97
98float GPBGetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field);
99void GPBSetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field, float value);
100
101double GPBGetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field);
102void GPBSetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field, double value);
103
104// Get/Set the given enum field of a message. You can only Set values that are
105// members of the enum. For proto3, when doing a Get, if the value isn't a
106// memeber of the enum, kGPBUnrecognizedEnumeratorValue will be returned. The
107// the functions with "Raw" in the will bypass all checks.
108int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
109void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
110int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
111void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
112
113// Repeated Fields
114
115// The object will/should be GPB*Array or NSMutableArray based on the field's
116// type.
117id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
118void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array);
119
120// Map Fields
121
122// The object will/should be GPB*Dictionary or NSMutableDictionary based on the
123// field's type.
124id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
125void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dictionary);
126
127//%PDDM-EXPAND-END GPB_ACCESSORS()
128
129// Returns an empty NSData to assign to byte fields when you wish
130// to assign them to empty. Prevents allocating a lot of little [NSData data]
131// objects.
132NSData *GPBEmptyNSData(void) __attribute__((pure));
133
Thomas Van Lenten8c889572015-06-16 16:45:14 -0400134NS_ASSUME_NONNULL_END
135
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400136CF_EXTERN_C_END
137
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400138
139//%PDDM-DEFINE GPB_ACCESSORS()
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400140//%
Thomas Van Lentend846b0b2015-06-08 16:24:57 -0400141//%//
142//%// Get/Set the given field of a message.
143//%//
144//%
145//%// Single Fields
146//%
147//%GPB_ACCESSOR_SINGLE_FULL(Bytes, NSData, *)
148//%GPB_ACCESSOR_SINGLE_FULL(String, NSString, *)
149//%GPB_ACCESSOR_SINGLE_FULL(Message, GPBMessage, *)
150//%GPB_ACCESSOR_SINGLE_FULL(Group, GPBMessage, *)
151//%GPB_ACCESSOR_SINGLE(Bool, BOOL)
152//%GPB_ACCESSOR_SINGLE(Int32, int32_t)
153//%GPB_ACCESSOR_SINGLE(UInt32, uint32_t)
154//%GPB_ACCESSOR_SINGLE(Int64, int64_t)
155//%GPB_ACCESSOR_SINGLE(UInt64, uint64_t)
156//%GPB_ACCESSOR_SINGLE(Float, float)
157//%GPB_ACCESSOR_SINGLE(Double, double)
158//%// Get/Set the given enum field of a message. You can only Set values that are
159//%// members of the enum. For proto3, when doing a Get, if the value isn't a
160//%// memeber of the enum, kGPBUnrecognizedEnumeratorValue will be returned. The
161//%// the functions with "Raw" in the will bypass all checks.
162//%int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field);
163//%void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
164//%int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field);
165//%void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field, int32_t value);
166//%
167//%// Repeated Fields
168//%
169//%// The object will/should be GPB*Array or NSMutableArray based on the field's
170//%// type.
171//%id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field);
172//%void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array);
173//%
174//%// Map Fields
175//%
176//%// The object will/should be GPB*Dictionary or NSMutableDictionary based on the
177//%// field's type.
178//%id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field);
179//%void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dictionary);
180//%
181
182//%PDDM-DEFINE GPB_ACCESSOR_SINGLE(NAME, TYPE)
183//%GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, )
184//%PDDM-DEFINE GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, TisP)
185//%TYPE TisP##GPBGetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field);
186//%void GPBSetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field, TYPE TisP##value);
187//%