@@ -15,8 +15,8 @@ generated code are highlighted - note that these differences are in the
1515generated code as described in this document, not the base message
1616classes/interfaces, which are the same in both versions. You should read the
1717[ proto2 language guide] ( /programming-guides/proto ) and/or
18- [ proto3 language guide] ( /programming-guides/proto3 ) before reading this
19- document.
18+ [ proto3 language guide] ( /programming-guides/proto3 )
19+ before reading this document.
2020
2121## Compiler Invocation {#invocation}
2222
@@ -267,17 +267,19 @@ The compiler will generate the following accessor methods:
267267 whatever value is written into the given string.
268268- ` void clear_foo() ` : Clears the value of the field. After calling this,
269269 ` has_foo() ` will return ` false ` and ` foo() ` will return the default value.
270- - ` void set_allocated_foo(string* value) ` : Sets the ` string ` object to the
271- field and frees the previous field value if it exists. If the ` string `
272- pointer is not ` NULL ` , the message takes ownership of the allocated ` string `
273- object and ` has_foo() ` will return ` true ` . The message is free to delete the
274- allocated ` string ` object at any time, so references to the object may be
275- invalidated. Otherwise, if the ` value ` is ` NULL ` , the behavior is the same
276- as calling ` clear_foo() ` .
277- - ` string* release_foo() ` : Releases the ownership of the field and returns the
278- pointer of the ` string ` object. After calling this, caller takes the
279- ownership of the allocated ` string ` object, ` has_foo() ` will return ` false ` ,
280- and ` foo() ` will return the default value.
270+ - ` void set_allocated_foo(string* value) ` :
271+ Sets the ` string `
272+ object to the field and frees the previous field value if it exists. If the
273+ ` string ` pointer is not ` NULL ` , the message takes ownership of the allocated
274+ ` string ` object and ` has_foo() ` will return ` true ` . The message is free to
275+ delete the allocated ` string ` object at any time, so references to the
276+ object may be invalidated. Otherwise, if the ` value ` is ` NULL ` , the behavior
277+ is the same as calling ` clear_foo() ` .
278+ - ` string* release_foo() ` :
279+ Releases the
280+ ownership of the field and returns the pointer of the ` string ` object. After
281+ calling this, caller takes the ownership of the allocated ` string ` object,
282+ ` has_foo() ` will return ` false ` , and ` foo() ` will return the default value.
281283
282284### Singular String Fields (proto3) {#proto3_string}
283285
@@ -309,16 +311,18 @@ The compiler will generate the following accessor methods:
309311 return whatever value is written into the given string.
310312- ` void clear_foo() ` : Clears the value of the field. After calling this,
311313 ` foo() ` will return the empty string/empty bytes.
312- - ` void set_allocated_foo(string* value) ` : Sets the ` string ` object to the
313- field and frees the previous field value if it exists. If the ` string `
314- pointer is not ` NULL ` , the message takes ownership of the allocated ` string `
315- object. The message is free to delete the allocated ` string ` object at any
316- time, so references to the object may be invalidated. Otherwise, if the
317- ` value ` is ` NULL ` , the behavior is the same as calling ` clear_foo() ` .
318- - ` string* release_foo() ` : Releases the ownership of the field and returns the
319- pointer of the ` string ` object. After calling this, caller takes the
320- ownership of the allocated ` string ` object and ` foo() ` will return the empty
321- string/empty bytes.
314+ - ` void set_allocated_foo(string* value) ` :
315+ Sets the ` string `
316+ object to the field and frees the previous field value if it exists. If the
317+ ` string ` pointer is not ` NULL ` , the message takes ownership of the allocated
318+ ` string ` object. The message is free to delete the allocated ` string ` object
319+ at any time, so references to the object may be invalidated. Otherwise, if
320+ the ` value ` is ` NULL ` , the behavior is the same as calling ` clear_foo() ` .
321+ - ` string* release_foo() ` :
322+ Releases the
323+ ownership of the field and returns the pointer of the ` string ` object. After
324+ calling this, caller takes the ownership of the allocated ` string ` object
325+ and ` foo() ` will return the empty string/empty bytes.
322326
323327### Singular Enum Fields (proto2) {#enum_field}
324328
@@ -465,8 +469,8 @@ The compiler will generate the following accessor methods:
465469- ` int foo_size() const ` : Returns the number of elements currently in the
466470 field.
467471- ` const string& foo(int index) const ` : Returns the element at the given
468- zero-based index. Calling this method with index outside of [ 0, foo_size()-1 ]
469- yields undefined behavior.
472+ zero-based index. Calling this method with index outside of [ 0,
473+ foo_size()-1 ] yields undefined behavior.
470474- ` void set_foo(int index, const string& value) ` : Sets the value of the
471475 element at the given zero-based index.
472476- ` void set_foo(int index, const char* value) ` : Sets the value of the element
@@ -885,7 +889,8 @@ it is put into a map field as if it is a known enum value.
885889
886890## Any
887891
888- Given an [ ` Any ` ] ( /programming-guides/proto3#any ) field like this:
892+ Given an [ ` Any ` ] ( /programming-guides/proto3#any ) field
893+ like this:
889894
890895``` proto
891896import "google/protobuf/any.proto";
0 commit comments