diff --git a/content/_index.md b/content/_index.md index 471fe8375..983478d15 100644 --- a/content/_index.md +++ b/content/_index.md @@ -1,25 +1,26 @@ +++ -title = "Protocol Buffers" +title = "Protobuf" weight = 5 toc_hide = "true" -description = "Protocol Buffers are language-neutral, platform-neutral extensible mechanisms for serializing structured data." +description = "Protobuf is a language-neutral, platform-neutral extensible mechanism for serializing structured data." type = "docs" no_list = "true" +++ -## What Are Protocol Buffers? +## What Is Protobuf? -Protocol buffers are Google's language-neutral, platform-neutral, extensible -mechanism for serializing structured data – think XML, but smaller, faster, and -simpler. You define how you want your data to be structured once, then you can -use special generated source code to easily write and read your structured data -to and from a variety of data streams and using a variety of languages. +Protobuf ("Protocol Buffers") is Google's language-neutral, platform-neutral, +extensible mechanism for serializing structured data – think XML, but smaller, +faster, and simpler. You define how you want your data to be structured once, +then you can use special generated source code to easily write and read your +structured data to and from a variety of data streams and using a variety of +languages. ## Pick Your Favorite Language -Protocol buffers support generated code in C++, C#, Dart, Go, Java, -Kotlin, -Objective-C, Python, Rust, and Ruby. With proto3, you can also work with PHP. +Protobuf supports generated code in C++, C#, Dart, Go, +Java, Kotlin, Objective-C, Python, Rust, and Ruby. With proto3, +you can also work with PHP. ## Example Implementation @@ -67,7 +68,7 @@ email = john.email();
Packages | |
|---|---|
Auxiliary classes used for I/O. | |
Utility classes. | |
Implementation of the Protocol Buffer compiler. | |
Files | |
|---|---|
This file defines an Arena allocator for better allocation performance. | |
This file contains classes which describe a type of protocol message. | |
Protocol buffer representations of descriptors. | |
Interface for manipulating databases of descriptors. | |
Defines an implementation of Message which can emulate types which are not known at compile-time. | |
This file defines the map container and its helpers to support protobuf maps. | |
Defines Message, the abstract interface implemented by non-lite protocol message objects. | |
Defines MessageLite, the abstract interface implemented by all (lite and non-lite) protocol message objects. | |
RepeatedField and RepeatedPtrField are used by generated protocol message classes to manipulate repeated fields. | |
DEPRECATED: This module declares the abstract interfaces underlying proto2 RPC services. | |
Utilities for printing and parsing protocol messages in a human-readable, text-based format. | |
Contains classes used to keep track of unrecognized fields seen while parsing a protocol message. | |
Auxiliary classes used for I/O.
The Protocol Buffer library uses the classes in this package to deal with I/O and encoding/decoding raw bytes. Most users will not need to deal with this package. However, users who want to adapt the system to work with their own I/O abstractions – e.g., to allow Protocol Buffers to be read from a different kind of input stream without the need for a temporary buffer – should take a closer look.
-Files | |
|---|---|
This file contains the CodedInputStream and CodedOutputStream classes, which wrap a ZeroCopyInputStream or ZeroCopyOutputStream, respectively, and allow you to read or write individual pieces of data in various formats. | |
Utility class for writing text to a ZeroCopyOutputStream. | |
Class for parsing tokenized text from a ZeroCopyInputStream. | |
This file contains the ZeroCopyInputStream and ZeroCopyOutputStream interfaces, which represent abstract I/O streams to and from which protocol buffers can be read and written. | |
This file contains common implementations of the interfaces defined in zero_copy_stream.h which are only included in the full (non-lite) protobuf library. | |
This file contains common implementations of the interfaces defined in zero_copy_stream.h which are included in the "lite" protobuf library. | |
Utility classes.
This package contains various utilities for message comparison, JSON conversion, well known types, etc.
-Files | |
|---|---|
Defines classes for field comparison. | |
Defines utilities for the FieldMask well known type. | |
Utility functions to convert between protobuf binary format and proto3 JSON format. | |
This file defines static methods and classes for comparing Protocol Messages. | |
Defines utilities for the Timestamp and Duration well known types. | |
Defines a TypeResolver for the Any message. | |
Defines utilities for the TypeResolver. | |
Implementation of the Protocol Buffer compiler.
This package contains code for parsing .proto files and generating code based on them. There are two reasons you might be interested in this package:
+Packages | |
|---|---|
Auxiliary classes used for I/O. | |
Utility classes. | |
Implementation of the Protobuf compiler. | |
Files | |
|---|---|
This file defines an Arena allocator for better allocation performance. | |
This file contains classes which describe a type of protocol message. | |
Protobuf representations of descriptors. | |
Interface for manipulating databases of descriptors. | |
Defines an implementation of Message which can emulate types which are not known at compile-time. | |
This file defines the map container and its helpers to support Protobuf maps. | |
Defines Message, the abstract interface implemented by non-lite protocol message objects. | |
Defines MessageLite, the abstract interface implemented by all (lite and non-lite) protocol message objects. | |
RepeatedField and RepeatedPtrField are used by generated protocol message classes to manipulate repeated fields. | |
DEPRECATED: This module declares the abstract interfaces underlying proto2 RPC services. | |
Utilities for printing and parsing protocol messages in a human-readable, text-based format. | |
Contains classes used to keep track of unrecognized fields seen while parsing a protocol message. | |
Auxiliary classes used for I/O.
The Protobuf library uses the classes in this package to deal with I/O and encoding/decoding raw bytes. Most users will not need to deal with this package. However, users who want to adapt the system to work with their own I/O abstractions – e.g., to allow Protobuf messages to be read from a different kind of input stream without the need for a temporary buffer – should take a closer look.
+Files | |
|---|---|
This file contains the CodedInputStream and CodedOutputStream classes, which wrap a ZeroCopyInputStream or ZeroCopyOutputStream, respectively, and allow you to read or write individual pieces of data in various formats. | |
Utility class for writing text to a ZeroCopyOutputStream. | |
Class for parsing tokenized text from a ZeroCopyInputStream. | |
This file contains the ZeroCopyInputStream and ZeroCopyOutputStream interfaces, which represent abstract I/O streams to and from which Protobuf messages can be read and written. | |
This file contains common implementations of the interfaces defined in zero_copy_stream.h which are only included in the full (non-lite) Protobuf library. | |
This file contains common implementations of the interfaces defined in zero_copy_stream.h which are included in the "lite" Protobuf library. | |
Utility classes.
This package contains various utilities for message comparison, JSON conversion, well known types, etc.
+Files | |
|---|---|
Defines classes for field comparison. | |
Defines utilities for the FieldMask well known type. | |
Utility functions to convert between Protobuf binary format and proto3 JSON format. | |
This file defines static methods and classes for comparing Protocol Messages. | |
Defines utilities for the Timestamp and Duration well known types. | |
Defines a TypeResolver for the Any message. | |
Defines utilities for the TypeResolver. | |
Implementation of the Protobuf compiler.
This package contains code for parsing .proto files and generating code based on them. There are two reasons you might be interested in this package:
This protocol is implemented by all arena-enabled proto2 message classes as well as protobuf container types like RepeatedPtrField and Map. The protocol is internal to protobuf and is not guaranteed to be stable. Non-proto types should not rely on this protocol.
+This protocol is implemented by all arena-enabled proto2 message classes as well as Protobuf container types like RepeatedPtrField and Map. The protocol is internal to Protobuf and is not guaranteed to be stable. Non-proto types should not rely on this protocol.
Members | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
const size_t | kBlockOverhead = =
internal::ThreadSafeArena::kBlockHeaderSize +
diff --git a/content/reference/cpp/api-docs/google.protobuf.common.md b/content/reference/cpp/api-docs/google.protobuf.common.md
index abd2f99d7..767097fe7 100644
--- a/content/reference/cpp/api-docs/google.protobuf.common.md
+++ b/content/reference/cpp/api-docs/google.protobuf.common.md
@@ -2,7 +2,7 @@
title = "common.h"
toc_hide = "true"
linkTitle = "C++"
-description = "This section contains reference documentation for working with protocol buffer classes in C++."
+description = "This section contains reference documentation for working with Protobuf classes in C++."
type = "docs"
+++
diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.code_generator.md b/content/reference/cpp/api-docs/google.protobuf.compiler.code_generator.md
index 9ca8ebba6..7ba7e5509 100644
--- a/content/reference/cpp/api-docs/google.protobuf.compiler.code_generator.md
+++ b/content/reference/cpp/api-docs/google.protobuf.compiler.code_generator.md
@@ -2,7 +2,7 @@
title = "code_generator.h"
toc_hide = "true"
linkTitle = "C++"
-description = "This section contains reference documentation for working with protocol buffer classes in C++."
+description = "This section contains reference documentation for working with Protobuf classes in C++."
type = "docs"
+++
@@ -12,13 +12,13 @@ type = "docs"
class CodeGenerator
The abstract interface to a class which generates code implementing a particular proto file in a particular language. A number of these may be registered with CommandLineInterface to support various languages. -Known subclasses:
FEATURE_PROTO3_OPTIONAL = = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FEATURE_PROTO3_OPTIONAL |
virtual bool CodeGenerator::Generate(
const FileDescriptor * file,
const std::string & parameter,
GeneratorContext * generator_context,
std::string * error) const = 0Generates code for the given proto file, generating one or more files in the given output directory.
A parameter to be passed to the generator can be specified on the command line. This is intended to be used to pass generator specific parameters. It is empty if no parameter was given. ParseGeneratorParameter (below), can be used to accept multiple parameters within the single parameter command line flag.
+Known subclasses:
Members | |
|---|---|
enum | FeatureSync with plugin.proto. more... |
| CodeGenerator() |
virtual | ~CodeGenerator() |
virtual bool | Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) const = 0Generates code for the given proto file, generating one or more files in the given output directory. more... |
virtual bool | GenerateAll(const std::vector< const FileDescriptor * > & files, const std::string & parameter, GeneratorContext * generator_context, std::string * error) constGenerates code for all given proto files. more... |
virtual uint64_t | GetSupportedFeatures() constImplement this to indicate what features this code generator supports. more... |
virtual bool | HasGenerateAll() constThis is no longer used, but this class is part of the open-source Protobuf library, so it has to remain to keep vtables the same for the current version of the library. more... |
enum CodeGenerator::Feature {
FEATURE_PROTO3_OPTIONAL = = 1
}Sync with plugin.proto.
| FEATURE_PROTO3_OPTIONAL |
virtual bool CodeGenerator::Generate(
const FileDescriptor * file,
const std::string & parameter,
GeneratorContext * generator_context,
std::string * error) const = 0Generates code for the given proto file, generating one or more files in the given output directory.
A parameter to be passed to the generator can be specified on the command line. This is intended to be used to pass generator specific parameters. It is empty if no parameter was given. ParseGeneratorParameter (below), can be used to accept multiple parameters within the single parameter command line flag.
Returns true if successful. Otherwise, sets *error to a description of the problem (e.g. "invalid parameter") and returns false.
virtual bool CodeGenerator::GenerateAll(
const std::vector< const FileDescriptor * > & files,
const std::string & parameter,
GeneratorContext * generator_context,
std::string * error) constGenerates code for all given proto files.
WARNING: The canonical code generator design produces one or two output files per input .proto file, and we do not wish to encourage alternate designs.
A parameter is given as passed on the command line, as in |Generate()| above.
Returns true if successful. Otherwise, sets *error to a description of the problem (e.g. "invalid parameter") and returns false.
virtual uint64_t CodeGenerator::GetSupportedFeatures() constImplement this to indicate what features this code generator supports.
This should be a bitwise OR of features from the Features enum in plugin.proto.
-virtual bool CodeGenerator::HasGenerateAll() constThis is no longer used, but this class is part of the opensource protobuf library, so it has to remain to keep vtables the same for the current version of the library.
When protobufs does a api breaking change, the method can be removed.
+virtual bool CodeGenerator::HasGenerateAll() constThis is no longer used, but this class is part of the open-source Protobuf library, so it has to remain to keep vtables the same for the current version of the library.
When Protobuf does an API breaking change, the method can be removed.
#include <google/protobuf/compiler/code_generator.h>
namespace google::protobuf::compiler
CodeGenerators generate one or more files in a given directory.
This abstract interface represents the directory to which the CodeGenerator is to write and other information about the context in which the Generator runs.
Members | |
|---|---|
| GeneratorContext() |
virtual | ~GeneratorContext() |
virtual io::ZeroCopyOutputStream * | Open(const std::string & filename) = 0Opens the given file, truncating it if it exists, and returns a ZeroCopyOutputStream that writes to the file. more... |
virtual io::ZeroCopyOutputStream * | OpenForAppend(const std::string & filename)Similar to Open() but the output will be appended to the file if exists. |
virtual io::ZeroCopyOutputStream * | OpenForInsert(const std::string & filename, const std::string & insertion_point)Creates a ZeroCopyOutputStream which will insert code into the given file at the given insertion point. more... |
virtual io::ZeroCopyOutputStream * | OpenForInsertWithGeneratedCodeInfo(const std::string & filename, const std::string & insertion_point, const google::protobuf::GeneratedCodeInfo & info)Similar to OpenForInsert, but if info is non-empty, will open (or create) filename.pb.meta and insert info at the appropriate place with the necessary shifts. more... |
virtual void | ListParsedFiles(std::vector< const FileDescriptor * > * output)Returns a vector of FileDescriptors for all the files being compiled in this run. more... |
virtual void | GetCompilerVersion(Version * version) constRetrieves the version number of the protocol compiler associated with this GeneratorContext. |
virtual io::ZeroCopyOutputStream *
GeneratorContext::Open(
const std::string & filename) = 0Opens the given file, truncating it if it exists, and returns a ZeroCopyOutputStream that writes to the file.
The caller takes ownership of the returned object. This method never fails (a dummy stream will be returned instead).
The filename given should be relative to the root of the source tree. E.g. the C++ generator, when generating code for "foo/bar.proto", will generate the files "foo/bar.pb.h" and "foo/bar.pb.cc"; note that "foo/" is included in these filenames. The filename is not allowed to contain "." or ".." components.
diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.command_line_interface.md b/content/reference/cpp/api-docs/google.protobuf.compiler.command_line_interface.md index 0dbfe78ed..185026ecd 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.command_line_interface.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.command_line_interface.md @@ -2,7 +2,7 @@ title = "command_line_interface.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.cpp_generator.md b/content/reference/cpp/api-docs/google.protobuf.compiler.cpp_generator.md index d29feb4f1..48672e93b 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.cpp_generator.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.cpp_generator.md @@ -2,7 +2,7 @@ title = "cpp_generator.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.csharp_generator.md b/content/reference/cpp/api-docs/google.protobuf.compiler.csharp_generator.md index 86881202d..bfe0bb7d0 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.csharp_generator.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.csharp_generator.md @@ -2,7 +2,7 @@ title = "csharp_generator.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.csharp_names.md b/content/reference/cpp/api-docs/google.protobuf.compiler.csharp_names.md index 529e48e62..081550685 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.csharp_names.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.csharp_names.md @@ -2,7 +2,7 @@ title = "csharp_names.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.importer.md b/content/reference/cpp/api-docs/google.protobuf.compiler.importer.md index 2df4c25fa..1804ffea0 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.importer.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.importer.md @@ -2,7 +2,7 @@ title = "importer.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.java_generator.md b/content/reference/cpp/api-docs/google.protobuf.compiler.java_generator.md index 98c6536a4..9ca74e12d 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.java_generator.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.java_generator.md @@ -2,7 +2,7 @@ title = "java_generator.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.java_names.md b/content/reference/cpp/api-docs/google.protobuf.compiler.java_names.md index 9a1103b96..f8b33d871 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.java_names.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.java_names.md @@ -2,7 +2,7 @@ title = "java_names.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.javanano_generator.md b/content/reference/cpp/api-docs/google.protobuf.compiler.javanano_generator.md index 7ec4bac30..a293ed869 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.javanano_generator.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.javanano_generator.md @@ -2,7 +2,7 @@ title = "javanano_generator.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.js_generator.md b/content/reference/cpp/api-docs/google.protobuf.compiler.js_generator.md index 2fc00b01b..6ab34ccb5 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.js_generator.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.js_generator.md @@ -2,7 +2,7 @@ title = "js_generator.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ @@ -10,9 +10,9 @@ type = "docs"bool GeneratorOptions::annotate_codeIf true, we should append annotations as comments on the last line for generated .js file.
Annotations used by tools like to provide cross-references between .js and .proto files. Annotations are encoded as base64 proto of GeneratedCodeInfo message (see descriptor.proto).
#include <google/protobuf/compiler/js/js_generator.h>
namespace google::protobuf::compiler::js
CodeGenerator implementation which generates a JavaScript source file and header.
If you create your own protocol compiler binary and you want it to support JavaScript output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.
-Members | |
|---|---|
| Generator() |
virtual | ~Generator() |
virtual bool | Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) constGenerates code for the given proto file, generating one or more files in the given output directory. more... |
virtual bool | HasGenerateAll() constThis is no longer used, but this class is part of the opensource protobuf library, so it has to remain to keep vtables the same for the current version of the library. more... |
virtual bool | GenerateAll(const std::vector< const FileDescriptor * > & files, const std::string & parameter, GeneratorContext * generator_context, std::string * error) constGenerates code for all given proto files. more... |
virtual uint64 | GetSupportedFeatures() constImplement this to indicate what features this code generator supports. more... |
virtual bool Generator::Generate(
const FileDescriptor * file,
const std::string & parameter,
GeneratorContext * generator_context,
std::string * error) constGenerates code for the given proto file, generating one or more files in the given output directory.
A parameter to be passed to the generator can be specified on the command line. This is intended to be used to pass generator specific parameters. It is empty if no parameter was given. ParseGeneratorParameter (below), can be used to accept multiple parameters within the single parameter command line flag.
+Members | |
|---|---|
| Generator() |
virtual | ~Generator() |
virtual bool | Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) constGenerates code for the given proto file, generating one or more files in the given output directory. more... |
virtual bool | HasGenerateAll() constThis is no longer used, but this class is part of the open-source Protobuf library, so it has to remain to keep vtables the same for the current version of the library. more... |
virtual bool | GenerateAll(const std::vector< const FileDescriptor * > & files, const std::string & parameter, GeneratorContext * generator_context, std::string * error) constGenerates code for all given proto files. more... |
virtual uint64 | GetSupportedFeatures() constImplement this to indicate what features this code generator supports. more... |
virtual bool Generator::Generate(
const FileDescriptor * file,
const std::string & parameter,
GeneratorContext * generator_context,
std::string * error) constGenerates code for the given proto file, generating one or more files in the given output directory.
A parameter to be passed to the generator can be specified on the command line. This is intended to be used to pass generator specific parameters. It is empty if no parameter was given. ParseGeneratorParameter (below), can be used to accept multiple parameters within the single parameter command line flag.
Returns true if successful. Otherwise, sets *error to a description of the problem (e.g. "invalid parameter") and returns false.
-virtual bool Generator::HasGenerateAll() constThis is no longer used, but this class is part of the opensource protobuf library, so it has to remain to keep vtables the same for the current version of the library.
When protobufs does a api breaking change, the method can be removed.
+virtual bool Generator::HasGenerateAll() constThis is no longer used, but this class is part of the open-source Protobuf library, so it has to remain to keep vtables the same for the current version of the library.
When Protobuf does an API breaking change, the method can be removed.
virtual bool Generator::GenerateAll(
const std::vector< const FileDescriptor * > & files,
const std::string & parameter,
GeneratorContext * generator_context,
std::string * error) constGenerates code for all given proto files.
WARNING: The canonical code generator design produces one or two output files per input .proto file, and we do not wish to encourage alternate designs.
A parameter is given as passed on the command line, as in |Generate()| above.
Returns true if successful. Otherwise, sets *error to a description of the problem (e.g. "invalid parameter") and returns false.
diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.objectivec_generator.md b/content/reference/cpp/api-docs/google.protobuf.compiler.objectivec_generator.md index ad236a33c..e994ce5b6 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.objectivec_generator.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.objectivec_generator.md @@ -2,13 +2,13 @@ title = "objectivec_generator.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++#include <google/protobuf/compiler/objectivec/objectivec_generator.h>
namespace google::protobuf::compiler::objectivec
Generates ObjectiveC code for a given .proto file.
Classes in this file | |
|---|---|
CodeGenerator implementation which generates a ObjectiveC source file and header. | |
#include <google/protobuf/compiler/objectivec/objectivec_generator.h>
namespace google::protobuf::compiler::objectivec
CodeGenerator implementation which generates a ObjectiveC source file and header.
If you create your own protocol compiler binary and you want it to support ObjectiveC output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.
-Members | |
|---|---|
| ObjectiveCGenerator() |
| ~ObjectiveCGenerator() |
| ObjectiveCGenerator(const ObjectiveCGenerator & ) |
ObjectiveCGenerator & | operator=(const ObjectiveCGenerator & ) |
implements CodeGenerator | |
virtual bool | HasGenerateAll() constThis is no longer used, but this class is part of the opensource protobuf library, so it has to remain to keep vtables the same for the current version of the library. more... |
virtual bool | Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) constGenerates code for the given proto file, generating one or more files in the given output directory. more... |
virtual bool | GenerateAll(const std::vector< const FileDescriptor * > & files, const std::string & parameter, GeneratorContext * generator_context, std::string * error) constGenerates code for all given proto files. more... |
virtual uint64_t | GetSupportedFeatures() constImplement this to indicate what features this code generator supports. more... |
virtual bool ObjectiveCGenerator::HasGenerateAll() constThis is no longer used, but this class is part of the opensource protobuf library, so it has to remain to keep vtables the same for the current version of the library.
When protobufs does a api breaking change, the method can be removed.
+Members | |
|---|---|
| ObjectiveCGenerator() |
| ~ObjectiveCGenerator() |
| ObjectiveCGenerator(const ObjectiveCGenerator & ) |
ObjectiveCGenerator & | operator=(const ObjectiveCGenerator & ) |
implements CodeGenerator | |
virtual bool | HasGenerateAll() constThis is no longer used, but this class is part of the open-source Protobuf library, so it has to remain to keep vtables the same for the current version of the library. more... |
virtual bool | Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) constGenerates code for the given proto file, generating one or more files in the given output directory. more... |
virtual bool | GenerateAll(const std::vector< const FileDescriptor * > & files, const std::string & parameter, GeneratorContext * generator_context, std::string * error) constGenerates code for all given proto files. more... |
virtual uint64_t | GetSupportedFeatures() constImplement this to indicate what features this code generator supports. more... |
virtual bool ObjectiveCGenerator::HasGenerateAll() constThis is no longer used, but this class is part of the open-source Protobuf library, so it has to remain to keep vtables the same for the current version of the library.
When Protobuf does an API breaking change, the method can be removed.
virtual bool ObjectiveCGenerator::Generate(
const FileDescriptor * file,
const std::string & parameter,
GeneratorContext * generator_context,
std::string * error) constGenerates code for the given proto file, generating one or more files in the given output directory.
A parameter to be passed to the generator can be specified on the command line. This is intended to be used to pass generator specific parameters. It is empty if no parameter was given. ParseGeneratorParameter (below), can be used to accept multiple parameters within the single parameter command line flag.
Returns true if successful. Otherwise, sets *error to a description of the problem (e.g. "invalid parameter") and returns false.
virtual bool ObjectiveCGenerator::GenerateAll(
const std::vector< const FileDescriptor * > & files,
const std::string & parameter,
GeneratorContext * generator_context,
std::string * error) constGenerates code for all given proto files.
WARNING: The canonical code generator design produces one or two output files per input .proto file, and we do not wish to encourage alternate designs.
diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.objectivec_helpers.md b/content/reference/cpp/api-docs/google.protobuf.compiler.objectivec_helpers.md index ba401a92f..07557d4f4 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.objectivec_helpers.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.objectivec_helpers.md @@ -2,7 +2,7 @@ title = "objectivec_helpers.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.parser.md b/content/reference/cpp/api-docs/google.protobuf.compiler.parser.md index cba5c8eda..17de7af27 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.parser.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.parser.md @@ -2,7 +2,7 @@ title = "parser.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.plugin.md b/content/reference/cpp/api-docs/google.protobuf.compiler.plugin.md index 6e69a5124..61bc007fc 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.plugin.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.plugin.md @@ -2,7 +2,7 @@ title = "plugin.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.plugin.pb.md b/content/reference/cpp/api-docs/google.protobuf.compiler.plugin.pb.md index 77771358d..37ce54093 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.plugin.pb.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.plugin.pb.md @@ -2,7 +2,7 @@ title = "plugin.pb.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.python_generator.md b/content/reference/cpp/api-docs/google.protobuf.compiler.python_generator.md index a87811668..d8cad39d2 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.python_generator.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.python_generator.md @@ -2,11 +2,11 @@ title = "python_generator.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -#include <google/protobuf/compiler/python/python_generator.h>
namespace google::protobuf::compiler::python
Generates Python code for a given .proto file.
Classes in this file | |
|---|---|
CodeGenerator implementation for generated Python protocol buffer classes. | |
#include <google/protobuf/compiler/python/python_generator.h>
namespace google::protobuf::compiler::python
CodeGenerator implementation for generated Python protocol buffer classes.
If you create your own protocol compiler binary and you want it to support Python output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.
+#include <google/protobuf/compiler/python/python_generator.h>
namespace google::protobuf::compiler::python
Generates Python code for a given .proto file.
Classes in this file | |
|---|---|
CodeGenerator implementation for generated Python Protobuf classes. | |
#include <google/protobuf/compiler/python/python_generator.h>
namespace google::protobuf::compiler::python
CodeGenerator implementation for generated Python Protobuf classes.
If you create your own protocol compiler binary and you want it to support Python output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.
Members | |
|---|---|
| Generator() |
virtual | ~Generator() |
virtual bool | Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) constCodeGenerator methods. |
virtual uint64_t | GetSupportedFeatures() constImplement this to indicate what features this code generator supports. more... |
virtual uint64_t Generator::GetSupportedFeatures() constImplement this to indicate what features this code generator supports.
This should be a bitwise OR of features from the Features enum in plugin.proto.
#include <google/protobuf/compiler/ruby/ruby_generator.h>
namespace google::protobuf::compiler::ruby
Generates Ruby code for a given .proto file.
Classes in this file | |
|---|---|
CodeGenerator implementation for generated Ruby protocol buffer classes. | |
#include <google/protobuf/compiler/ruby/ruby_generator.h>
namespace google::protobuf::compiler::ruby
CodeGenerator implementation for generated Ruby protocol buffer classes.
If you create your own protocol compiler binary and you want it to support Ruby output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.
+#include <google/protobuf/compiler/ruby/ruby_generator.h>
namespace google::protobuf::compiler::ruby
Generates Ruby code for a given .proto file.
Classes in this file | |
|---|---|
CodeGenerator implementation for generated Ruby Protobuf classes. | |
#include <google/protobuf/compiler/ruby/ruby_generator.h>
namespace google::protobuf::compiler::ruby
CodeGenerator implementation for generated Ruby Protobuf classes.
If you create your own protocol compiler binary and you want it to support Ruby output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.
Members |
|---|
Members | |
|---|---|
enum | TypeIdentifies a field type. more... |
enum | CppTypeSpecifies the C++ data type used to represent the field. more... |
enum | LabelIdentifies whether the field is optional, required, or repeated. more... |
typedef | FieldDescriptorProto Proto |
const int | kMaxNumber = = (1 << 29) - 1Valid field numbers are positive integers up to kMaxNumber. |
const int | kFirstReservedNumber = = 19000First field number reserved for the protocol buffer library implementation. more... |
const int | kLastReservedNumber = = 19999Last field number reserved for the protocol buffer library implementation. more... |
int32 | default_value_int32_ |
int64 | default_value_int64_ |
uint32 | default_value_uint32_ |
uint64 | default_value_uint64_ |
float | default_value_float_ |
double | default_value_double_ |
bool | default_value_bool_ |
const EnumValueDescriptor * | default_value_enum_ |
const std::string * | default_value_string_ |
std::atomic< const Message * > | default_generated_instance_ |
const std::string & | name() constName of this field within the message. |
const std::string & | full_name() constFully-qualified name of the field. |
const std::string & | json_name() constJSON name of this field. |
const FileDescriptor * | file() constFile in which this field was defined. |
bool | is_extension() constIs this an extension field? |
int | number() constDeclared tag number. |
const std::string & | lowercase_name() const |
const std::string & | camelcase_name() const |
Type | type() constDeclared type of this field. |
const char * | type_name() constName of the declared type. |
CppType | cpp_type() constC++ type of this field. |
const char * | cpp_type_name() constName of the C++ type. |
Label | label() constoptional/required/repeated |
bool | is_required() constshorthand for label() == LABEL_REQUIRED |
bool | is_optional() constshorthand for label() == LABEL_OPTIONAL |
bool | is_repeated() constshorthand for label() == LABEL_REPEATED |
bool | is_packable() constshorthand for is_repeated() && IsTypePackable(type()) |
bool | is_packed() constshorthand for is_packable() && options().packed() |
bool | is_map() const |
bool | has_optional_keyword() constReturns true if this field was syntactically written with "optional" in the .proto file. more... |
bool | has_presence() constReturns true if this field tracks presence, ie. more... |
int | index() constIndex of this field within the message's field array, or the file or extension scope's extensions array. |
bool | has_default_value() constDoes this field have an explicitly-declared default value? |
bool | has_json_name() constWhether the user has specified the json_name field option in the .proto file. |
int32 | default_value_int32() constGet the field default value if cpp_type() == CPPTYPE_INT32. more... |
int64 | default_value_int64() constGet the field default value if cpp_type() == CPPTYPE_INT64. more... |
uint32 | default_value_uint32() constGet the field default value if cpp_type() == CPPTYPE_UINT32. more... |
uint64 | default_value_uint64() constGet the field default value if cpp_type() == CPPTYPE_UINT64. more... |
float | default_value_float() constGet the field default value if cpp_type() == CPPTYPE_FLOAT. more... |
double | default_value_double() constGet the field default value if cpp_type() == CPPTYPE_DOUBLE. more... |
bool | default_value_bool() constGet the field default value if cpp_type() == CPPTYPE_BOOL. more... |
const EnumValueDescriptor * | default_value_enum() constGet the field default value if cpp_type() == CPPTYPE_ENUM. more... |
const std::string & | default_value_string() constGet the field default value if cpp_type() == CPPTYPE_STRING. more... |
const Descriptor * | containing_type() constThe Descriptor for the message of which this is a field. more... |
const OneofDescriptor * | containing_oneof() constIf the field is a member of a oneof, this is the one, otherwise this is nullptr. |
const OneofDescriptor * | real_containing_oneof() constIf the field is a member of a non-synthetic oneof, returns the descriptor for the oneof, otherwise returns nullptr. |
int | index_in_oneof() constIf the field is a member of a oneof, returns the index in that oneof. |
const Descriptor * | extension_scope() constAn extension may be declared within the scope of another message. more... |
const Descriptor * | message_type() constIf type is TYPE_MESSAGE or TYPE_GROUP, returns a descriptor for the message or the group type. more... |
const EnumDescriptor * | enum_type() constIf type is TYPE_ENUM, returns a descriptor for the enum. more... |
const FieldOptions & | options() constGet the FieldOptions for this field. more... |
void | CopyTo(FieldDescriptorProto * proto) constSee Descriptor::CopyTo(). |
std::string | DebugString() const |
std::string | DebugStringWithOptions(const DebugStringOptions & options) const |
const std::string & | PrintableNameForExtension() constReturns full_name() except if the field is a MessageSet extension, in which case it returns the full_name() of the containing message type for backwards compatibility with proto1. more... |
static CppType | TypeToCppType(Type type)Helper method to get the CppType for a particular Type. |
static const char * | TypeName(Type type)Helper method to get the name of a Type. |
static const char * | CppTypeName(CppType cpp_type)Helper method to get the name of a CppType. |
static bool | IsTypePackable(Type field_type)Return true iff [[]packed = true] is valid for fields of this type. |
Source Location | |
bool | GetSourceLocation(SourceLocation * out_location) constUpdates |*out_location| to the source location of the complete extent of this field declaration. more... |
enum FieldDescriptor::Type {
TYPE_DOUBLE = = 1,
TYPE_FLOAT = = 2,
TYPE_INT64 = = 3,
TYPE_UINT64 = = 4,
TYPE_INT32 = = 5,
TYPE_FIXED64 = = 6,
TYPE_FIXED32 = = 7,
TYPE_BOOL = = 8,
TYPE_STRING = = 9,
TYPE_GROUP = = 10,
TYPE_MESSAGE = = 11,
TYPE_BYTES = = 12,
TYPE_UINT32 = = 13,
TYPE_ENUM = = 14,
TYPE_SFIXED32 = = 15,
TYPE_SFIXED64 = = 16,
TYPE_SINT32 = = 17,
TYPE_SINT64 = = 18,
MAX_TYPE = = 18
}Identifies a field type.
0 is reserved for errors. The order is weird for historical reasons. Types 12 and up are new in proto2.
+Members | |
|---|---|
enum | TypeIdentifies a field type. more... |
enum | CppTypeSpecifies the C++ data type used to represent the field. more... |
enum | LabelIdentifies whether the field is optional, required, or repeated. more... |
typedef | FieldDescriptorProto Proto |
const int | kMaxNumber = = (1 << 29) - 1Valid field numbers are positive integers up to kMaxNumber. |
const int | kFirstReservedNumber = = 19000First field number reserved for the Protobuf library implementation. more... |
const int | kLastReservedNumber = = 19999Last field number reserved for the Protobuf library implementation. more... |
int32 | default_value_int32_ |
int64 | default_value_int64_ |
uint32 | default_value_uint32_ |
uint64 | default_value_uint64_ |
float | default_value_float_ |
double | default_value_double_ |
bool | default_value_bool_ |
const EnumValueDescriptor * | default_value_enum_ |
const std::string * | default_value_string_ |
std::atomic< const Message * > | default_generated_instance_ |
const std::string & | name() constName of this field within the message. |
const std::string & | full_name() constFully-qualified name of the field. |
const std::string & | json_name() constJSON name of this field. |
const FileDescriptor * | file() constFile in which this field was defined. |
bool | is_extension() constIs this an extension field? |
int | number() constDeclared tag number. |
const std::string & | lowercase_name() const |
const std::string & | camelcase_name() const |
Type | type() constDeclared type of this field. |
const char * | type_name() constName of the declared type. |
CppType | cpp_type() constC++ type of this field. |
const char * | cpp_type_name() constName of the C++ type. |
Label | label() constoptional/required/repeated |
bool | is_required() constshorthand for label() == LABEL_REQUIRED |
bool | is_optional() constshorthand for label() == LABEL_OPTIONAL |
bool | is_repeated() constshorthand for label() == LABEL_REPEATED |
bool | is_packable() constshorthand for is_repeated() && IsTypePackable(type()) |
bool | is_packed() constshorthand for is_packable() && options().packed() |
bool | is_map() const |
bool | has_optional_keyword() constReturns true if this field was syntactically written with "optional" in the .proto file. more... |
bool | has_presence() constReturns true if this field tracks presence, ie. more... |
int | index() constIndex of this field within the message's field array, or the file or extension scope's extensions array. |
bool | has_default_value() constDoes this field have an explicitly-declared default value? |
bool | has_json_name() constWhether the user has specified the json_name field option in the .proto file. |
int32 | default_value_int32() constGet the field default value if cpp_type() == CPPTYPE_INT32. more... |
int64 | default_value_int64() constGet the field default value if cpp_type() == CPPTYPE_INT64. more... |
uint32 | default_value_uint32() constGet the field default value if cpp_type() == CPPTYPE_UINT32. more... |
uint64 | default_value_uint64() constGet the field default value if cpp_type() == CPPTYPE_UINT64. more... |
float | default_value_float() constGet the field default value if cpp_type() == CPPTYPE_FLOAT. more... |
double | default_value_double() constGet the field default value if cpp_type() == CPPTYPE_DOUBLE. more... |
bool | default_value_bool() constGet the field default value if cpp_type() == CPPTYPE_BOOL. more... |
const EnumValueDescriptor * | default_value_enum() constGet the field default value if cpp_type() == CPPTYPE_ENUM. more... |
const std::string & | default_value_string() constGet the field default value if cpp_type() == CPPTYPE_STRING. more... |
const Descriptor * | containing_type() constThe Descriptor for the message of which this is a field. more... |
const OneofDescriptor * | containing_oneof() constIf the field is a member of a oneof, this is the one, otherwise this is nullptr. |
const OneofDescriptor * | real_containing_oneof() constIf the field is a member of a non-synthetic oneof, returns the descriptor for the oneof, otherwise returns nullptr. |
int | index_in_oneof() constIf the field is a member of a oneof, returns the index in that oneof. |
const Descriptor * | extension_scope() constAn extension may be declared within the scope of another message. more... |
const Descriptor * | message_type() constIf type is TYPE_MESSAGE or TYPE_GROUP, returns a descriptor for the message or the group type. more... |
const EnumDescriptor * | enum_type() constIf type is TYPE_ENUM, returns a descriptor for the enum. more... |
const FieldOptions & | options() constGet the FieldOptions for this field. more... |
void | CopyTo(FieldDescriptorProto * proto) constSee Descriptor::CopyTo(). |
std::string | DebugString() const |
std::string | DebugStringWithOptions(const DebugStringOptions & options) const |
const std::string & | PrintableNameForExtension() constReturns full_name() except if the field is a MessageSet extension, in which case it returns the full_name() of the containing message type for backwards compatibility with proto1. more... |
static CppType | TypeToCppType(Type type)Helper method to get the CppType for a particular Type. |
static const char * | TypeName(Type type)Helper method to get the name of a Type. |
static const char * | CppTypeName(CppType cpp_type)Helper method to get the name of a CppType. |
static bool | IsTypePackable(Type field_type)Return true iff [[]packed = true] is valid for fields of this type. |
Source Location | |
bool | GetSourceLocation(SourceLocation * out_location) constUpdates |*out_location| to the source location of the complete extent of this field declaration. more... |
enum FieldDescriptor::Type {
TYPE_DOUBLE = = 1,
TYPE_FLOAT = = 2,
TYPE_INT64 = = 3,
TYPE_UINT64 = = 4,
TYPE_INT32 = = 5,
TYPE_FIXED64 = = 6,
TYPE_FIXED32 = = 7,
TYPE_BOOL = = 8,
TYPE_STRING = = 9,
TYPE_GROUP = = 10,
TYPE_MESSAGE = = 11,
TYPE_BYTES = = 12,
TYPE_UINT32 = = 13,
TYPE_ENUM = = 14,
TYPE_SFIXED32 = = 15,
TYPE_SFIXED64 = = 16,
TYPE_SINT32 = = 17,
TYPE_SINT64 = = 18,
MAX_TYPE = = 18
}Identifies a field type.
0 is reserved for errors. The order is weird for historical reasons. Types 12 and up are new in proto2.
| TYPE_DOUBLE | double, exactly eight bytes on the wire. |
| TYPE_FLOAT | float, exactly four bytes on the wire. |
| TYPE_INT64 | int64, varint on the wire. Negative numbers take 10 bytes. Use TYPE_SINT64 if negative values are likely. |
| TYPE_UINT64 | uint64, varint on the wire. |
| TYPE_INT32 | int32, varint on the wire. Negative numbers take 10 bytes. Use TYPE_SINT32 if negative values are likely. |
| TYPE_FIXED64 | uint64, exactly eight bytes on the wire. |
| TYPE_FIXED32 | uint32, exactly four bytes on the wire. |
| TYPE_BOOL | bool, varint on the wire. |
| TYPE_STRING | UTF-8 text. |
| TYPE_GROUP | Tag-delimited message. Deprecated. |
| TYPE_MESSAGE | Length-delimited message. |
| TYPE_BYTES | Arbitrary byte array. |
| TYPE_UINT32 | uint32, varint on the wire |
| TYPE_ENUM | Enum, varint on the wire. |
| TYPE_SFIXED32 | int32, exactly four bytes on the wire |
| TYPE_SFIXED64 | int64, exactly eight bytes on the wire |
| TYPE_SINT32 | int32, ZigZag-encoded varint on the wire |
| TYPE_SINT64 | int64, ZigZag-encoded varint on the wire |
| MAX_TYPE | Constant useful for defining lookup tables indexed by Type. |
enum FieldDescriptor::CppType {
CPPTYPE_INT32 = = 1,
CPPTYPE_INT64 = = 2,
CPPTYPE_UINT32 = = 3,
CPPTYPE_UINT64 = = 4,
CPPTYPE_DOUBLE = = 5,
CPPTYPE_FLOAT = = 6,
CPPTYPE_BOOL = = 7,
CPPTYPE_ENUM = = 8,
CPPTYPE_STRING = = 9,
CPPTYPE_MESSAGE = = 10,
MAX_CPPTYPE = = 10
}Specifies the C++ data type used to represent the field.
There is a fixed mapping from Type to CppType where each Type maps to exactly one CppType. 0 is reserved for errors.
| CPPTYPE_INT32 | TYPE_INT32, TYPE_SINT32, TYPE_SFIXED32. |
| CPPTYPE_INT64 | TYPE_INT64, TYPE_SINT64, TYPE_SFIXED64. |
| CPPTYPE_UINT32 | TYPE_UINT32, TYPE_FIXED32. |
| CPPTYPE_UINT64 | TYPE_UINT64, TYPE_FIXED64. |
| CPPTYPE_DOUBLE | TYPE_DOUBLE. |
| CPPTYPE_FLOAT | TYPE_FLOAT. |
| CPPTYPE_BOOL | TYPE_BOOL. |
| CPPTYPE_ENUM | TYPE_ENUM. |
| CPPTYPE_STRING | TYPE_STRING, TYPE_BYTES. |
| CPPTYPE_MESSAGE | TYPE_MESSAGE, TYPE_GROUP. |
| MAX_CPPTYPE | Constant useful for defining lookup tables indexed by CppType. |
enum FieldDescriptor::Label {
LABEL_OPTIONAL = = 1,
LABEL_REQUIRED = = 2,
LABEL_REPEATED = = 3,
MAX_LABEL = = 3
}Identifies whether the field is optional, required, or repeated.
0 is reserved for errors.
-| LABEL_OPTIONAL | optional |
| LABEL_REQUIRED | required |
| LABEL_REPEATED | repeated |
| MAX_LABEL | Constant useful for defining lookup tables indexed by Label. |
const int FieldDescriptor::kFirstReservedNumber = = 19000First field number reserved for the protocol buffer library implementation.
Users may not declare fields that use reserved numbers.
-const int FieldDescriptor::kLastReservedNumber = = 19999Last field number reserved for the protocol buffer library implementation.
Users may not declare fields that use reserved numbers.
-const std::string &
FieldDescriptor::lowercase_name() constSame as name() except converted to lower-case.
This (and especially the FindFieldByLowercaseName() method) can be useful when parsing formats which prefer to use lowercase naming style. (Although, technically field names should be lowercased anyway according to the protobuf style guide, so this only makes a difference when dealing with old .proto files which do not follow the guide.)
+| LABEL_OPTIONAL | optional |
| LABEL_REQUIRED | required |
| LABEL_REPEATED | repeated |
| MAX_LABEL | Constant useful for defining lookup tables indexed by Label. |
const int FieldDescriptor::kFirstReservedNumber = = 19000First field number reserved for the Protobuf library implementation.
Users may not declare fields that use reserved numbers.
+const int FieldDescriptor::kLastReservedNumber = = 19999Last field number reserved for the Protobuf library implementation.
Users may not declare fields that use reserved numbers.
+const std::string &
FieldDescriptor::lowercase_name() constSame as name() except converted to lower-case.
This (and especially the FindFieldByLowercaseName() method) can be useful when parsing formats which prefer to use lowercase naming style. (Although, technically field names should be lowercased anyway according to the Protobuf style guide, so this only makes a difference when dealing with old .proto files which do not follow the guide.)
const std::string &
FieldDescriptor::camelcase_name() constSame as name() except converted to camel-case.
In this conversion, any time an underscore appears in the name, it is removed and the next letter is capitalized. Furthermore, the first letter of the name is lower-cased. Examples:
FooBar -> fooBar foo_bar -> fooBar diff --git a/content/reference/cpp/api-docs/google.protobuf.descriptor.pb.md b/content/reference/cpp/api-docs/google.protobuf.descriptor.pb.md index b0dfacd6c..3e966f8a3 100644 --- a/content/reference/cpp/api-docs/google.protobuf.descriptor.pb.md +++ b/content/reference/cpp/api-docs/google.protobuf.descriptor.pb.md @@ -2,11 +2,11 @@ title = "descriptor.pb.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -
#include <google/protobuf/descriptor.pb.h>
namespace google::protobufProtocol buffer representations of descriptors.
This file defines a set of protocol message classes which represent the same information represented by the classes defined in descriptor.h. You can convert a FileDescriptorProto to a FileDescriptor using the DescriptorPool class. Thus, the classes in this file allow protocol type definitions to be communicated efficiently between processes.
+
#include <google/protobuf/descriptor.pb.h>
namespace google::protobufProtobuf representations of descriptors.
This file defines a set of protocol message classes which represent the same information represented by the classes defined in descriptor.h. You can convert a FileDescriptorProto to a FileDescriptor using the DescriptorPool class. Thus, the classes in this file allow protocol type definitions to be communicated efficiently between processes.
The protocol compiler currently doesn't support auto-generated documentation, hence this page contains no descriptions. This file was generated by the protocol compiler from
diff --git a/content/reference/cpp/api-docs/google.protobuf.descriptor_database.md b/content/reference/cpp/api-docs/google.protobuf.descriptor_database.md index c2f28e434..c787ecac9 100644 --- a/content/reference/cpp/api-docs/google.protobuf.descriptor_database.md +++ b/content/reference/cpp/api-docs/google.protobuf.descriptor_database.md @@ -2,7 +2,7 @@ title = "descriptor_database.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.dynamic_message.md b/content/reference/cpp/api-docs/google.protobuf.dynamic_message.md index 17d432754..be22de338 100644 --- a/content/reference/cpp/api-docs/google.protobuf.dynamic_message.md +++ b/content/reference/cpp/api-docs/google.protobuf.dynamic_message.md @@ -4,7 +4,7 @@ title = "dynamic_message.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.io.coded_stream.md b/content/reference/cpp/api-docs/google.protobuf.io.coded_stream.md index 04db2bc81..c1bfca934 100644 --- a/content/reference/cpp/api-docs/google.protobuf.io.coded_stream.md +++ b/content/reference/cpp/api-docs/google.protobuf.io.coded_stream.md @@ -2,13 +2,13 @@ title = "coded_stream.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++descriptor.proto, whose contents are as follows:
#include <google/protobuf/io/coded_stream.h>
namespace google::protobuf::ioThis file contains the CodedInputStream and CodedOutputStream classes, which wrap a ZeroCopyInputStream or ZeroCopyOutputStream, respectively, and allow you to read or write individual pieces of data in various formats.
In particular, these implement the varint encoding for integers, a simple variable-length encoding in which smaller numbers take fewer bytes.
-Typically these classes will only be used internally by the protocol buffer library in order to encode and decode protocol buffers. Clients of the library only need to know about this class if they wish to write custom message parsing or serialization procedures.
+Typically these classes will only be used internally by the Protobuf library in order to encode and decode Protobuf messages. Clients of the library only need to know about this class if they wish to write custom message parsing or serialization procedures.
CodedOutputStream example:
@@ -173,7 +173,7 @@ delete coded_output;
void CodedOutputStream::EnableAliasing(
bool enabled)Instructs the CodedOutputStream to allow the underlying ZeroCopyOutputStream to hold pointers to the original structure instead of copying, if it supports it (i.e.
output->AllowsAliasing() is true). If the underlying stream does not support aliasing, then enabling it has no affect. For now, this only affects the behavior of WriteRawMaybeAliased().
NOTE: It is caller's responsibility to ensure that the chunk of memory remains live until all of the data has been consumed from the stream.
void CodedOutputStream::SetSerializationDeterministic(
bool value)Indicate to the serializer whether the user wants derministic serialization.
The default when this is not called comes from the global default, controlled by SetDefaultSerializationDeterministic.
-What deterministic serialization means is entirely up to the driver of the serialization process (i.e. the caller of methods like WriteVarint32). In the case of serializing a proto buffer message using one of the methods of MessageLite, this means that for a given binary equal messages will always be serialized to the same bytes. This implies:
+What deterministic serialization means is entirely up to the driver of the serialization process (i.e. the caller of methods like WriteVarint32). In the case of serializing a Protobuf message using one of the methods of MessageLite, this means that for a given binary equal messages will always be serialized to the same bytes. This implies:
Repeated serialization of a message will return the same bytes. Different processes running the same binary (including on different diff --git a/content/reference/cpp/api-docs/google.protobuf.io.gzip_stream.md b/content/reference/cpp/api-docs/google.protobuf.io.gzip_stream.md index dabc10c3b..1c87a23c0 100644 --- a/content/reference/cpp/api-docs/google.protobuf.io.gzip_stream.md +++ b/content/reference/cpp/api-docs/google.protobuf.io.gzip_stream.md @@ -2,7 +2,7 @@ title = "gzip_stream.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.io.printer.md b/content/reference/cpp/api-docs/google.protobuf.io.printer.md index f1048c50d..1623248a2 100644 --- a/content/reference/cpp/api-docs/google.protobuf.io.printer.md +++ b/content/reference/cpp/api-docs/google.protobuf.io.printer.md @@ -2,13 +2,13 @@ title = "printer.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -
#include <google/protobuf/io/printer.h>
namespace google::protobuf::ioUtility class for writing text to a ZeroCopyOutputStream.
Classes in this file | |
|---|---|
Records annotations about a Printer's output. | |
Records annotations about a Printer's output to the given protocol buffer, assuming that the buffer has an ::Annotation message exposing path, source_file, begin and end fields. | |
#include <google/protobuf/io/printer.h>
namespace google::protobuf::io
Records annotations about a Printer's output.
Known subclasses:
Members | |
|---|---|
typedef | std::pair< std::pair< size_t, size_t >, std::string > AnnotationAnnotation is a offset range and a payload pair. |
virtual void | AddAnnotation(size_t begin_offset, size_t end_offset, const std::string & file_path, const std::vector< int > & path) = 0Records that the bytes in file_path beginning with begin_offset and ending before end_offset are associated with the SourceCodeInfo-style path. |
virtual void | AddAnnotationNew(Annotation & ) |
virtual | ~AnnotationCollector() |
virtual void AnnotationCollector::AddAnnotationNew(
Annotation & )Just a vector of range, payload pairs stored in a context should suffice.
+#include <google/protobuf/io/printer.h>
namespace google::protobuf::io
Utility class for writing text to a ZeroCopyOutputStream.
Classes in this file | |
|---|---|
Records annotations about a Printer's output. | |
Records annotations about a Printer's output to the given Protobuf message, assuming that the message has an ::Annotation message exposing path, source_file, begin and end fields. | |
#include <google/protobuf/io/printer.h>
namespace google::protobuf::io
Records annotations about a Printer's output.
Known subclasses:
Members | |
|---|---|
typedef | std::pair< std::pair< size_t, size_t >, std::string > AnnotationAnnotation is a offset range and a payload pair. |
virtual void | AddAnnotation(size_t begin_offset, size_t end_offset, const std::string & file_path, const std::vector< int > & path) = 0Records that the bytes in file_path beginning with begin_offset and ending before end_offset are associated with the SourceCodeInfo-style path. |
virtual void | AddAnnotationNew(Annotation & ) |
virtual | ~AnnotationCollector() |
virtual void AnnotationCollector::AddAnnotationNew(
Annotation & )Just a vector of range, payload pairs stored in a context should suffice.
-#include <google/protobuf/io/printer.h>
namespace google::protobuf::io
template <typename >
Records annotations about a Printer's output to the given protocol buffer, assuming that the buffer has an ::Annotation message exposing path, source_file, begin and end fields.
Members | |
|---|---|
explicit | AnnotationProtoCollector(AnnotationProto * annotation_proto)annotation_proto is the protocol buffer to which new Annotations should be added. more... |
virtual void | AddAnnotation(size_t begin_offset, size_t end_offset, const std::string & file_path, const std::vector< int > & path)Override for AnnotationCollector::AddAnnotation. |
virtual void | AddAnnotationNew(Annotation & a)Override for AnnotationCollector::AddAnnotation. |
explicit AnnotationProtoCollector::AnnotationProtoCollector(
AnnotationProto * annotation_proto)annotation_proto is the protocol buffer to which new Annotations should be added.
It is not owned by the AnnotationProtoCollector.
+#include <google/protobuf/io/printer.h>
namespace google::protobuf::io
template <typename >
Records annotations about a Printer's output to the given Protobuf message, assuming that the message has an ::Annotation message exposing path, source_file, begin and end fields.
Members | |
|---|---|
explicit | AnnotationProtoCollector(AnnotationProto * annotation_proto)annotation_proto is the Protobuf message to which new Annotations should be added. more... |
virtual void | AddAnnotation(size_t begin_offset, size_t end_offset, const std::string & file_path, const std::vector< int > & path)Override for AnnotationCollector::AddAnnotation. |
virtual void | AddAnnotationNew(Annotation & a)Override for AnnotationCollector::AddAnnotation. |
explicit AnnotationProtoCollector::AnnotationProtoCollector(
AnnotationProto * annotation_proto)annotation_proto is the Protobuf message to which new Annotations should be added.
It is not owned by the AnnotationProtoCollector.
#include <google/protobuf/io/printer.h>
namespace google::protobuf::io
Members | |
|---|---|
| Printer(ZeroCopyOutputStream * output, char variable_delimiter)Create a printer that writes text to the given output stream. more... |
| Printer(ZeroCopyOutputStream * output, char variable_delimiter, AnnotationCollector * annotation_collector)Create a printer that writes text to the given output stream. more... |
| ~Printer() |
template void | Annotate(const char * varname, const SomeDescriptor * descriptor)Link a substitution variable emitted by the last call to Print to the object described by descriptor. |
template void | Annotate(const char * begin_varname, const char * end_varname, const SomeDescriptor * descriptor)Link the output range defined by the substitution variables as emitted by the last call to Print to the object described by descriptor. more... |
void | Annotate(const char * varname, const std::string & file_name)Link a substitution variable emitted by the last call to Print to the file with path file_name. |
void | Annotate(const char * begin_varname, const char * end_varname, const std::string & file_name)Link the output range defined by the substitution variables as emitted by the last call to Print to the file with path file_name. more... |
void | Print(const std::map< std::string, std::string > & variables, const char * text)Print some text after applying variable substitutions. more... |
template void | Print(const char * text, const Args &... args)Like the first Print(), except the substitutions are given as parameters. |
void | Indent()Indent text by two spaces. more... |
void | Outdent()Reduces the current indent level by two spaces, or crashes if the indent level is zero. |
void | PrintRaw(const std::string & data)Write a string to the output buffer. more... |
void | PrintRaw(const char * data)Write a zero-delimited string to output buffer. more... |
void | WriteRaw(const char * data, int size)Write some bytes to the output buffer. more... |
void | FormatInternal(const std::vector< std::string > & args, const std::map< std::string, std::string > & vars, const char * format)FormatInternal is a helper function not meant to use directly, use compiler::cpp::Formatter instead. more... |
bool | failed() constTrue if any write to the underlying stream failed. more... |
Printer::Printer(
ZeroCopyOutputStream * output,
char variable_delimiter)Create a printer that writes text to the given output stream.
Use the given character as the delimiter for variables.
Printer::Printer(
ZeroCopyOutputStream * output,
char variable_delimiter,
AnnotationCollector * annotation_collector)Create a printer that writes text to the given output stream.
Use the given character as the delimiter for variables. If annotation_collector is not null, Printer will provide it with annotations about code written to the stream. annotation_collector is not owned by Printer.
template void Printer::Annotate(
const char * begin_varname,
const char * end_varname,
const SomeDescriptor * descriptor)Link the output range defined by the substitution variables as emitted by the last call to Print to the object described by descriptor.
The range begins at begin_varname's value and ends after the last character of the value substituted for end_varname.
diff --git a/content/reference/cpp/api-docs/google.protobuf.io.tokenizer.md b/content/reference/cpp/api-docs/google.protobuf.io.tokenizer.md index 0b05302c3..3845f9d76 100644 --- a/content/reference/cpp/api-docs/google.protobuf.io.tokenizer.md +++ b/content/reference/cpp/api-docs/google.protobuf.io.tokenizer.md @@ -2,7 +2,7 @@ title = "tokenizer.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ diff --git a/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream.md b/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream.md index 9ccbcda3c..0151e5ab3 100644 --- a/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream.md +++ b/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream.md @@ -2,11 +2,11 @@ title = "zero_copy_stream.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -#include <google/protobuf/io/zero_copy_stream.h>
namespace google::protobuf::io
This file contains the ZeroCopyInputStream and ZeroCopyOutputStream interfaces, which represent abstract I/O streams to and from which protocol buffers can be read and written.
For a few simple implementations of these interfaces, see zero_copy_stream_impl.h.
+#include <google/protobuf/io/zero_copy_stream.h>
namespace google::protobuf::io
This file contains the ZeroCopyInputStream and ZeroCopyOutputStream interfaces, which represent abstract I/O streams to and from which Protobuf messages can be read and written.
For a few simple implementations of these interfaces, see zero_copy_stream_impl.h.
These interfaces are different from classic I/O streams in that they try to minimize the amount of data copying that needs to be done. To accomplish this, responsibility for allocating buffers is moved to the stream object, rather than being the responsibility of the caller. So, the stream can return a buffer which actually points directly into the final data structure where the bytes are to be stored, and the caller can interact directly with that buffer, eliminating an intermediate copy operation.
diff --git a/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream_impl.md b/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream_impl.md index e9a433053..f14a8f579 100644 --- a/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream_impl.md +++ b/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream_impl.md @@ -2,11 +2,11 @@ title = "zero_copy_stream_impl.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -#include <google/protobuf/io/zero_copy_stream_impl.h>
namespace google::protobuf::io
This file contains common implementations of the interfaces defined in zero_copy_stream.h which are only included in the full (non-lite) protobuf library.
These implementations include Unix file descriptors and C++ iostreams. See also: zero_copy_stream_impl_lite.h
+#include <google/protobuf/io/zero_copy_stream_impl.h>
namespace google::protobuf::io
This file contains common implementations of the interfaces defined in zero_copy_stream.h which are only included in the full (non-lite) Protobuf library.
These implementations include Unix file descriptors and C++ iostreams. See also: zero_copy_stream_impl_lite.h
Classes in this file | |
|---|---|
A ZeroCopyInputStream which reads from a file descriptor. | |
A ZeroCopyOutputStream which writes to a file descriptor. | |
A ZeroCopyInputStream which reads from a C++ istream. | |
A ZeroCopyOutputStream which writes to a C++ ostream. | |
A ZeroCopyInputStream which reads from several other streams in sequence. | |
#include <google/protobuf/io/zero_copy_stream_impl.h>
namespace google::protobuf::io
A ZeroCopyInputStream which reads from a file descriptor.
FileInputStream is preferred over using an ifstream with IstreamInputStream. The latter will introduce an extra layer of buffering, harming performance. Also, it's conceivable that FileInputStream could someday be enhanced to use zero-copy file descriptors on OSs which support them.
Members | |
|---|---|
explicit | FileInputStream(int file_descriptor, int block_size = -1)Creates a stream that reads from the given Unix file descriptor. more... |
bool | Close()Flushes any buffers and closes the underlying file. more... |
void | SetCloseOnDelete(bool value)By default, the file descriptor is not closed when the stream is destroyed. more... |
int | GetErrno() constIf an I/O error has occurred on this file descriptor, this is the errno from that error. more... |
implements ZeroCopyInputStream | |
virtual bool | Next(const void ** data, int * size)Obtains a chunk of data from the stream. more... |
virtual void | BackUp(int count) |
virtual bool | Skip(int count)Skips a number of bytes. more... |
virtual int64_t | ByteCount() constReturns the total number of bytes read since this object was created. |
explicit FileInputStream::FileInputStream(
int file_descriptor,
int block_size = -1)Creates a stream that reads from the given Unix file descriptor.
If a block_size is given, it specifies the number of bytes that should be read and returned with each call to Next(). Otherwise, a reasonable default is used.
diff --git a/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream_impl_lite.md b/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream_impl_lite.md index a04133874..9a773842e 100644 --- a/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream_impl_lite.md +++ b/content/reference/cpp/api-docs/google.protobuf.io.zero_copy_stream_impl_lite.md @@ -2,11 +2,11 @@ title = "zero_copy_stream_iml_lite.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
namespace google::protobuf::io
This file contains common implementations of the interfaces defined in zero_copy_stream.h which are included in the "lite" protobuf library.
These implementations cover I/O on raw arrays and strings, as well as adaptors which make it easy to implement streams based on traditional streams. Of course, many users will probably want to write their own implementations of these interfaces specific to the particular I/O abstractions they prefer to use, but these should cover the most common cases.
+#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
namespace google::protobuf::io
This file contains common implementations of the interfaces defined in zero_copy_stream.h which are included in the "lite" Protobuf library.
These implementations cover I/O on raw arrays and strings, as well as adaptors which make it easy to implement streams based on traditional streams. Of course, many users will probably want to write their own implementations of these interfaces specific to the particular I/O abstractions they prefer to use, but these should cover the most common cases.
Classes in this file | |
|---|---|
A ZeroCopyInputStream backed by an in-memory array of bytes. | |
A ZeroCopyOutputStream backed by an in-memory array of bytes. | |
A ZeroCopyOutputStream which appends bytes to a string. | |
A generic traditional input stream interface. | |
A ZeroCopyInputStream which reads from a CopyingInputStream. | |
A generic traditional output stream interface. | |
A ZeroCopyOutputStream which writes to a CopyingOutputStream. | |
A ZeroCopyInputStream which wraps some other stream and limits it to a particular byte count. | |
File MembersThese definitions are not part of any class. | |
|---|---|
char * | mutable_string_data(std::string * s)Return a pointer to mutable characters underlying the given string. more... |
std::pair< char *, bool > | as_string_data(std::string * s)as_string_data(s) is equivalent to ({ char* p = mutable_string_data(s); make_pair(p, p != NULL); }) Sometimes it's faster: in some scenarios p cannot be NULL, and then the code can avoid that check. |
char * io::mutable_string_data(
std::string * s)Return a pointer to mutable characters underlying the given string.
The return value is valid until the next time the string is resized. We trust the caller to treat the return value as an array of length s->size().
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
namespace google::protobuf::io
A ZeroCopyInputStream backed by an in-memory array of bytes.
Members | |
|---|---|
| ArrayInputStream(const void * data, int size, int block_size = -1)Create an InputStream that returns the bytes pointed to by "data". more... |
| ~ArrayInputStream() |
implements ZeroCopyInputStream | |
virtual bool | Next(const void ** data, int * size)Obtains a chunk of data from the stream. more... |
virtual void | BackUp(int count) |
virtual bool | Skip(int count)Skips a number of bytes. more... |
virtual int64_t | ByteCount() constReturns the total number of bytes read since this object was created. |
ArrayInputStream::ArrayInputStream(
const void * data,
int size,
int block_size = -1)Create an InputStream that returns the bytes pointed to by "data".
"data" remains the property of the caller but must remain valid until the stream is destroyed. If a block_size is given, calls to Next() will return data blocks no larger than the given size. Otherwise, the first call to Next() returns the entire array. block_size is mainly useful for testing; in production you would probably never want to set it.
diff --git a/content/reference/cpp/api-docs/google.protobuf.map.md b/content/reference/cpp/api-docs/google.protobuf.map.md index f0022eb39..bc0dc12d8 100644 --- a/content/reference/cpp/api-docs/google.protobuf.map.md +++ b/content/reference/cpp/api-docs/google.protobuf.map.md @@ -4,14 +4,14 @@ title = "map.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -#include <google/protobuf/map.h>
namespace google::protobuf
This file defines the map container and its helpers to support protobuf maps.
The Map and MapIterator types are provided by this header file. Please avoid using other types defined here, unless they are public types within Map or MapIterator, such as Map::value_type.
+#include <google/protobuf/map.h>
namespace google::protobuf
This file defines the map container and its helpers to support Protobuf maps.
The Map and MapIterator types are provided by this header file. Please avoid using other types defined here, unless they are public types within Map or MapIterator, such as Map::value_type.
-Classes in this file | |
|---|---|
This is the class for Map's internal value_type. | |
Map is an associative container type used to store protobuf map fields. | |
Iterators. | |
#include <google/protobuf/map.h>
namespace google::protobuf
template <typename , typename >
This is the class for Map's internal value_type, which is just an alias to std::pair.
-#include <google/protobuf/map.h>
namespace google::protobuf
template <typename , typename >
Map is an associative container type used to store protobuf map fields.
Each Map instance may or may not use a different hash function, a different iteration order, and so on. E.g., please don't examine implementation details to decide if the following would work: Map<int, int> m0, m1; m0[0] = m1[0] = m0[1] = m1[1] = 0; assert(m0.begin()->first == m1.begin()->first); // Bug!
+Classes in this file | |
|---|---|
This is the class for Map's internal value_type. | |
Map is an associative container type used to store Protobuf map fields. | |
Iterators. | |
#include <google/protobuf/map.h>
namespace google::protobuf
template <typename , typename >
This is the class for Map's internal value_type, which is just an alias to std::pair.
+#include <google/protobuf/map.h>
namespace google::protobuf
template <typename , typename >
Map is an associative container type used to store Protobuf map fields.
Each Map instance may or may not use a different hash function, a different iteration order, and so on. E.g., please don't examine implementation details to decide if the following would work: Map<int, int> m0, m1; m0[0] = m1[0] = m0[1] = m1[1] = 0; assert(m0.begin()->first == m1.begin()->first); // Bug!
Map's interface is similar to std::unordered_map, except that Map is not designed to play well with exceptions.
Members | |
|---|---|
typedef | Key key_type |
typedef | T mapped_type |
typedef | MapPair< Key, T > value_type |
typedef | value_type * pointer |
typedef | const value_type * const_pointer |
typedef | value_type & reference |
typedef | const value_type & const_reference |
typedef | size_t size_type |
typedef | typename internal::TransparentSupport< Key >::hash hasher |
constexpr | Map() |
explicit | Map(Arena * arena) |
| Map(const Map & other) |
| Map(Map && other) |
Map & | operator=(Map && other) |
template | Map(const InputIt & first, const InputIt & last) |
| ~Map() |
iterator | begin() |
iterator | end() |
const_iterator | begin() const |
const_iterator | end() const |
const_iterator | cbegin() const |
const_iterator | cend() const |
size_type | size() constCapacity. |
bool | empty() const |
template T & | operator[](const key_arg< K > & key)Element access. |
template T & | operator[](key_arg< K > && key) |
template const T & | at(const key_arg< K > & key) const |
template T & | at(const key_arg< K > & key) |
template size_type | count(const key_arg< K > & key) constLookup. |
template const_iterator | find(const key_arg< K > & key) const |
template iterator | find(const key_arg< K > & key) |
template bool | contains(const key_arg< K > & key) const |
template std::pair< const_iterator, const_iterator > | equal_range(const key_arg< K > & key) const |
template std::pair< iterator, iterator > | equal_range(const key_arg< K > & key) |
std::pair< iterator, bool > | insert(const value_type & value)insert |
template void | insert(InputIt first, InputIt last) |
void | insert(std::initializer_list< value_type > values) |
template size_type | erase(const key_arg< K > & key)Erase and clear. |
iterator | erase(iterator pos) |
void | |
void | clear() |
Map & | operator=(const Map & other)Assign. |
void | swap(Map & other) |
void | InternalSwap(Map & other) |
hasher | hash_function() constAccess to hasher. more... |
size_t | SpaceUsedExcludingSelfLong() const |
hasher Map::hash_function() constAccess to hasher.
Currently this returns a copy, but it may be modified to return a const reference in the future.
#include <google/protobuf/map.h>
namespace google::protobuf
Iterators.
Members | |
|---|---|
typedef | std::forward_iterator_tag iterator_category |
typedef | typename Map::value_type value_type |
typedef | ptrdiff_t difference_type |
typedef | const value_type * pointer |
typedef | const value_type & reference |
| const_iterator() |
explicit | const_iterator(const InnerIt & it) |
const_reference | operator*() const |
const_pointer | operator->() const |
const_iterator & | operator++() |
const_iterator | operator++(int ) |
#include <google/protobuf/map.h>
namespace google::protobuf
Members | |
|---|---|
typedef | std::forward_iterator_tag iterator_category |
typedef | typename Map::value_type value_type |
typedef | ptrdiff_t difference_type |
typedef | value_type * pointer |
typedef | value_type & reference |
| iterator() |
explicit | iterator(const InnerIt & it) |
reference | operator*() const |
pointer | operator->() const |
iterator & | operator++() |
iterator | operator++(int ) |
| operator const_iterator() constAllow implicit conversion to const_iterator. |
A RepeatedFieldRef object can be copied and the resulted object will point to the same repeated field in the same message. The object can be used as long as the message is not destroyed.
Note that to use this method users need to include the header file "reflection.h" (which defines the RepeatedFieldRef class templates).
template const RepeatedField< T > &
Reflection::GetRepeatedField(
const Message & msg,
const FieldDescriptor * d) constDEPRECATED.
Please use GetRepeatedFieldRef().
-for T = Cord and all protobuf scalar types except enums.
+for T = Cord and all Protobuf scalar types except enums.
template RepeatedField< T > *
Reflection::MutableRepeatedField(
Message * msg,
const FieldDescriptor * d) constDEPRECATED.
Please use GetMutableRepeatedFieldRef().
-for T = Cord and all protobuf scalar types except enums.
+for T = Cord and all Protobuf scalar types except enums.
template const RepeatedPtrField< T > &
Reflection::GetRepeatedPtrField(
const Message & msg,
const FieldDescriptor * d) constDEPRECATED.
Please use GetRepeatedFieldRef().
for T = std::string, google::protobuf::internal::StringPieceField
google::protobuf::Message & descendants.diff --git a/content/reference/cpp/api-docs/google.protobuf.message_lite.md b/content/reference/cpp/api-docs/google.protobuf.message_lite.md index d6fa41333..ee01ba1f8 100644 --- a/content/reference/cpp/api-docs/google.protobuf.message_lite.md +++ b/content/reference/cpp/api-docs/google.protobuf.message_lite.md @@ -4,38 +4,38 @@ title = "message_lite.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -
#include <google/protobuf/message_lite.h>
namespace google::protobuf
Defines MessageLite, the abstract interface implemented by all (lite and non-lite) protocol message objects.
Classes in this file | |
|---|---|
Interface to light weight protocol messages. | |
File MembersThese definitions are not part of any class. | |
|---|---|
void | ShutdownProtobufLibrary()Shut down the entire protocol buffers library, deleting all static-duration objects allocated by the library or by generated .pb.cc files. more... |
void protobuf::ShutdownProtobufLibrary()Shut down the entire protocol buffers library, deleting all static-duration objects allocated by the library or by generated .pb.cc files.
There are two reasons you might want to call this:
+#include <google/protobuf/message_lite.h>
namespace google::protobuf
Defines MessageLite, the abstract interface implemented by all (lite and non-lite) protocol message objects.
Classes in this file | |
|---|---|
Interface to light weight protocol messages. | |
File MembersThese definitions are not part of any class. | |
|---|---|
void | ShutdownProtobufLibrary()Shut down the entire Protobuf library, deleting all static-duration objects allocated by the library or by generated .pb.cc files. more... |
void protobuf::ShutdownProtobufLibrary()Shut down the entire Protobuf library, deleting all static-duration objects allocated by the library or by generated .pb.cc files.
There are two reasons you might want to call this:
It is safe to call this multiple times. However, it is not safe to use any other part of the protocol buffers library after ShutdownProtobufLibrary() has been called. Furthermore this call is not thread safe, user needs to synchronize multiple calls.
+It is safe to call this multiple times. However, it is not safe to use any other part of the Protobuf library after ShutdownProtobufLibrary() has been called. Furthermore this call is not thread safe, user needs to synchronize multiple calls.
#include <google/protobuf/message_lite.h>
namespace google::protobuf
Interface to light weight protocol messages.
This interface is implemented by all protocol message objects. Non-lite messages additionally implement the Message interface, which is a subclass of MessageLite. Use MessageLite instead when you only need the subset of features which it supports – namely, nothing that uses descriptors or reflection. You can instruct the protocol compiler to generate classes which implement only MessageLite, not the full Message interface, by adding the following line to the .proto file:
option optimize_for = LITE_RUNTIME;-
This is particularly useful on resource-constrained systems where the full protocol buffers runtime library is too big.
+This is particularly useful on resource-constrained systems where the full Protobuf runtime library is too big.
-Note that on non-constrained systems (e.g. servers) when you need to link in lots of protocol definitions, a better way to reduce total code footprint is to use optimize_for = CODE_SIZE. This will make the generated code smaller while still supporting all the same features (at the expense of speed). optimize_for = LITE_RUNTIME is best when you only have a small number of message types linked into your binary, in which case the size of the protocol buffers runtime itself is the biggest problem.
+Note that on non-constrained systems (e.g. servers) when you need to link in lots of protocol definitions, a better way to reduce total code footprint is to use optimize_for = CODE_SIZE. This will make the generated code smaller while still supporting all the same features (at the expense of speed). optimize_for = LITE_RUNTIME is best when you only have a small number of message types linked into your binary, in which case the size of the Protobuf runtime itself is the biggest problem.
Users must not derive from this class. Only the protocol compiler and the internal library are allowed to create subclasses.
Known subclasses:
Members | |
|---|---|
enum | ParseFlags |
protected internal::InternalMetadata | _internal_metadata_ |
constexpr | MessageLite() |
virtual | ~MessageLite() |
template bool | ParseFrom(const T & input) |
virtual uint8 * | _InternalSerialize(uint8 * ptr, io::EpsCopyOutputStream * stream) const = 0Fast path when conditions match (ie. more... |
bool | IsInitializedWithErrors() constIdentical to IsInitialized() except that it logs an error message. |
protected template static T * | CreateMaybeMessage(Arena * arena) |
protected explicit | MessageLite(Arena * arena) |
protected Arena * | GetOwningArena() constReturns the arena, if any, that directly owns this message and its internal memory (Arena::Own is different in that the arena doesn't directly own the internal memory). more... |
protected Arena * | GetArenaForAllocation() constReturns the arena, used for allocating internal objects(e.g., child messages, etc), or owning incoming objects (e.g., set allocated). |
Basic Operations | |
virtual std::string | GetTypeName() const = 0Get the name of this message type, e.g. "foo.bar.BazProto". |
virtual MessageLite * | New() const = 0Construct a new instance of the same type. more... |
virtual MessageLite * | New(Arena * arena) constConstruct a new instance on the arena. more... |
Arena * | GetArena() constSame as GetOwningArena. |
void * | GetMaybeArenaPointer() constGet a pointer that may be equal to this message's arena, or may not be. more... |
virtual void | Clear() = 0Clear all fields of the message and set them to their default values. more... |
virtual bool | IsInitialized() const = 0Quickly check if all required fields have values set. |
virtual std::string | InitializationErrorString() constThis is not implemented for Lite messages – it just returns "(cannot
determine missing fields for lite message)". more... |
virtual void | CheckTypeAndMergeFrom(const MessageLite & other) = 0If |other| is the exact same class as this, calls MergeFrom(). more... |
std::string | DebugString() constThese methods return a human-readable summary of the message. more... |
std::string | ShortDebugString() const |
std::string | Utf8DebugString() constMessageLite::DebugString is already Utf8 Safe. more... |
Parsing
- Methods for parsing in protocol buffer format. +Methods for parsing in Protobuf format. Most of these are just simple wrappers around MergeFromCodedStream(). Clear() will be called before merging the input. - | |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromCodedStream(io::CodedInputStream * input)Fill the message with a protocol buffer parsed from the given input stream. more... |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromCodedStream(io::CodedInputStream * input)Like ParseFromCodedStream(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromZeroCopyStream(io::ZeroCopyInputStream * input)Read a protocol buffer from the given zero-copy input stream. more... |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromZeroCopyStream(io::ZeroCopyInputStream * input)Like ParseFromZeroCopyStream(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromFileDescriptor(int file_descriptor)Parse a protocol buffer from a file descriptor. more... |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromFileDescriptor(int file_descriptor)Like ParseFromFileDescriptor(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromIstream(std::istream * input)Parse a protocol buffer from a C++ istream. more... |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromIstream(std::istream * input)Like ParseFromIstream(), but accepts messages that are missing required fields. |
bool | MergePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size)Read a protocol buffer from the given zero-copy input stream, expecting the message to be exactly "size" bytes long. more... |
bool | MergeFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size)Like ParseFromBoundedZeroCopyStream(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size) |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size)Like ParseFromBoundedZeroCopyStream(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromString(ConstStringParam data)Parses a protocol buffer contained in a string. more... |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromString(ConstStringParam data)Like ParseFromString(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromArray(const void * data, int size)Parse a protocol buffer contained in an array of bytes. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromArray(const void * data, int size)Like ParseFromArray(), but accepts messages that are missing required fields. |
bool | MergeFromCodedStream(io::CodedInputStream * input) |
bool | MergePartialFromCodedStream(io::CodedInputStream * input)Like MergeFromCodedStream(), but succeeds even if required fields are missing in the input. more... |
bool | MergeFromString(ConstStringParam data)Merge a protocol buffer contained in a string. |
Serialization
- Methods for serializing in protocol buffer format. + | |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromCodedStream(io::CodedInputStream * input)Fill the message with data parsed from the given input stream. more... |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromCodedStream(io::CodedInputStream * input)Like ParseFromCodedStream(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromZeroCopyStream(io::ZeroCopyInputStream * input)Read a Protobuf message from the given zero-copy input stream. more... |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromZeroCopyStream(io::ZeroCopyInputStream * input)Like ParseFromZeroCopyStream(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromFileDescriptor(int file_descriptor)Parse a Protobuf message from a file descriptor. more... |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromFileDescriptor(int file_descriptor)Like ParseFromFileDescriptor(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromIstream(std::istream * input)Parse a Protobuf message from a C++ istream. more... |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromIstream(std::istream * input)Like ParseFromIstream(), but accepts messages that are missing required fields. |
bool | MergePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size)Read a Protobuf message from the given zero-copy input stream, expecting the message to be exactly "size" bytes long. more... |
bool | MergeFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size)Like ParseFromBoundedZeroCopyStream(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size) |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size)Like ParseFromBoundedZeroCopyStream(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromString(ConstStringParam data)Parses a Protobuf message contained in a string. more... |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromString(ConstStringParam data)Like ParseFromString(), but accepts messages that are missing required fields. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParseFromArray(const void * data, int size)Parse a Protobuf message contained in an array of bytes. |
PROTOBUF_ATTRIBUTE_REINITIALIZES bool | ParsePartialFromArray(const void * data, int size)Like ParseFromArray(), but accepts messages that are missing required fields. |
bool | MergeFromCodedStream(io::CodedInputStream * input) |
bool | MergePartialFromCodedStream(io::CodedInputStream * input)Like MergeFromCodedStream(), but succeeds even if required fields are missing in the input. more... |
bool | MergeFromString(ConstStringParam data)Merge a Protobuf message contained in a string. |
Serialization
+ Methods for serializing in Protobuf format. Most of these are just simple wrappers around ByteSize() and SerializeWithCachedSizes(). - | |
bool | SerializeToCodedStream(io::CodedOutputStream * output) constWrite a protocol buffer of this message to the given output. more... |
bool | SerializePartialToCodedStream(io::CodedOutputStream * output) constLike SerializeToCodedStream(), but allows missing required fields. |
bool | SerializeToZeroCopyStream(io::ZeroCopyOutputStream * output) constWrite the message to the given zero-copy output stream. more... |
bool | SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream * output) constLike SerializeToZeroCopyStream(), but allows missing required fields. |
bool | SerializeToString(std::string * output) constSerialize the message and store it in the given string. more... |
bool | SerializePartialToString(std::string * output) constLike SerializeToString(), but allows missing required fields. |
bool | SerializeToArray(void * data, int size) constSerialize the message and store it in the given byte array. more... |
bool | SerializePartialToArray(void * data, int size) constLike SerializeToArray(), but allows missing required fields. |
std::string | SerializeAsString() constMake a string encoding the message. more... |
std::string | SerializePartialAsString() constLike SerializeAsString(), but allows missing required fields. |
bool | SerializeToFileDescriptor(int file_descriptor) constSerialize the message and write it to the given file descriptor. more... |
bool | SerializePartialToFileDescriptor(int file_descriptor) constLike SerializeToFileDescriptor(), but allows missing required fields. |
bool | SerializeToOstream(std::ostream * output) constSerialize the message and write it to the given C++ ostream. more... |
bool | SerializePartialToOstream(std::ostream * output) constLike SerializeToOstream(), but allows missing required fields. |
bool | AppendToString(std::string * output) constLike SerializeToString(), but appends to the data to the string's existing contents. more... |
bool | AppendPartialToString(std::string * output) constLike AppendToString(), but allows missing required fields. |
virtual size_t | ByteSizeLong() const = 0Computes the serialized size of the message. more... |
int | ByteSize() constLegacy ByteSize() API. |
void | SerializeWithCachedSizes(io::CodedOutputStream * output) constSerializes the message without recomputing the size. more... |
uint8 * | SerializeWithCachedSizesToArray(uint8 * target) constLike SerializeWithCachedSizes, but writes directly to *target, returning a pointer to the byte immediately after the last byte written. more... |
virtual int | GetCachedSize() const = 0Returns the result of the last call to ByteSize(). more... |
virtual const char * | _InternalParse(const char * , internal::ParseContext * ) |
enum MessageLite::ParseFlags {
kMerge = = 0,
kParse = = 1,
kMergePartial = = 2,
kParsePartial = = 3,
kMergeWithAliasing = = 4,
kParseWithAliasing = = 5,
kMergePartialWithAliasing = = 6,
kParsePartialWithAliasing = = 7
}| kMerge | |
| kParse | |
| kMergePartial | |
| kParsePartial | |
| kMergeWithAliasing | |
| kParseWithAliasing | |
| kMergePartialWithAliasing | |
| kParsePartialWithAliasing |
virtual uint8 * MessageLite::_InternalSerialize(
uint8 * ptr,
io::EpsCopyOutputStream * stream) const = 0Fast path when conditions match (ie.
non-deterministic) uint8* _InternalSerialize(uint8* ptr) const;
+boolSerializeToCodedStream(io::CodedOutputStream * output) constboolSerializePartialToCodedStream(io::CodedOutputStream * output) constboolSerializeToZeroCopyStream(io::ZeroCopyOutputStream * output) constboolSerializePartialToZeroCopyStream(io::ZeroCopyOutputStream * output) constboolSerializeToString(std::string * output) constboolSerializePartialToString(std::string * output) constboolSerializeToArray(void * data, int size) constboolSerializePartialToArray(void * data, int size) conststd::stringSerializeAsString() conststd::stringSerializePartialAsString() constboolSerializeToFileDescriptor(int file_descriptor) constboolSerializePartialToFileDescriptor(int file_descriptor) constboolSerializeToOstream(std::ostream * output) constboolSerializePartialToOstream(std::ostream * output) constboolAppendToString(std::string * output) constboolAppendPartialToString(std::string * output) constvirtual size_tByteSizeLong() const = 0intByteSize() constvoidSerializeWithCachedSizes(io::CodedOutputStream * output) constuint8 *SerializeWithCachedSizesToArray(uint8 * target) constvirtual intGetCachedSize() const = 0virtual const char *_InternalParse(const char * , internal::ParseContext * )enum MessageLite::ParseFlags {
kMerge = = 0,
kParse = = 1,
kMergePartial = = 2,
kParsePartial = = 3,
kMergeWithAliasing = = 4,
kParseWithAliasing = = 5,
kMergePartialWithAliasing = = 6,
kParsePartialWithAliasing = = 7
}| kMerge | |
| kParse | |
| kMergePartial | |
| kParsePartial | |
| kMergeWithAliasing | |
| kParseWithAliasing | |
| kMergePartialWithAliasing | |
| kParsePartialWithAliasing |
virtual uint8 * MessageLite::_InternalSerialize(
uint8 * ptr,
io::EpsCopyOutputStream * stream) const = 0Fast path when conditions match (ie.
non-deterministic) uint8* _InternalSerialize(uint8* ptr) const;
protected Arena * MessageLite::GetOwningArena() constReturns the arena, if any, that directly owns this message and its internal memory (Arena::Own is different in that the arena doesn't directly own the internal memory).
This method is used in proto's implementation for swapping, moving and setting allocated, for deciding whether the ownership of this message or its internal memory could be changed.
virtual MessageLite * MessageLite::New() const = 0Construct a new instance of the same type.
Ownership is passed to the caller.
virtual MessageLite * MessageLite::New(
Arena * arena) constConstruct a new instance on the arena.
Ownership is passed to the caller if arena is a NULL. Default implementation for backwards compatibility.
@@ -48,19 +48,19 @@ determine missing fields for lite message)".However, it is implemented f
The format of the returned string is subject to change, so please do not assume it will remain stable over time.
std::string MessageLite::Utf8DebugString() constMessageLite::DebugString is already Utf8 Safe.
This is to add compatibility with Message.
-PROTOBUF_ATTRIBUTE_REINITIALIZES bool
MessageLite::ParseFromCodedStream(
io::CodedInputStream * input)Fill the message with a protocol buffer parsed from the given input stream.
Returns false on a read error or if the input is in the wrong format. A successful return does not indicate the entire input is consumed, ensure you call ConsumedEntireMessage() to check that if applicable.
-PROTOBUF_ATTRIBUTE_REINITIALIZES bool
MessageLite::ParseFromZeroCopyStream(
io::ZeroCopyInputStream * input)Read a protocol buffer from the given zero-copy input stream.
If successful, the entire input will be consumed.
-PROTOBUF_ATTRIBUTE_REINITIALIZES bool
MessageLite::ParseFromFileDescriptor(
int file_descriptor)Parse a protocol buffer from a file descriptor.
If successful, the entire input will be consumed.
-PROTOBUF_ATTRIBUTE_REINITIALIZES bool
MessageLite::ParseFromIstream(
std::istream * input)Parse a protocol buffer from a C++ istream.
If successful, the entire input will be consumed.
-bool MessageLite::MergePartialFromBoundedZeroCopyStream(
io::ZeroCopyInputStream * input,
int size)Read a protocol buffer from the given zero-copy input stream, expecting the message to be exactly "size" bytes long.
If successful, exactly this many bytes will have been consumed from the input.
-PROTOBUF_ATTRIBUTE_REINITIALIZES bool
MessageLite::ParseFromString(
ConstStringParam data)Parses a protocol buffer contained in a string.
Returns true on success. This function takes a string in the (non-human-readable) binary wire format, matching the encoding output by MessageLite::SerializeToString(). If you'd like to convert a human-readable string into a protocol buffer object, see google::protobuf::TextFormat::ParseFromString().
-bool MessageLite::MergeFromCodedStream(
io::CodedInputStream * input)Reads a protocol buffer from the stream and merges it into this Message.
Singular fields read from the what is already in the Message and repeated fields are appended to those already present.
+PROTOBUF_ATTRIBUTE_REINITIALIZES bool
MessageLite::ParseFromCodedStream(
io::CodedInputStream * input)Fill the message with data parsed from the given input stream.
Returns false on a read error or if the input is in the wrong format. A successful return does not indicate the entire input is consumed, ensure you call ConsumedEntireMessage() to check that if applicable.
+PROTOBUF_ATTRIBUTE_REINITIALIZES bool
MessageLite::ParseFromZeroCopyStream(
io::ZeroCopyInputStream * input)Read a Protobuf message from the given zero-copy input stream.
If successful, the entire input will be consumed.
+PROTOBUF_ATTRIBUTE_REINITIALIZES bool
MessageLite::ParseFromFileDescriptor(
int file_descriptor)Parse a Protobuf message from a file descriptor.
If successful, the entire input will be consumed.
+PROTOBUF_ATTRIBUTE_REINITIALIZES bool
MessageLite::ParseFromIstream(
std::istream * input)Parse a Protobuf message from a C++ istream.
If successful, the entire input will be consumed.
+bool MessageLite::MergePartialFromBoundedZeroCopyStream(
io::ZeroCopyInputStream * input,
int size)Read a Protobuf message from the given zero-copy input stream, expecting the message to be exactly "size" bytes long.
If successful, exactly this many bytes will have been consumed from the input.
+PROTOBUF_ATTRIBUTE_REINITIALIZES bool
MessageLite::ParseFromString(
ConstStringParam data)Parses a Protobuf message contained in a string.
Returns true on success. This function takes a string in the (non-human-readable) binary wire format, matching the encoding output by MessageLite::SerializeToString(). If you'd like to convert a human-readable string into a Protobuf object, see google::protobuf::TextFormat::ParseFromString().
+bool MessageLite::MergeFromCodedStream(
io::CodedInputStream * input)Reads a Protobuf message from the stream and merges it into this Message.
Singular fields read from the what is already in the Message and repeated fields are appended to those already present.
It is the responsibility of the caller to call input->LastTagWas() (for groups) or input->ConsumedEntireMessage() (for non-groups) after this returns to verify that the message's end was delimited correctly.
ParseFromCodedStream() is implemented as Clear() followed by MergeFromCodedStream().
bool MessageLite::MergePartialFromCodedStream(
io::CodedInputStream * input)Like MergeFromCodedStream(), but succeeds even if required fields are missing in the input.
MergeFromCodedStream() is just implemented as MergePartialFromCodedStream() followed by IsInitialized().
-bool MessageLite::SerializeToCodedStream(
io::CodedOutputStream * output) constWrite a protocol buffer of this message to the given output.
Returns false on a write error. If the message is missing required fields, this may GOOGLE_CHECK-fail.
+bool MessageLite::SerializeToCodedStream(
io::CodedOutputStream * output) constWrite this Protobuf message to the given output.
Returns false on a write error. If the message is missing required fields, this may GOOGLE_CHECK-fail.
bool MessageLite::SerializeToZeroCopyStream(
io::ZeroCopyOutputStream * output) constWrite the message to the given zero-copy output stream.
All required fields must be set.
bool MessageLite::SerializeToString(
std::string * output) constSerialize the message and store it in the given string.
All required fields must be set.
bool MessageLite::SerializeToArray(
void * data,
int size) constSerialize the message and store it in the given byte array.
All required fields must be set.
diff --git a/content/reference/cpp/api-docs/google.protobuf.repeated_field.md b/content/reference/cpp/api-docs/google.protobuf.repeated_field.md index 7dafc1aac..62824ecd2 100644 --- a/content/reference/cpp/api-docs/google.protobuf.repeated_field.md +++ b/content/reference/cpp/api-docs/google.protobuf.repeated_field.md @@ -2,11 +2,11 @@ title = "repeated_field.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -#include <google/protobuf/repeated_field.h>
namespace google::protobuf
RepeatedField and RepeatedPtrField are used by generated protocol message classes to manipulate repeated fields.
These classes are very similar to STL's vector, but include a number of optimizations found to be useful specifically in the case of Protocol Buffers. RepeatedPtrField is particularly different from STL vector as it manages ownership of the pointers that it contains.
+#include <google/protobuf/repeated_field.h>
namespace google::protobuf
RepeatedField and RepeatedPtrField are used by generated protocol message classes to manipulate repeated fields.
These classes are very similar to STL's vector, but include a number of optimizations found to be useful specifically in the case of Protobuf. RepeatedPtrField is particularly different from STL vector as it manages ownership of the pointers that it contains.
Typically, clients should not need to access RepeatedField objects directly, but should instead use the accessor functions generated automatically by the protocol compiler.
diff --git a/content/reference/cpp/api-docs/google.protobuf.service.md b/content/reference/cpp/api-docs/google.protobuf.service.md index dd36735e7..e4d9b0070 100644 --- a/content/reference/cpp/api-docs/google.protobuf.service.md +++ b/content/reference/cpp/api-docs/google.protobuf.service.md @@ -2,7 +2,7 @@ title = "service.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ @@ -83,7 +83,7 @@ service->CallMethod(method, *request, response, callback);virtual voidSetFailed(const std::string & reason) = 0virtual boolIsCanceled() const = 0virtual voidNotifyOnCancel(Closure * callback) = 0virtual void RpcController::Reset() = 0Resets the RpcController to its initial state so that it may be reused in a new call.
Must not be called while an RPC is in progress.
virtual bool RpcController::Failed() const = 0After a call has finished, returns true if the call failed.
The possible reasons for failure depend on the RPC implementation. Failed() must not be called before a call has finished. If Failed() returns true, the contents of the response message are undefined.
virtual void RpcController::StartCancel() = 0Advises the RPC system that the caller desires that the RPC call be canceled.
The RPC system may cancel it immediately, may wait awhile and then cancel it, or may not even cancel the call at all. If the call is canceled, the "done" callback will still be called and the RpcController will indicate that the call failed at that time.
-virtual void RpcController::SetFailed(
const std::string & reason) = 0Causes Failed() to return true on the client side.
"reason" will be incorporated into the message returned by ErrorText(). If you find you need to return machine-readable information about failures, you should incorporate it into your response protocol buffer and should NOT call SetFailed().
+virtual void RpcController::SetFailed(
const std::string & reason) = 0Causes Failed() to return true on the client side.
"reason" will be incorporated into the message returned by ErrorText(). If you find you need to return machine-readable information about failures, you should incorporate it into your response Protobuf message and should NOT call SetFailed().
virtual bool RpcController::IsCanceled() const = 0If true, indicates that the client canceled the RPC, so the server may as well give up on replying to it.
The server should still call the final "done" callback.
virtual void RpcController::NotifyOnCancel(
Closure * callback) = 0Asks that the given callback be called when the RPC is canceled.
The callback will always be called exactly once. If the RPC completes without being canceled, the callback will be called after completion. If the RPC has already been canceled when NotifyOnCancel() is called, the callback will be called immediately.
NotifyOnCancel() must be called no more than once per request.
diff --git a/content/reference/cpp/api-docs/google.protobuf.text_format.md b/content/reference/cpp/api-docs/google.protobuf.text_format.md index 26ae8cebb..f02945f34 100644 --- a/content/reference/cpp/api-docs/google.protobuf.text_format.md +++ b/content/reference/cpp/api-docs/google.protobuf.text_format.md @@ -2,11 +2,11 @@ title = "text_format.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -#include <google/protobuf/text_format.h>
namespace google::protobuf
Utilities for printing and parsing protocol messages in a human-readable, text-based format.
Classes in this file | |
|---|---|
This class implements protocol buffer text format, colloquially known as text proto. | |
The default printer that converts scalar values from fields into their string representation. | |
Deprecated: please use FastFieldValuePrinter instead. | |
Interface that Printers or Parsers can use to find extensions, or types referenced in Any messages. | |
Data structure which is populated with the locations of each field value parsed from the text. | |
A location in the parsed text. | |
For more control over parsing, use this class. | |
Class for those users which require more fine-grained control over how a protobuffer message is printed out. | |
#include <google/protobuf/text_format.h>
namespace google::protobuf
This class implements protocol buffer text format, colloquially known as text proto.
Printing and parsing protocol messages in text format is useful for debugging and human editing of messages.
+#include <google/protobuf/text_format.h>
namespace google::protobuf
Utilities for printing and parsing protocol messages in a human-readable, text-based format.
Classes in this file | |
|---|---|
This class implements Protobuf text format, colloquially known as text proto. | |
The default printer that converts scalar values from fields into their string representation. | |
Deprecated: please use FastFieldValuePrinter instead. | |
Interface that Printers or Parsers can use to find extensions, or types referenced in Any messages. | |
Data structure which is populated with the locations of each field value parsed from the text. | |
A location in the parsed text. | |
For more control over parsing, use this class. | |
Class for those users which require more fine-grained control over how a Protobuf message is printed out. | |
#include <google/protobuf/text_format.h>
namespace google::protobuf
This class implements Protobuf text format, colloquially known as text proto.
Printing and parsing protocol messages in text format is useful for debugging and human editing of messages.
This class is really a namespace that contains only static methods.
@@ -18,7 +18,7 @@ type = "docs"static bool TextFormat::Parse(
io::ZeroCopyInputStream * input,
Message * output)Parses a text-format protocol message from the given input stream to the given message object.
This function parses the human-readable format written by Print(). Returns true on success. The message is cleared first, even if the function fails – See Merge() to avoid this behavior.
Example input: "user {\n id: 123 extra { gender: MALE language: 'en' }\n}"
One use for this function is parsing handwritten strings in test code. Another use is to parse the output from google::protobuf::Message::DebugString() (or ShortDebugString()), because these functions output using google::protobuf::TextFormat::Print().
-If you would like to read a protocol buffer serialized in the (non-human-readable) binary wire format, see google::protobuf::MessageLite::ParseFromString().
+If you would like to read a Protobuf message serialized in the (non-human-readable) binary wire format, see google::protobuf::MessageLite::ParseFromString().
static bool TextFormat::ParseFieldValueFromString(
const std::string & input,
const FieldDescriptor * field,
Message * message)Parse the given text as a single field value and store it into the given field of the given message.
If the field is a repeated field, the new value will be added to the end
#include <google/protobuf/text_format.h>
namespace google::protobuf
Members | |
|---|---|
virtual | ~BaseTextGenerator() |
virtual void | Indent() |
virtual void | Outdent() |
virtual size_t | GetCurrentIndentationSize() constReturns the current indentation size in characters. |
virtual void | Print(const char * text, size_t size) = 0Print text to the output stream. |
void | PrintString(const std::string & str) |
template void | PrintLiteral(const char(&) text) |
#include <google/protobuf/text_format.h>
namespace google::protobuf
The default printer that converts scalar values from fields into their string representation.
You can derive from this FastFieldValuePrinter if you want to have fields to be printed in a different way and register it at the Printer.
Members | |
|---|---|
| FastFieldValuePrinter() |
virtual | ~FastFieldValuePrinter() |
virtual void | PrintBool(bool val, BaseTextGenerator * generator) const |
virtual void | PrintInt32(int32 val, BaseTextGenerator * generator) const |
virtual void | PrintUInt32(uint32 val, BaseTextGenerator * generator) const |
virtual void | PrintInt64(int64 val, BaseTextGenerator * generator) const |
virtual void | PrintUInt64(uint64 val, BaseTextGenerator * generator) const |
virtual void | PrintFloat(float val, BaseTextGenerator * generator) const |
virtual void | PrintDouble(double val, BaseTextGenerator * generator) const |
virtual void | PrintString(const std::string & val, BaseTextGenerator * generator) const |
virtual void | PrintBytes(const std::string & val, BaseTextGenerator * generator) const |
virtual void | PrintEnum(int32 val, const std::string & name, BaseTextGenerator * generator) const |
virtual void | PrintFieldName(const Message & message, int field_index, int field_count, const Reflection * reflection, const FieldDescriptor * field, BaseTextGenerator * generator) const |
virtual void | PrintFieldName(const Message & message, const Reflection * reflection, const FieldDescriptor * field, BaseTextGenerator * generator) const |
virtual void | PrintMessageStart(const Message & message, int field_index, int field_count, bool single_line_mode, BaseTextGenerator * generator) const |
virtual bool | PrintMessageContent(const Message & message, int field_index, int field_count, bool single_line_mode, BaseTextGenerator * generator) constAllows to override the logic on how to print the content of a message. more... |
virtual void | PrintMessageEnd(const Message & message, int field_index, int field_count, bool single_line_mode, BaseTextGenerator * generator) const |
virtual bool FastFieldValuePrinter::PrintMessageContent(
const Message & message,
int field_index,
int field_count,
bool single_line_mode,
BaseTextGenerator * generator) constAllows to override the logic on how to print the content of a message.
Return false to use the default printing logic. Note that it is legal for this function to print something and then return false to use the default content printing (although at that point it would behave similarly to PrintMessageStart).
@@ -35,12 +35,12 @@ type = "docs"void Parser::AllowUnknownExtension(
bool allow)When an unknown extension is met, parsing will fail if this option is set to false (the default).
If true, unknown extensions will be ignored and a warning message will be generated. Beware! Setting this option true may hide some errors (e.g. spelling error on extension name). This allows data loss; unlike binary format, text format cannot preserve unknown extensions. Avoid using this option if possible.
void Parser::AllowUnknownField(
bool allow)When an unknown field is met, parsing will fail if this option is set to false (the default).
If true, unknown fields will be ignored and a warning message will be generated. Beware! Setting this option true may hide some errors (e.g. spelling error on field name). This allows data loss; unlike binary format, text format cannot preserve unknown fields. Avoid using this option if possible.
void Parser::SetRecursionLimit(
int limit)Sets maximum recursion depth which parser can use.
This is effectively the maximum allowed nesting of proto messages.
-#include <google/protobuf/text_format.h>
namespace google::protobuf
Class for those users which require more fine-grained control over how a protobuffer message is printed out.
Members | |
|---|---|
| Printer() |
bool | Print(const Message & message, io::ZeroCopyOutputStream * output) constLike TextFormat::Print. |
bool | PrintUnknownFields(const UnknownFieldSet & unknown_fields, io::ZeroCopyOutputStream * output) const |
bool | PrintToString(const Message & message, std::string * output) const |
bool | PrintUnknownFieldsToString(const UnknownFieldSet & unknown_fields, std::string * output) const |
void | PrintFieldValueToString(const Message & message, const FieldDescriptor * field, int index, std::string * output) const |
void | SetInitialIndentLevel(int indent_level)Adjust the initial indent level of all output. more... |
void | SetSingleLineMode(bool single_line_mode)If printing in single line mode, then the entire message will be output on a single line with no line breaks. |
bool | IsInSingleLineMode() const |
void | SetUseFieldNumber(bool use_field_number)If use_field_number is true, uses field number instead of field name. |
void | SetUseShortRepeatedPrimitives(bool use_short_repeated_primitives)Set true to print repeated primitives in a format like: more... |
void | SetUseUtf8StringEscaping(bool as_utf8)Set true to output UTF-8 instead of ASCII. more... |
void | SetDefaultFieldValuePrinter(const FastFieldValuePrinter * printer)Set the default FastFieldValuePrinter that is used for all fields that don't have a field-specific printer registered. more... |
void | SetDefaultFieldValuePrinter(const FieldValuePrinter * printer) |
void | SetHideUnknownFields(bool hide)Sets whether we want to hide unknown fields or not. more... |
void | SetPrintMessageFieldsInIndexOrder(bool print_message_fields_in_index_order)If print_message_fields_in_index_order is true, fields of a proto message will be printed using the order defined in source code instead of the field number, extensions will be printed at the end of the message and their relative order is determined by the extension number. more... |
void | SetExpandAny(bool expand)If expand==true, expand google.protobuf.Any payloads. more... |
void | SetFinder(const Finder * finder)Set how parser finds message for Any payloads. |
void | SetTruncateStringFieldLongerThan(const int64 truncate_string_field_longer_than)If non-zero, we truncate all string fields that are longer than this threshold. more... |
bool | RegisterFieldValuePrinter(const FieldDescriptor * field, const FastFieldValuePrinter * printer)Register a custom field-specific FastFieldValuePrinter for fields with a particular FieldDescriptor. more... |
bool | RegisterFieldValuePrinter(const FieldDescriptor * field, const FieldValuePrinter * printer) |
bool | RegisterMessagePrinter(const Descriptor * descriptor, const MessagePrinter * printer)Register a custom message-specific MessagePrinter for messages with a particular Descriptor. more... |
void Printer::SetInitialIndentLevel(
int indent_level)Adjust the initial indent level of all output.
Each indent level is equal to two spaces.
+#include <google/protobuf/text_format.h>
namespace google::protobuf
Class for those users which require more fine-grained control over how a Protobuf message is printed out.
Members | |
|---|---|
| Printer() |
bool | Print(const Message & message, io::ZeroCopyOutputStream * output) constLike TextFormat::Print. |
bool | PrintUnknownFields(const UnknownFieldSet & unknown_fields, io::ZeroCopyOutputStream * output) const |
bool | PrintToString(const Message & message, std::string * output) const |
bool | PrintUnknownFieldsToString(const UnknownFieldSet & unknown_fields, std::string * output) const |
void | PrintFieldValueToString(const Message & message, const FieldDescriptor * field, int index, std::string * output) const |
void | SetInitialIndentLevel(int indent_level)Adjust the initial indent level of all output. more... |
void | SetSingleLineMode(bool single_line_mode)If printing in single line mode, then the entire message will be output on a single line with no line breaks. |
bool | IsInSingleLineMode() const |
void | SetUseFieldNumber(bool use_field_number)If use_field_number is true, uses field number instead of field name. |
void | SetUseShortRepeatedPrimitives(bool use_short_repeated_primitives)Set true to print repeated primitives in a format like: more... |
void | SetUseUtf8StringEscaping(bool as_utf8)Set true to output UTF-8 instead of ASCII. more... |
void | SetDefaultFieldValuePrinter(const FastFieldValuePrinter * printer)Set the default FastFieldValuePrinter that is used for all fields that don't have a field-specific printer registered. more... |
void | SetDefaultFieldValuePrinter(const FieldValuePrinter * printer) |
void | SetHideUnknownFields(bool hide)Sets whether we want to hide unknown fields or not. more... |
void | SetPrintMessageFieldsInIndexOrder(bool print_message_fields_in_index_order)If print_message_fields_in_index_order is true, fields of a proto message will be printed using the order defined in source code instead of the field number, extensions will be printed at the end of the message and their relative order is determined by the extension number. more... |
void | SetExpandAny(bool expand)If expand==true, expand google.protobuf.Any payloads. more... |
void | SetFinder(const Finder * finder)Set how parser finds message for Any payloads. |
void | SetTruncateStringFieldLongerThan(const int64 truncate_string_field_longer_than)If non-zero, we truncate all string fields that are longer than this threshold. more... |
bool | RegisterFieldValuePrinter(const FieldDescriptor * field, const FastFieldValuePrinter * printer)Register a custom field-specific FastFieldValuePrinter for fields with a particular FieldDescriptor. more... |
bool | RegisterFieldValuePrinter(const FieldDescriptor * field, const FieldValuePrinter * printer) |
bool | RegisterMessagePrinter(const Descriptor * descriptor, const MessagePrinter * printer)Register a custom message-specific MessagePrinter for messages with a particular Descriptor. more... |
void Printer::SetInitialIndentLevel(
int indent_level)Adjust the initial indent level of all output.
Each indent level is equal to two spaces.
void Printer::SetUseShortRepeatedPrimitives(
bool use_short_repeated_primitives)Set true to print repeated primitives in a format like:
field_name: [1, 2, 3, 4]
instead of printing each value on its own line. Short format applies only to primitive values – i.e. everything except strings and sub-messages/groups.
void Printer::SetUseUtf8StringEscaping(
bool as_utf8)Set true to output UTF-8 instead of ASCII.
The only difference is that bytes >= 0x80 in string fields will not be escaped, because they are assumed to be part of UTF-8 multi-byte sequences. This will change the default FastFieldValuePrinter.
void Printer::SetDefaultFieldValuePrinter(
const FastFieldValuePrinter * printer)Set the default FastFieldValuePrinter that is used for all fields that don't have a field-specific printer registered.
Takes ownership of the printer.
-void Printer::SetHideUnknownFields(
bool hide)Sets whether we want to hide unknown fields or not.
Usually unknown fields are printed in a generic way that includes the tag number of the field instead of field name. However, sometimes it is useful to be able to print the message without unknown fields (e.g. for the python protobuf version to maintain consistency between its pure python and c++ implementations).
+void Printer::SetHideUnknownFields(
bool hide)Sets whether we want to hide unknown fields or not.
Usually unknown fields are printed in a generic way that includes the tag number of the field instead of field name. However, sometimes it is useful to be able to print the message without unknown fields (e.g. for the python Protobuf version to maintain consistency between its pure python and c++ implementations).
void Printer::SetPrintMessageFieldsInIndexOrder(
bool print_message_fields_in_index_order)If print_message_fields_in_index_order is true, fields of a proto message will be printed using the order defined in source code instead of the field number, extensions will be printed at the end of the message and their relative order is determined by the extension number.
By default, use the field number order.
void Printer::SetExpandAny(
bool expand)If expand==true, expand google.protobuf.Any payloads.
The output will be of form
[type_url] { <value_printed_in_text> }
diff --git a/content/reference/cpp/api-docs/google.protobuf.unknown_field_set.md b/content/reference/cpp/api-docs/google.protobuf.unknown_field_set.md
index 8eb6e768f..7ebb4623b 100644
--- a/content/reference/cpp/api-docs/google.protobuf.unknown_field_set.md
+++ b/content/reference/cpp/api-docs/google.protobuf.unknown_field_set.md
@@ -4,7 +4,7 @@
title = "unknown_field_set.h"
toc_hide = "true"
linkTitle = "C++"
-description = "This section contains reference documentation for working with protocol buffer classes in C++."
+description = "This section contains reference documentation for working with Protobuf classes in C++."
type = "docs"
+++
@@ -12,7 +12,7 @@ type = "docs"
To get the UnknownFieldSet attached to any message, call Reflection::GetUnknownFields().
-This class is necessarily tied to the protocol buffer wire format, unlike the Reflection interface which is independent of any serialization scheme.
+This class is necessarily tied to the Protobuf wire format, unlike the Reflection interface which is independent of any serialization scheme.
Members | |
|---|---|
| UnknownFieldSet() |
| ~UnknownFieldSet() |
void | Clear()Remove all fields. |
void | ClearAndFreeMemory()Remove all fields and deallocate internal data objects. |
bool | empty() constIs this set empty? |
void | MergeFrom(const UnknownFieldSet & other)Merge the contents of some other UnknownFieldSet with this one. |
void | MergeFromAndDestroy(UnknownFieldSet * other)Similar to above, but this function will destroy the contents of other. |
void | Swap(UnknownFieldSet * x)Swaps the contents of some other UnknownFieldSet with this one. |
size_t | SpaceUsedExcludingSelfLong() constComputes (an estimate of) the total number of bytes currently used for storing the unknown fields in memory. more... |
int | SpaceUsedExcludingSelf() const |
size_t | SpaceUsedLong() constVersion of SpaceUsed() including sizeof(*this). |
int | SpaceUsed() const |
int | field_count() constReturns the number of fields present in the UnknownFieldSet. |
const UnknownField & | field(int index) constGet a field in the set, where 0 <= index < field_count(). more... |
UnknownField * | mutable_field(int index)Get a mutable pointer to a field in the set, where 0 <= index < field_count(). more... |
static void | MergeToInternalMetadata(const UnknownFieldSet & other, internal::InternalMetadata * metadata)Merge the contents an UnknownFieldSet with the UnknownFieldSet in *metadata, if there is one. more... |
Adding fields | |
void | AddVarint(int number, uint64 value) |
void | AddFixed32(int number, uint32 value) |
void | AddFixed64(int number, uint64 value) |
void | AddLengthDelimited(int number, const std::string & value) |
std::string * | AddLengthDelimited(int number) |
UnknownFieldSet * | AddGroup(int number) |
void | AddField(const UnknownField & field)Adds an unknown field from another set. |
void | DeleteSubrange(int start, int num)Delete fields with indices in the range [start . more... |
void | DeleteByNumber(int number)Delete all fields with a specific field number. more... |
Parsing helpersThese work exactly like the similarly-named methods of Message. | |
bool | MergeFromCodedStream(io::CodedInputStream * input) |
bool | ParseFromCodedStream(io::CodedInputStream * input) |
bool | ParseFromZeroCopyStream(io::ZeroCopyInputStream * input) |
bool | ParseFromArray(const void * data, int size) |
bool | ParseFromString(const std::string & data) |
template bool | MergeFromMessage(const MessageType & message)Merges this message's unknown field data (if any). more... |
static const UnknownFieldSet & | default_instance() |
size_t UnknownFieldSet::SpaceUsedExcludingSelfLong() constComputes (an estimate of) the total number of bytes currently used for storing the unknown fields in memory.
Does NOT include sizeof(*this) in the calculation.
const UnknownField &
UnknownFieldSet::field(
int index) constGet a field in the set, where 0 <= index < field_count().
The fields appear in the order in which they were added.
diff --git a/content/reference/cpp/api-docs/google.protobuf.util.field_comparator.md b/content/reference/cpp/api-docs/google.protobuf.util.field_comparator.md index af327e911..2e031bbe1 100644 --- a/content/reference/cpp/api-docs/google.protobuf.util.field_comparator.md +++ b/content/reference/cpp/api-docs/google.protobuf.util.field_comparator.md @@ -4,16 +4,16 @@ title = "field_comparator.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -#include <google/protobuf/util/field_comparator.h>
namespace google::protobuf::util
Defines classes for field comparison.
Classes in this file | |
|---|---|
Base class specifying the interface for comparing protocol buffer fields. | |
Basic implementation of FieldComparator. | |
#include <google/protobuf/util/field_comparator.h>
namespace google::protobuf::util
Base class specifying the interface for comparing protocol buffer fields.
Regular users should consider using or subclassing DefaultFieldComparator rather than this interface. Currently, this does not support comparing unknown fields.
+#include <google/protobuf/util/field_comparator.h>
namespace google::protobuf::util
Defines classes for field comparison.
Classes in this file | |
|---|---|
Base class specifying the interface for comparing Protobuf fields. | |
Basic implementation of FieldComparator. | |
#include <google/protobuf/util/field_comparator.h>
namespace google::protobuf::util
Base class specifying the interface for comparing Protobuf fields.
Regular users should consider using or subclassing DefaultFieldComparator rather than this interface. Currently, this does not support comparing unknown fields.
-Known subclasses:
Members | |
|---|---|
enum | ComparisonResult |
| FieldComparator() |
virtual | ~FieldComparator() |
virtual ComparisonResult | Compare(const Message & message_1, const Message & message_2, const FieldDescriptor * field, int index_1, int index_2, const util::FieldContext * field_context) = 0Compares the values of a field in two protocol buffer messages. more... |
enum FieldComparator::ComparisonResult {
SAME,
DIFFERENT,
RECURSE
}| SAME | Compared fields are equal. In case of comparing submessages, user should not recursively compare their contents. +Known subclasses:
SAME, DIFFERENT, RECURSE } | ||||||||||||||||
| SAME | Compared fields are equal. In case of comparing submessages, user should not recursively compare their contents. |
| DIFFERENT | Compared fields are different. In case of comparing submessages, user should not recursively compare their contents. |
| RECURSE | Compared submessages need to be compared recursively. FieldComparator does not specify the semantics of recursive comparison. This value should not be returned for simple values. - |
virtual ComparisonResult FieldComparator::Compare(
const Message & message_1,
const Message & message_2,
const FieldDescriptor * field,
int index_1,
int index_2,
const util::FieldContext * field_context) = 0Compares the values of a field in two protocol buffer messages.
Returns SAME or DIFFERENT for simple values, and SAME, DIFFERENT or RECURSE for submessages. Returning RECURSE for fields not being submessages is illegal. In case the given FieldDescriptor points to a repeated field, the indices need to be valid. Otherwise they should be ignored.
+virtual ComparisonResult FieldComparator::Compare(
const Message & message_1,
const Message & message_2,
const FieldDescriptor * field,
int index_1,
int index_2,
const util::FieldContext * field_context) = 0Compares the values of a field in two Protobuf messages.
Returns SAME or DIFFERENT for simple values, and SAME, DIFFERENT or RECURSE for submessages. Returning RECURSE for fields not being submessages is illegal. In case the given FieldDescriptor points to a repeated field, the indices need to be valid. Otherwise they should be ignored.
FieldContext contains information about the specific instances of the fields being compared, versus FieldDescriptor which only contains general type information about the fields.
#include <google/protobuf/util/field_comparator.h>
namespace google::protobuf::util
Basic implementation of FieldComparator.
Supports three modes of floating point value comparison: exact, approximate using MathUtil::AlmostEqual method, and arbitrarily precise using MathUtil::WithinFractionOrMargin.
@@ -31,7 +31,7 @@ type = "docs"REQUIRES: float_comparison_ == APPROXIMATE
protected ComparisonResult SimpleFieldComparator::SimpleCompare(
const Message & message_1,
const Message & message_2,
const FieldDescriptor * field,
int index_1,
int index_2,
const util::FieldContext * field_context)Returns the comparison result for the given field in two messages.
This function is called directly by DefaultFieldComparator::Compare. Subclasses can call this function to compare fields they do not need to handle specially.
protected bool SimpleFieldComparator::CompareWithDifferencer(
MessageDifferencer * differencer,
const Message & message1,
const Message & message2,
const util::FieldContext * field_context)Compare using the provided message_differencer.
For example, a subclass can use this method to compare some field in a certain way using the same message_differencer instance and the field context.
-#include <google/protobuf/util/field_comparator.h>
namespace google::protobuf::util
Members | |
|---|---|
virtual ComparisonResult | Compare(const Message & message_1, const Message & message_2, const FieldDescriptor * field, int index_1, int index_2, const util::FieldContext * field_context)Compares the values of a field in two protocol buffer messages. more... |
virtual ComparisonResult DefaultFieldComparator::Compare(
const Message & message_1,
const Message & message_2,
const FieldDescriptor * field,
int index_1,
int index_2,
const util::FieldContext * field_context)Compares the values of a field in two protocol buffer messages.
Returns SAME or DIFFERENT for simple values, and SAME, DIFFERENT or RECURSE for submessages. Returning RECURSE for fields not being submessages is illegal. In case the given FieldDescriptor points to a repeated field, the indices need to be valid. Otherwise they should be ignored.
+#include <google/protobuf/util/field_comparator.h>
namespace google::protobuf::util
Members | |
|---|---|
virtual ComparisonResult | Compare(const Message & message_1, const Message & message_2, const FieldDescriptor * field, int index_1, int index_2, const util::FieldContext * field_context)Compares the values of a field in two Protobuf messages. more... |
virtual ComparisonResult DefaultFieldComparator::Compare(
const Message & message_1,
const Message & message_2,
const FieldDescriptor * field,
int index_1,
int index_2,
const util::FieldContext * field_context)Compares the values of a field in two Protobuf messages.
Returns SAME or DIFFERENT for simple values, and SAME, DIFFERENT or RECURSE for submessages. Returning RECURSE for fields not being submessages is illegal. In case the given FieldDescriptor points to a repeated field, the indices need to be valid. Otherwise they should be ignored.
FieldContext contains information about the specific instances of the fields being compared, versus FieldDescriptor which only contains general type information about the fields.
diff --git a/content/reference/cpp/api-docs/google.protobuf.util.field_mask_util.md b/content/reference/cpp/api-docs/google.protobuf.util.field_mask_util.md index 9b85ebf1b..864385650 100644 --- a/content/reference/cpp/api-docs/google.protobuf.util.field_mask_util.md +++ b/content/reference/cpp/api-docs/google.protobuf.util.field_mask_util.md @@ -2,15 +2,15 @@ title = "field_mask_util.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -#include <google/protobuf/util/field_mask_util.h>
namespace google::protobuf::util
Defines utilities for the FieldMask well known type.
Classes in this file | |
|---|---|
#include <google/protobuf/util/field_mask_util.h>
namespace google::protobuf::util
Members | |
|---|---|
static std::string | ToString(const FieldMask & mask)Converts FieldMask to/from string, formatted by separating each path with a comma (e.g., "foo_bar,baz.quz"). |
static void | FromString(StringPiece str, FieldMask * out) |
template static void | FromFieldNumbers(const std::vector< int64_t > & field_numbers, FieldMask * out)Populates the FieldMask with the paths corresponding to the fields with the given numbers, after checking that all field numbers are valid. |
static bool | ToJsonString(const FieldMask & mask, std::string * out)Converts FieldMask to/from string, formatted according to proto3 JSON spec for FieldMask (e.g., "fooBar,baz.quz"). more... |
static bool | FromJsonString(StringPiece str, FieldMask * out) |
static bool | GetFieldDescriptors(const Descriptor * descriptor, StringPiece path, std::vector< const FieldDescriptor * > * field_descriptors)Get the descriptors of the fields which the given path from the message descriptor traverses, if field_descriptors is not null. more... |
template static bool | IsValidPath(StringPiece path)Checks whether the given path is valid for type T. |
template static bool | IsValidFieldMask(const FieldMask & mask)Checks whether the given FieldMask is valid for type T. |
template static void | AddPathToFieldMask(StringPiece path, FieldMask * mask)Adds a path to FieldMask after checking whether the given path is valid. more... |
template static FieldMask | GetFieldMaskForAllFields()Creates a FieldMask with all fields of type T. more... |
template static void | GetFieldMaskForAllFields(FieldMask * out) |
static void | GetFieldMaskForAllFields(const Descriptor * descriptor, FieldMask * out)This flavor takes the protobuf type descriptor as an argument. more... |
static void | ToCanonicalForm(const FieldMask & mask, FieldMask * out)Converts a FieldMask to the canonical form. more... |
static void | Union(const FieldMask & mask1, const FieldMask & mask2, FieldMask * out)Creates an union of two FieldMasks. |
static void | Intersect(const FieldMask & mask1, const FieldMask & mask2, FieldMask * out)Creates an intersection of two FieldMasks. |
template static void | Subtract(const FieldMask & mask1, const FieldMask & mask2, FieldMask * out)Subtracts mask2 from mask1 base of type T. |
static void | Subtract(const Descriptor * descriptor, const FieldMask & mask1, const FieldMask & mask2, FieldMask * out)This flavor takes the protobuf type descriptor as an argument. more... |
static bool | IsPathInFieldMask(StringPiece path, const FieldMask & mask)Returns true if path is covered by the given FieldMask. more... |
static void | MergeMessageTo(const Message & source, const FieldMask & mask, const MergeOptions & options, Message * destination)Merges fields specified in a FieldMask into another message. |
static bool | TrimMessage(const FieldMask & mask, Message * message)Removes from 'message' any field that is not represented in the given FieldMask. more... |
static bool | TrimMessage(const FieldMask & mask, Message * message, const TrimOptions & options)Removes from 'message' any field that is not represented in the given FieldMask with customized TrimOptions. more... |
static bool FieldMaskUtil::ToJsonString(
const FieldMask & mask,
std::string * out)Converts FieldMask to/from string, formatted according to proto3 JSON spec for FieldMask (e.g., "fooBar,baz.quz").
If the field name is not style conforming (i.e., not snake_case when converted to string, or not camelCase when converted from string), the conversion will fail.
+#include <google/protobuf/util/field_mask_util.h>
namespace google::protobuf::util
Defines utilities for the FieldMask well known type.
Classes in this file | |
|---|---|
#include <google/protobuf/util/field_mask_util.h>
namespace google::protobuf::util
Members | |
|---|---|
static std::string | ToString(const FieldMask & mask)Converts FieldMask to/from string, formatted by separating each path with a comma (e.g., "foo_bar,baz.quz"). |
static void | FromString(StringPiece str, FieldMask * out) |
template static void | FromFieldNumbers(const std::vector< int64_t > & field_numbers, FieldMask * out)Populates the FieldMask with the paths corresponding to the fields with the given numbers, after checking that all field numbers are valid. |
static bool | ToJsonString(const FieldMask & mask, std::string * out)Converts FieldMask to/from string, formatted according to proto3 JSON spec for FieldMask (e.g., "fooBar,baz.quz"). more... |
static bool | FromJsonString(StringPiece str, FieldMask * out) |
static bool | GetFieldDescriptors(const Descriptor * descriptor, StringPiece path, std::vector< const FieldDescriptor * > * field_descriptors)Get the descriptors of the fields which the given path from the message descriptor traverses, if field_descriptors is not null. more... |
template static bool | IsValidPath(StringPiece path)Checks whether the given path is valid for type T. |
template static bool | IsValidFieldMask(const FieldMask & mask)Checks whether the given FieldMask is valid for type T. |
template static void | AddPathToFieldMask(StringPiece path, FieldMask * mask)Adds a path to FieldMask after checking whether the given path is valid. more... |
template static FieldMask | GetFieldMaskForAllFields()Creates a FieldMask with all fields of type T. more... |
template static void | GetFieldMaskForAllFields(FieldMask * out) |
static void | GetFieldMaskForAllFields(const Descriptor * descriptor, FieldMask * out)This flavor takes the Protobuf type descriptor as an argument. more... |
static void | ToCanonicalForm(const FieldMask & mask, FieldMask * out)Converts a FieldMask to the canonical form. more... |
static void | Union(const FieldMask & mask1, const FieldMask & mask2, FieldMask * out)Creates an union of two FieldMasks. |
static void | Intersect(const FieldMask & mask1, const FieldMask & mask2, FieldMask * out)Creates an intersection of two FieldMasks. |
template static void | Subtract(const FieldMask & mask1, const FieldMask & mask2, FieldMask * out)Subtracts mask2 from mask1 base of type T. |
static void | Subtract(const Descriptor * descriptor, const FieldMask & mask1, const FieldMask & mask2, FieldMask * out)This flavor takes the Protobuf type descriptor as an argument. more... |
static bool | IsPathInFieldMask(StringPiece path, const FieldMask & mask)Returns true if path is covered by the given FieldMask. more... |
static void | MergeMessageTo(const Message & source, const FieldMask & mask, const MergeOptions & options, Message * destination)Merges fields specified in a FieldMask into another message. |
static bool | TrimMessage(const FieldMask & mask, Message * message)Removes from 'message' any field that is not represented in the given FieldMask. more... |
static bool | TrimMessage(const FieldMask & mask, Message * message, const TrimOptions & options)Removes from 'message' any field that is not represented in the given FieldMask with customized TrimOptions. more... |
static bool FieldMaskUtil::ToJsonString(
const FieldMask & mask,
std::string * out)Converts FieldMask to/from string, formatted according to proto3 JSON spec for FieldMask (e.g., "fooBar,baz.quz").
If the field name is not style conforming (i.e., not snake_case when converted to string, or not camelCase when converted from string), the conversion will fail.
static bool FieldMaskUtil::GetFieldDescriptors(
const Descriptor * descriptor,
StringPiece path,
std::vector< const FieldDescriptor * > * field_descriptors)Get the descriptors of the fields which the given path from the message descriptor traverses, if field_descriptors is not null.
Return false if the path is not valid, and the content of field_descriptors is unspecified.
template static void FieldMaskUtil::AddPathToFieldMask(
StringPiece path,
FieldMask * mask)Adds a path to FieldMask after checking whether the given path is valid.
This method check-fails if the path is not a valid path for type T.
template static FieldMask FieldMaskUtil::GetFieldMaskForAllFields()Creates a FieldMask with all fields of type T.
This FieldMask only contains fields of T but not any sub-message fields.
-static void FieldMaskUtil::GetFieldMaskForAllFields(
const Descriptor * descriptor,
FieldMask * out)This flavor takes the protobuf type descriptor as an argument.
Useful when the type is not known at compile time.
+static void FieldMaskUtil::GetFieldMaskForAllFields(
const Descriptor * descriptor,
FieldMask * out)This flavor takes the Protobuf type descriptor as an argument.
Useful when the type is not known at compile time.
static void FieldMaskUtil::ToCanonicalForm(
const FieldMask & mask,
FieldMask * out)Converts a FieldMask to the canonical form.
It will:
1. Remove paths that are covered by another path. For example,
@@ -18,7 +18,7 @@ type = "docs"
is also in the FieldMask.
2. Sort all paths in alphabetical order.
-static void FieldMaskUtil::Subtract(
const Descriptor * descriptor,
const FieldMask & mask1,
const FieldMask & mask2,
FieldMask * out)This flavor takes the protobuf type descriptor as an argument.
Useful when the type is not known at compile time.
+static void FieldMaskUtil::Subtract(
const Descriptor * descriptor,
const FieldMask & mask1,
const FieldMask & mask2,
FieldMask * out)This flavor takes the Protobuf type descriptor as an argument.
Useful when the type is not known at compile time.
static bool FieldMaskUtil::IsPathInFieldMask(
StringPiece path,
const FieldMask & mask)Returns true if path is covered by the given FieldMask.
Note that path "foo.bar" covers all paths like "foo.bar.baz", "foo.bar.quz.x", etc. Also note that parent paths are not covered by explicit child path, i.e. "foo.bar" does NOT cover "foo", even if "bar" is the only child.
static bool FieldMaskUtil::TrimMessage(
const FieldMask & mask,
Message * message)Removes from 'message' any field that is not represented in the given FieldMask.
If the FieldMask is empty, does nothing. Returns true if the message is modified.
static bool FieldMaskUtil::TrimMessage(
const FieldMask & mask,
Message * message,
const TrimOptions & options)Removes from 'message' any field that is not represented in the given FieldMask with customized TrimOptions.
If the FieldMask is empty, does nothing. Returns true if the message is modified.
diff --git a/content/reference/cpp/api-docs/google.protobuf.util.json_util.md b/content/reference/cpp/api-docs/google.protobuf.util.json_util.md index 2e16994af..6e263658f 100644 --- a/content/reference/cpp/api-docs/google.protobuf.util.json_util.md +++ b/content/reference/cpp/api-docs/google.protobuf.util.json_util.md @@ -2,20 +2,20 @@ title = "json_util.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ -#include <google/protobuf/util/json_util.h>
namespace google::protobuf::util
Utility functions to convert between protobuf binary format and proto3 JSON format.
Classes in this file | |
|---|---|
File MembersThese definitions are not part of any class. | |
|---|---|
typedef | JsonPrintOptions JsonOptionsDEPRECATED. Use JsonPrintOptions instead. |
util::Status | MessageToJsonString(const Message & message, std::string * output, const JsonOptions & options)Converts from protobuf message to JSON and appends it to |output|. more... |
util::Status | MessageToJsonString(const Message & message, std::string * output) |
util::Status | JsonStringToMessage(StringPiece input, Message * message, const JsonParseOptions & options)Converts from JSON to protobuf message. more... |
util::Status | JsonStringToMessage(StringPiece input, Message * message) |
util::Status | BinaryToJsonStream(TypeResolver * resolver, const std::string & type_url, io::ZeroCopyInputStream * binary_input, io::ZeroCopyOutputStream * json_output, const JsonPrintOptions & options)Converts protobuf binary data to JSON. more... |
util::Status | BinaryToJsonStream(TypeResolver * resolver, const std::string & type_url, io::ZeroCopyInputStream * binary_input, io::ZeroCopyOutputStream * json_output) |
util::Status | BinaryToJsonString(TypeResolver * resolver, const std::string & type_url, const std::string & binary_input, std::string * json_output, const JsonPrintOptions & options) |
util::Status | BinaryToJsonString(TypeResolver * resolver, const std::string & type_url, const std::string & binary_input, std::string * json_output) |
util::Status | JsonToBinaryStream(TypeResolver * resolver, const std::string & type_url, io::ZeroCopyInputStream * json_input, io::ZeroCopyOutputStream * binary_output, const JsonParseOptions & options)Converts JSON data to protobuf binary format. more... |
util::Status | JsonToBinaryStream(TypeResolver * resolver, const std::string & type_url, io::ZeroCopyInputStream * json_input, io::ZeroCopyOutputStream * binary_output) |
util::Status | JsonToBinaryString(TypeResolver * resolver, const std::string & type_url, StringPiece json_input, std::string * binary_output, const JsonParseOptions & options) |
util::Status | JsonToBinaryString(TypeResolver * resolver, const std::string & type_url, StringPiece json_input, std::string * binary_output) |
util::Status util::MessageToJsonString(
const Message & message,
std::string * output,
const JsonOptions & options)Converts from protobuf message to JSON and appends it to |output|.
This is a simple wrapper of BinaryToJsonString(). It will use the DescriptorPool of the passed-in message to resolve Any types.
-util::Status util::JsonStringToMessage(
StringPiece input,
Message * message,
const JsonParseOptions & options)Converts from JSON to protobuf message.
This is a simple wrapper of JsonStringToBinary(). It will use the DescriptorPool of the passed-in message to resolve Any types.
-util::Status util::BinaryToJsonStream(
TypeResolver * resolver,
const std::string & type_url,
io::ZeroCopyInputStream * binary_input,
io::ZeroCopyOutputStream * json_output,
const JsonPrintOptions & options)Converts protobuf binary data to JSON.
The conversion will fail if:
+#include <google/protobuf/util/json_util.h>
namespace google::protobuf::util
Utility functions to convert between Protobuf binary format and proto3 JSON format.
Classes in this file | |
|---|---|
File MembersThese definitions are not part of any class. | |
|---|---|
typedef | JsonPrintOptions JsonOptionsDEPRECATED. Use JsonPrintOptions instead. |
util::Status | MessageToJsonString(const Message & message, std::string * output, const JsonOptions & options)Converts from Protobuf message to JSON and appends it to |output|. more... |
util::Status | MessageToJsonString(const Message & message, std::string * output) |
util::Status | JsonStringToMessage(StringPiece input, Message * message, const JsonParseOptions & options)Converts from JSON to Protobuf message. more... |
util::Status | JsonStringToMessage(StringPiece input, Message * message) |
util::Status | BinaryToJsonStream(TypeResolver * resolver, const std::string & type_url, io::ZeroCopyInputStream * binary_input, io::ZeroCopyOutputStream * json_output, const JsonPrintOptions & options)Converts Protobuf binary data to JSON. more... |
util::Status | BinaryToJsonStream(TypeResolver * resolver, const std::string & type_url, io::ZeroCopyInputStream * binary_input, io::ZeroCopyOutputStream * json_output) |
util::Status | BinaryToJsonString(TypeResolver * resolver, const std::string & type_url, const std::string & binary_input, std::string * json_output, const JsonPrintOptions & options) |
util::Status | BinaryToJsonString(TypeResolver * resolver, const std::string & type_url, const std::string & binary_input, std::string * json_output) |
util::Status | JsonToBinaryStream(TypeResolver * resolver, const std::string & type_url, io::ZeroCopyInputStream * json_input, io::ZeroCopyOutputStream * binary_output, const JsonParseOptions & options)Converts JSON data to Protobuf binary format. more... |
util::Status | JsonToBinaryStream(TypeResolver * resolver, const std::string & type_url, io::ZeroCopyInputStream * json_input, io::ZeroCopyOutputStream * binary_output) |
util::Status | JsonToBinaryString(TypeResolver * resolver, const std::string & type_url, StringPiece json_input, std::string * binary_output, const JsonParseOptions & options) |
util::Status | JsonToBinaryString(TypeResolver * resolver, const std::string & type_url, StringPiece json_input, std::string * binary_output) |
util::Status util::MessageToJsonString(
const Message & message,
std::string * output,
const JsonOptions & options)Converts from Protobuf message to JSON and appends it to |output|.
This is a simple wrapper of BinaryToJsonString(). It will use the DescriptorPool of the passed-in message to resolve Any types.
+util::Status util::JsonStringToMessage(
StringPiece input,
Message * message,
const JsonParseOptions & options)Converts from JSON to Protobuf message.
This is a simple wrapper of JsonStringToBinary(). It will use the DescriptorPool of the passed-in message to resolve Any types.
+util::Status util::BinaryToJsonStream(
TypeResolver * resolver,
const std::string & type_url,
io::ZeroCopyInputStream * binary_input,
io::ZeroCopyOutputStream * json_output,
const JsonPrintOptions & options)Converts Protobuf binary data to JSON.
The conversion will fail if:
1. TypeResolver fails to resolve a type.
-2. input is not valid protobuf wire format, or conflicts with the type
+2. input is not valid Protobuf wire format, or conflicts with the type
information returned by TypeResolver.
Note that unknown fields will be discarded silently.
-util::Status util::JsonToBinaryStream(
TypeResolver * resolver,
const std::string & type_url,
io::ZeroCopyInputStream * json_input,
io::ZeroCopyOutputStream * binary_output,
const JsonParseOptions & options)Converts JSON data to protobuf binary format.
The conversion will fail if:
+util::Status util::JsonToBinaryStream(
TypeResolver * resolver,
const std::string & type_url,
io::ZeroCopyInputStream * json_input,
io::ZeroCopyOutputStream * binary_output,
const JsonParseOptions & options)Converts JSON data to Protobuf binary format.
The conversion will fail if:
1. TypeResolver fails to resolve a type. 2. input is not valid JSON format, or conflicts with the type diff --git a/content/reference/cpp/api-docs/google.protobuf.util.message_differencer.md b/content/reference/cpp/api-docs/google.protobuf.util.message_differencer.md index baaa1a7d1..37a80619f 100644 --- a/content/reference/cpp/api-docs/google.protobuf.util.message_differencer.md +++ b/content/reference/cpp/api-docs/google.protobuf.util.message_differencer.md @@ -4,7 +4,7 @@ title = "message_differencer.h" toc_hide = "true" linkTitle = "C++" -description = "This section contains reference documentation for working with protocol buffer classes in C++." +description = "This section contains reference documentation for working with Protobuf classes in C++." type = "docs" +++ @@ -21,7 +21,7 @@ type = "docs"Note on handling of google.protobuf.Any: MessageDifferencer automatically unpacks Any::value into a Message and compares its individual fields. Messages encoded in a repeated Any cannot be compared using TreatAsMap.
Note on thread-safety: MessageDifferencer is not thread-safe. You need to guard it with a lock to use the same MessageDifferencer instance from multiple threads. Note that it's fine to call static comparison methods (like MessageDifferencer::Equals) concurrently, but it's not recommended for performance critical code as it leads to extra allocations.
-
Members | |
|---|---|
enum | MessageFieldComparison |
enum | Scope |
enum | FloatComparisonDEPRECATED. Use FieldComparator::FloatComparison instead. more... |
enum | RepeatedFieldComparison |
DefaultFieldComparator * | default_impl |
FieldComparator * | base |
static bool | Determines whether the supplied messages are equal. more... |
static bool | Determines whether the supplied messages are equivalent. more... |
static bool | Determines whether the supplied messages are approximately equal. more... |
static bool | Determines whether the supplied messages are approximately equivalent. more... |
explicit | MessageDifferencer()To add a Reporter, construct default here, then use ReportDifferencesTo or ReportDifferencesToString. |
| ~MessageDifferencer() |
void | TreatAsSet(const FieldDescriptor * field)The elements of the given repeated field will be treated as a set for diffing purposes, so different orderings of the same elements will be considered equal. more... |
void | TreatAsSmartSet(const FieldDescriptor * field) |
void | TreatAsList(const FieldDescriptor * field)The elements of the given repeated field will be treated as a list for diffing purposes, so different orderings of the same elements will NOT be considered equal. more... |
void | TreatAsSmartList(const FieldDescriptor * field)Note that the complexity is similar to treating as SET. |
void | TreatAsMap(const FieldDescriptor * field, const FieldDescriptor * key)The elements of the given repeated field will be treated as a map for diffing purposes, with |key| being the map key. more... |
void | TreatAsMapWithMultipleFieldsAsKey(const FieldDescriptor * field, const std::vector< const FieldDescriptor * > & key_fields)Same as TreatAsMap except that this method will use multiple fields as the key in comparison. more... |
void | TreatAsMapWithMultipleFieldPathsAsKey(const FieldDescriptor * field, const std::vector< std::vector< const FieldDescriptor * > > & key_field_paths)Same as TreatAsMapWithMultipleFieldsAsKey, except that each of the field do not necessarily need to be a direct subfield. more... |
void | TreatAsMapUsingKeyComparator(const FieldDescriptor * field, const MapKeyComparator * key_comparator)Uses a custom MapKeyComparator to determine if two elements have the same key when comparing a repeated field as a map. more... |
MapKeyComparator * | CreateMultipleFieldsMapKeyComparator(const std::vector< std::vector< const FieldDescriptor * > > & key_field_paths)Initiates and returns a new instance of MultipleFieldsMapKeyComparator. |
void | AddIgnoreCriteria(IgnoreCriteria * ignore_criteria)Add a custom ignore criteria that is evaluated in addition to the ignored fields added with IgnoreField. more... |
void | IgnoreField(const FieldDescriptor * field)Indicates that any field with the given descriptor should be ignored for the purposes of comparing two messages. more... |
void | set_field_comparator(FieldComparator * comparator)Sets the field comparator used to determine differences between protocol buffer fields. more... |
void | SetFractionAndMargin(const FieldDescriptor * field, double fraction, double margin)DEPRECATED. more... |
void | set_message_field_comparison(MessageFieldComparison comparison)Sets the type of comparison (as defined in the MessageFieldComparison enumeration above) that is used by this differencer when determining how to compare fields in messages. |
void | set_report_matches(bool report_matches)Tells the differencer whether or not to report matches. more... |
void | set_report_moves(bool report_moves)Tells the differencer whether or not to report moves (in a set or map repeated field). more... |
void | set_report_ignores(bool report_ignores)Tells the differencer whether or not to report ignored values. more... |
void | set_scope(Scope scope)Sets the scope of the comparison (as defined in the Scope enumeration above) that is used by this differencer when determining which fields to compare between the messages. |
Scope | scope()Returns the current scope used by this differencer. |
void | set_float_comparison(FloatComparison comparison)DEPRECATED. more... |
void | set_repeated_field_comparison(RepeatedFieldComparison comparison)Sets the type of comparison for repeated field (as defined in the RepeatedFieldComparison enumeration above) that is used by this differencer when compare repeated fields in messages. |
RepeatedFieldComparison | repeated_field_comparison()Returns the current repeated field comparison used by this differencer. |
bool | Compares the two specified messages, returning true if they are the same, false otherwise. more... |
bool | CompareWithFields(const Message & message1, const Message & message2, const std::vector< const FieldDescriptor * > & message1_fields, const std::vector< const FieldDescriptor * > & message2_fields)Same as above, except comparing only the list of fields specified by the two vectors of FieldDescriptors. |
void | ReportDifferencesToString(std::string * output)Automatically creates a reporter that will output the differences found (if any) to the specified output string pointer. more... |
void | ReportDifferencesTo(Reporter * reporter)Tells the MessageDifferencer to report differences via the specified reporter. more... |
enum MessageDifferencer::MessageFieldComparison {
EQUAL,
EQUIVALENT
}| EQUAL | Fields must be present in both messages for the messages to be considered the same. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EQUIVALENT | Fields with default values are considered set for comparison purposes even if not explicitly set in the messages themselves. Unknown fields are ignored. +
EQUAL, EQUIVALENT } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EQUAL | Fields must be present in both messages for the messages to be considered the same. |
| EQUIVALENT | Fields with default values are considered set for comparison purposes even if not explicitly set in the messages themselves. Unknown fields are ignored. |
enum MessageDifferencer::Scope {
FULL,
PARTIAL
}| FULL | All fields of both messages are considered in the comparison. |
| PARTIAL | Only fields present in the first message are considered; fields set only in the second message will be skipped during comparison. |
enum MessageDifferencer::FloatComparison {
EXACT,
APPROXIMATE
}DEPRECATED. Use FieldComparator::FloatComparison instead.
| EXACT | Floats and doubles are compared exactly. |
| APPROXIMATE | Floats and doubles are compared using the MathUtil::AlmostEquals method. |
enum MessageDifferencer::RepeatedFieldComparison {
AS_LIST,
AS_SET,
AS_SMART_LIST,
AS_SMART_SET
}| AS_LIST | Repeated fields are compared in order. Differing values at the same index are reported using ReportModified(). If the repeated fields have different numbers of elements, the unpaired elements are reported using ReportAdded() or ReportDeleted(). | |||||||||||
| AS_SET | Treat all the repeated fields as sets. See TreatAsSet(), as below. | |||||||||||
| AS_SMART_LIST | Similar to AS_SET, but preserve the order and find the longest matching sequence from the first matching element. To use an optimal solution, call SetMatchIndicesForSmartListCallback() to pass it in. @@ -58,7 +58,7 @@ type = "docs"
IgnoreCriteria * ignore_criteria) |
| - Source context for the protocol buffer service represented by this + Source context for the Protobuf service represented by this message. | @@ -417,7 +417,7 @@ Enum type definition
Option
|
- Protocol buffer options. | +Protobuf options. |
source_context |
@@ -470,7 +470,7 @@ Enum value definition.
Option
|
- Protocol buffer options. | +Protobuf options. |
Option
json_namestring |
The path-qualified name of the .proto file that contained the associated
- protobuf element. For example:
+ Protobuf element. For example:
"google/protobuf/source.proto".
|
@@ -1219,7 +1218,7 @@ The JSON representation for `Struct` is JSON object.
## Syntax {#syntax}
-The syntax in which a protocol buffer element is defined.
+The syntax in which a Protobuf element is defined.
Option
|
- The protocol buffer options. | +The Protobuf options. |
source_context |
diff --git a/content/reference/protobuf/mime-types.md b/content/reference/protobuf/mime-types.md
index b290d4a19..2652ad7dd 100644
--- a/content/reference/protobuf/mime-types.md
+++ b/content/reference/protobuf/mime-types.md
@@ -1,5 +1,5 @@
+++
-title = "Protocol Buffer MIME Types"
+title = "Protobuf MIME Types"
weight = 830
linkTitle = "MIME Types"
description = "Standard MIME types for Protobuf Serializations."
@@ -30,7 +30,7 @@ followed by the following parameters:
- Protobuf reserves the `version` parameter for potential future versioning of
our wire formats. Do not set it until a wire format is versioned.
-So the standard MIME types for common protobuf encodings are:
+So the standard MIME types for common Protobuf encodings are:
- `application/protobuf` for serialized binary protos.
- `application/protobuf+json; charset=utf-8` for JSON format protos.
@@ -43,7 +43,7 @@ unknown or illegal values.
When binary protos are transacted over HTTP, Protobuf strongly recommends
Base64-encoding them and setting `X-Content-Type-Options: nosniff` to prevent
-XSS, as it is possible for a Protobuf to parse as active content.
+XSS, as it is possible for a proto to parse as active content.
It is acceptable to pass additional parameters to these MIME types if desired,
such as a type URL which indicates the content schema; but the MIME type
diff --git a/content/reference/protobuf/proto2-spec.md b/content/reference/protobuf/proto2-spec.md
index 7037ab7dc..a48212248 100644
--- a/content/reference/protobuf/proto2-spec.md
+++ b/content/reference/protobuf/proto2-spec.md
@@ -1,5 +1,5 @@
+++
-title = "Protocol Buffers Language Specification (Proto2 Syntax)"
+title = "Protobuf Language Specification (Proto2 Syntax)"
weight = 800
linkTitle = "Language Specification (Proto2 Syntax)"
description = "Language specification reference for the proto2 syntax and its relationship to Protobuf Editions."
@@ -110,7 +110,7 @@ constant = fullIdent | ( [ "-" | "+" ] intLit ) | ( [ "-" | "+" ] floatLit ) |
## Syntax
-The syntax statement is used to define the protobuf version. If `syntax` is
+The syntax statement is used to define the Protobuf version. If `syntax` is
omitted, the protocol compiler will use `proto2`. For the sake of clarity, it's
recommended to always explicitly include a `syntax` statement in your `.proto`
files.
@@ -151,7 +151,7 @@ package foo.bar;
## Option
Options can be used in proto files, messages, enums and services. An option can
-be a protobuf defined option or a custom option. For more information, see
+be a Protobuf defined option or a custom option. For more information, see
[Options](/programming-guides/proto2#options) in the
language guide.
@@ -169,7 +169,7 @@ option java_package = "com.example.foo";
## Fields
-Fields are the basic elements of a protocol buffer message. Fields can be normal
+Fields are the basic elements of a Protobuf message. Fields can be normal
fields, group fields, oneof fields, or map fields. A field has a type, name, and
field number. In proto2, fields also have a label (`required`, `optional`, or
`repeated`).
diff --git a/content/reference/protobuf/proto3-spec.md b/content/reference/protobuf/proto3-spec.md
index c025a934d..9ff637993 100644
--- a/content/reference/protobuf/proto3-spec.md
+++ b/content/reference/protobuf/proto3-spec.md
@@ -1,8 +1,8 @@
+++
-title = "Protocol Buffers Language Specification (Proto3)"
+title = "Protobuf Language Specification (Proto3)"
weight = 810
linkTitle = "Language Specification (Proto3)"
-description = "Language specification reference for the Protocol Buffers language (Proto3)."
+description = "Language specification reference for the Protobuf language (Proto3)."
type = "docs"
+++
@@ -107,7 +107,7 @@ constant = fullIdent | ( [ "-" | "+" ] intLit ) | ( [ "-" | "+" ] floatLit ) |
## Syntax
-The syntax statement is used to define the protobuf version.
+The syntax statement is used to define the Protobuf version.
```
syntax = "syntax" "=" ("'" "proto3" "'" | '"' "proto3" '"') ";"
@@ -151,7 +151,7 @@ package foo.bar;
## Option
Options can be used in proto files, messages, enums and services. An option can
-be a protobuf defined option or a custom option. For more information, see
+be a Protobuf defined option or a custom option. For more information, see
[Options](/programming-guides/proto3#options) in the
language guide.
@@ -170,7 +170,7 @@ option java_package = "com.example.foo";
## Fields
-Fields are the basic elements of a protocol buffer message. Fields can be normal
+Fields are the basic elements of a Protobuf message. Fields can be normal
fields, oneof fields, or map fields. A field has a type and field number.
```
diff --git a/content/reference/protobuf/textformat-spec.md b/content/reference/protobuf/textformat-spec.md
index dbb997bee..e64bba667 100644
--- a/content/reference/protobuf/textformat-spec.md
+++ b/content/reference/protobuf/textformat-spec.md
@@ -1,7 +1,7 @@
+++
title = "Text Format Language Specification"
weight = 820
-description = "The protocol buffer Text Format Language specifies a syntax for representation of protobuf data in text form, which is often useful for configurations or tests."
+description = "The Protobuf Text Format Language specifies a syntax for representation of Protobuf data in text form, which is often useful for configurations or tests."
type = "docs"
+++
@@ -517,7 +517,7 @@ integer = signedInteger | unsignedInteger ;
-0x80000000 to 0x7FFFFFFF containing an enum
value number. It is not valid to specify a name that is not a
member of the field's