• Home
Name Date Size #Lines LOC

..--

DevTools/03-May-2024-1,6571,279

ProtocolBuffers_OSX.xcodeproj/03-May-2024-1,4291,409

ProtocolBuffers_iOS.xcodeproj/03-May-2024-1,6981,675

Tests/03-May-2024-37,59533,430

google/protobuf/03-May-2024-3,8822,445

GPBArray.hD03-May-202420 KiB550227

GPBArray.mD03-May-202474.8 KiB2,5352,245

GPBArray_PackagePrivate.hD03-May-20243.4 KiB13156

GPBBootstrap.hD03-May-20244 KiB8626

GPBCodedInputStream.hD03-May-20244.7 KiB13133

GPBCodedInputStream.mD03-May-202415.1 KiB500434

GPBCodedInputStream_PackagePrivate.hD03-May-20245.1 KiB11558

GPBCodedOutputStream.hD03-May-202414.4 KiB345124

GPBCodedOutputStream.mD03-May-202440.7 KiB1,2221,058

GPBCodedOutputStream_PackagePrivate.hD03-May-20246.1 KiB12776

GPBDescriptor.hD03-May-20245.4 KiB14276

GPBDescriptor.mD03-May-202429.5 KiB964850

GPBDescriptor_PackagePrivate.hD03-May-202411.7 KiB314186

GPBDictionary.hD03-May-202488.2 KiB2,2441,348

GPBDictionary.mD03-May-2024463 KiB13,55611,877

GPBDictionary_PackagePrivate.hD03-May-202414.6 KiB489332

GPBExtensionInternals.hD03-May-20242.4 KiB5115

GPBExtensionInternals.mD03-May-202415.3 KiB381362

GPBExtensionRegistry.hD03-May-20243.7 KiB8311

GPBExtensionRegistry.mD03-May-20244 KiB10996

GPBMessage.hD03-May-202413.6 KiB30967

GPBMessage.mD03-May-2024118.8 KiB3,1852,944

GPBMessage_PackagePrivate.hD03-May-20246.3 KiB14438

GPBProtocolBuffers.hD03-May-20242.4 KiB5824

GPBProtocolBuffers.mD03-May-20242.7 KiB6157

GPBProtocolBuffers_RuntimeSupport.hD03-May-20242 KiB416

GPBRootObject.hD03-May-20242.1 KiB487

GPBRootObject.mD03-May-20248.6 KiB231205

GPBRootObject_PackagePrivate.hD03-May-20242 KiB477

GPBRuntimeTypes.hD03-May-20243.6 KiB10350

GPBUnknownField.hD03-May-20243.2 KiB9020

GPBUnknownField.mD03-May-202410.8 KiB327291

GPBUnknownFieldSet.hD03-May-20242.5 KiB6611

GPBUnknownFieldSet.mD03-May-202413.6 KiB424375

GPBUnknownFieldSet_PackagePrivate.hD03-May-20242.4 KiB6219

GPBUnknownField_PackagePrivate.hD03-May-20242 KiB5011

GPBUtilities.hD03-May-202410.9 KiB25846

GPBUtilities.mD03-May-202462.7 KiB1,7181,542

GPBUtilities_PackagePrivate.hD03-May-202413.2 KiB332190

GPBWellKnownTypes.hD03-May-20242.4 KiB5315

GPBWellKnownTypes.mD03-May-20244.2 KiB118100

GPBWireFormat.hD03-May-20242.9 KiB7333

GPBWireFormat.mD03-May-20243.4 KiB7970

README.mdD03-May-20245.7 KiB153113

generate_well_known_types.shD03-May-20242 KiB7752

README.md

