@@ -115,9 +115,13 @@ In addition to these methods, the `Foo` class defines the following methods:
115115- ` Foo& operator=(Foo&& other) ` : Move-assignment operator.
116116- ` void Swap(Foo* other) ` : Swap content with another message.
117117- ` const UnknownFieldSet& unknown_fields() const ` : Returns the set of unknown
118- fields encountered while parsing this message.
118+ fields encountered while parsing this message. If `option optimize_for =
119+ LITE_RUNTIME` is specified in the ` .proto` file, then the return type
120+ changes to ` std::string& ` .
119121- ` UnknownFieldSet* mutable_unknown_fields() ` : Returns a pointer to the
120- mutable set of unknown fields encountered while parsing this message.
122+ mutable set of unknown fields encountered while parsing this message. If
123+ ` option optimize_for = LITE_RUNTIME ` is specified in the ` .proto ` file, then
124+ the return type changes to ` std::string* ` .
121125
122126The class also defines the following static methods:
123127
@@ -132,6 +136,38 @@ The class also defines the following static methods:
132136 default instance of a message can be used as a factory by calling its
133137 ` New() ` method.
134138
139+ ### Generated Filenames {#generated-filenames}
140+
141+ [ Reserved keywords] ( https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/compiler/cpp/helpers.cc#L4 )
142+ are appended with an underscore in the generated output.
143+
144+ For example, the following proto3 definition syntax:
145+
146+ ``` proto
147+ message MyMessage {
148+ string false = 1;
149+ string myFalse = 2;
150+ }
151+ ```
152+
153+ generates the following partial output:
154+
155+ ``` cpp
156+ void clear_false_ () ;
157+ const std::string& false_ () const ;
158+ void set_false_ (Arg_ && arg, Args_ ... args);
159+ std::string* mutable_false_ ();
160+ PROTOBUF_NODISCARD std::string* release_false_ ();
161+ void set_allocated_false_ (std::string* ptr);
162+
163+ void clear_myfalse() ;
164+ const std::string& myfalse() const;
165+ void set_myfalse(Arg_ && arg, Args_ ... args);
166+ std::string* mutable_myfalse();
167+ PROTOBUF_NODISCARD std::string* release_myfalse();
168+ void set_allocated_myfalse(std::string* ptr);
169+ ```
170+
135171### Nested Types
136172
137173A message can be declared inside another message. For example:
@@ -184,7 +220,7 @@ any method inherited from `Message` or accessing the message through other ways
184220Correspondingly, the value of the returned pointer is never guaranteed to be the
185221same across two different invocations of the accessor.
186222
187- ### Singular Numeric Fields (proto2)
223+ ### Optional Numeric Fields (proto2 and proto3 )
188224
189225For either of these field definitions:
190226
@@ -207,7 +243,7 @@ For other numeric field types (including `bool`), `int32` is replaced with the
207243corresponding C++ type according to the
208244[ scalar value types table] ( /programming-guides/proto3#scalar ) .
209245
210- ### Singular Numeric Fields (proto3)
246+ ### Implicit Presence Numeric Fields (proto3)
211247
212248For these field definitions:
213249
@@ -229,7 +265,7 @@ For other numeric field types (including `bool`), `int32` is replaced with the
229265corresponding C++ type according to the
230266[ scalar value types table] ( /programming-guides/proto3#scalar ) .
231267
232- ### Singular String/Bytes Fields (proto2) {#string}
268+ ### Optional String/Bytes Fields (proto2 and proto3 ) {#string}
233269
234270For any of these field definitions:
235271
@@ -278,7 +314,7 @@ The compiler will generate the following accessor methods:
278314 calling this, caller takes the ownership of the allocated ` string ` object,
279315 ` has_foo() ` will return ` false ` , and ` foo() ` will return the default value.
280316
281- ### Singular String/Bytes Fields (proto3) {#proto3_string}
317+ ### Implicit Presence String/Bytes Fields (proto3) {#proto3_string}
282318
283319For any of these field definitions:
284320
@@ -355,7 +391,7 @@ The compiler will generate the following accessor methods:
355391 ` foo() ` will return an empty ` Cord ` (proto3) or the default value (proto2).
356392- ` bool has_foo() ` : Returns ` true ` if the field is set.
357393
358- ### Singular Enum Fields (proto2) {#enum_field}
394+ ### Optional Enum Fields (proto2 and proto3 ) {#enum_field}
359395
360396Given the enum type:
361397
@@ -386,7 +422,7 @@ The compiler will generate the following accessor methods:
386422- ` void clear_foo() ` : Clears the value of the field. After calling this,
387423 ` has_foo() ` will return ` false ` and ` foo() ` will return the default value.
388424
389- ### Singular Enum Fields (proto3)
425+ ### Implicit Presence Enum Fields (proto3)
390426
391427Given the enum type:
392428
@@ -414,7 +450,7 @@ The compiler will generate the following accessor methods:
414450- ` void clear_foo() ` : Clears the value of the field. After calling this,
415451 ` foo() ` will return the default value.
416452
417- ### Singular Embedded Message Fields {#embeddedmessage}
453+ ### Optional Embedded Message Fields (proto2 and proto3) {#embeddedmessage}
418454
419455Given the message type:
420456
0 commit comments