1Protocol Buffers - Google's data interchange format
2===================================================
3
4[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf)
5
6Copyright 2008 Google Inc.
7
8This directory contains the Objective C Protocol Buffers runtime library.
9
10Requirements
11------------
12
13The Objective C implementation requires:
14
15- Objective C 2.0 Runtime (32bit & 64bit iOS, 64bit OS X).
16- Xcode 7.0 (or later).
17- The library code does *not* use ARC (for performance reasons), but it all can
18  be called from ARC code.
19
20Installation
21------------
22
23The full distribution pulled from github includes the sources for both the
24compiler (protoc) and the runtime (this directory). To build the compiler
25and run the runtime tests, you can use:
26
27     $ objectivec/DevTools/full_mac_build.sh
28
29This will generate the `src/protoc` binary.
30
31Building
32--------
33
34There are two ways to include the Runtime sources in your project:
35
36Add `objectivec/\*.h` & `objectivec/GPBProtocolBuffers.m` to your project.
37
38*or*
39
40Add `objectivec/\*.h` & `objectivec/\*.m` except for
41`objectivec/GPBProtocolBuffers.m` to your project.
42
43
44If the target is using ARC, remember to turn off ARC (`-fno-objc-arc`) for the
45`.m` files.
46
47The files generated by `protoc` for the `*.proto` files (`\*.pbobjc.h' and
48`\*.pbobjc.m`) are then also added to the target.
49
50Usage
51-----
52
53The objects generated for messages should work like any other Objective C
54object. They are mutable objects, but if you don't change them, they are safe
55to share between threads (similar to passing an NSMutableDictionary between
56threads/queues; as long as no one mutates it, things are fine).
57
58There are a few behaviors worth calling out:
59
60A property that is type NSString\* will never return nil. If the value is
61unset, it will return an empty string (@""). This is inpart to align things
62with the Protocol Buffers spec which says the default for strings is an empty
63string, but also so you can always safely pass them to isEqual:/compare:, etc.
64and have deterministic results.
65
66A property that is type NSData\* also won't return nil, it will return an empty
67data ([NSData data]). The reasoning is the same as for NSString not returning
68nil.
69
70A property that is another GPBMessage class also will not return nil. If the
71field wasn't already set, you will get a instance of the correct class. This
72instance will be a temporary instance unless you mutate it, at which point it
73will be attached to its parent object. We call this pattern *autocreators*.
74Similar to NSString and NSData properties it makes things a little safer when
75using them with isEqual:/etc.; but more importantly, this allows you to write
76code that uses Objective C's property dot notation to walk into nested objects
77and access and/or assign things without having to check that they are not nil
78and create them each step along the way. You can write this:
79
80```
81- (void)updateRecord:(MyMessage *)msg {
82  ...
83  // Note: You don't have to check subMessage and otherMessage for nil and
84  // alloc/init/assign them back along the way.
85  msg.subMessage.otherMessage.lastName = @"Smith";
86  ...
87}
88```
89
90If you want to check if a GPBMessage property is present, there is always as
91`has\[NAME\]` property to go with the main property to check if it is set.
92
93A property that is of an Array or Dictionary type also provides *autocreator*
94behavior and will never return nil. This provides all the same benefits you
95see for the message properties. Again, you can write:
96
97```
98- (void)updateRecord:(MyMessage *)msg {
99  ...
100  // Note: Just like above, you don't have to check subMessage and otherMessage
101  // for nil and alloc/init/assign them back along the way. You also don't have
102  // to create the siblingsArray, you can safely just append to it.
103  [msg.subMessage.otherMessage.siblingsArray addObject:@"Pat"];
104  ...
105}
106```
107
108If you are inspecting a message you got from some other place (server, disk,
109etc), you may want to check if the Array or Dictionary has entries without
110causing it to be created for you. For this, there is always a `\[NAME\]_Count`
111property also provided that can return zero or the real count, but won't trigger
112the creation.
113
114For primitive type fields (ints, floats, bools, enum) in messages defined in a
115`.proto` file that use *proto2* syntax there are conceptual differences between
116having an *explicit* and *default* value. You can always get the value of the
117property. In the case that it hasn't been set you will get the default. In
118cases where you need to know whether it was set explicitly or you are just
119getting the default, you can use the `has\[NAME\]` property. If the value has
120been set, and you want to clear it, you can set the `has\[NAME\]` to `NO`.
121*proto3* syntax messages do away with this concept, thus the default values are
122never included when the message is encoded.
123
124The Objective C classes/enums can be used from Swift code.
125
126Objective C Generator Options
127-----------------------------
128
129**objc_class_prefix=\<prefix\>** (no default)
130
131Since Objective C uses a global namespace for all of its classes, there can
132be collisions. This option provides a prefix that will be added to the Enums
133and Objects (for messages) generated from the proto. Convention is to base
134the prefix on the package the proto is in.
135
136Contributing
137------------
138
139Please make updates to the tests along with changes. If just changing the
140runtime, the Xcode projects can be used to build and run tests. If your change
141also requires changes to the generated code,
142`objectivec/DevTools/full_mac_build.sh` can be used to easily rebuild and test
143changes. Passing `-h` to the script will show the addition options that could
144be useful.
145
146Documentation
147-------------
148
149The complete documentation for Protocol Buffers is available via the
150web at:
151
152    https://developers.google.com/protocol-buffers/
153