diff --git a/content/reference/cpp/api-docs/_index.md b/content/reference/cpp/api-docs/_index.md index 4fa25461..9a2cea60 100644 --- a/content/reference/cpp/api-docs/_index.md +++ b/content/reference/cpp/api-docs/_index.md @@ -8,11 +8,11 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

Packages

google::protobuf
google::protobuf::io
Auxiliary classes used for I/O.
google::protobuf::util
Utility classes.
google::protobuf::compiler
Implementation of the Protobuf compiler.

google::protobuf

Files

google/protobuf/arena.h
This file defines an Arena allocator for better allocation performance.
google/protobuf/descriptor.h
This file contains classes which describe a type of protocol message.
google/protobuf/descriptor.pb.h
Protobuf representations of descriptors.
google/protobuf/descriptor_database.h
Interface for manipulating databases of descriptors.
google/protobuf/dynamic_message.h
Defines an implementation of Message which can emulate types which are not known at compile-time.
google/protobuf/map.h
This file defines the map container and its helpers to support Protobuf maps.
google/protobuf/message.h
Defines Message, the abstract interface implemented by non-lite protocol message objects.
google/protobuf/message_lite.h
Defines MessageLite, the abstract interface implemented by all (lite and non-lite) protocol message objects.
google/protobuf/repeated_field.h
RepeatedField and RepeatedPtrField are used by generated protocol message classes to manipulate repeated fields.
google/protobuf/service.h
DEPRECATED: This module declares the abstract interfaces underlying proto2 RPC services.
google/protobuf/text_format.h
Utilities for printing and parsing protocol messages in a human-readable, text-based format.
google/protobuf/unknown_field_set.h
Contains classes used to keep track of unrecognized fields seen while parsing a protocol message.

google::protobuf::io

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

google/protobuf/io/coded_stream.h
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.
google/protobuf/io/printer.h
Utility class for writing text to a ZeroCopyOutputStream.
google/protobuf/io/tokenizer.h
Class for parsing tokenized text from a ZeroCopyInputStream.
google/protobuf/io/zero_copy_stream.h
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.
google/protobuf/io/zero_copy_stream_impl.h
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.
google/protobuf/io/zero_copy_stream_impl_lite.h
This file contains common implementations of the interfaces defined in zero_copy_stream.h which are included in the "lite" Protobuf library.

google::protobuf::util

Utility classes.

This package contains various utilities for message comparison, JSON conversion, well known types, etc.

-

Files

google/protobuf/util/field_comparator.h
Defines classes for field comparison.
google/protobuf/util/field_mask_util.h
Defines utilities for the FieldMask well known type.
google/protobuf/util/json_util.h
Utility functions to convert between Protobuf binary format and proto3 JSON format.
google/protobuf/util/message_differencer.h
This file defines static methods and classes for comparing Protocol Messages.
google/protobuf/util/time_util.h
Defines utilities for the Timestamp and Duration well known types.
google/protobuf/util/type_resolver.h
Defines a TypeResolver for the Any message.
google/protobuf/util/type_resolver_util.h
Defines utilities for the TypeResolver.

google::protobuf::compiler

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:

+

Packages

google::protobuf
google::protobuf::io
Auxiliary classes used for I/O.
google::protobuf::util
Utility classes.
google::protobuf::compiler
Implementation of the Protobuf compiler.

google::protobuf

Files

google/protobuf/arena.h
This file defines an Arena allocator for better allocation performance.
google/protobuf/descriptor.h
This file contains classes which describe a type of protocol message.
google/protobuf/descriptor.pb.h
Protobuf representations of descriptors.
google/protobuf/descriptor_database.h
Interface for manipulating databases of descriptors.
google/protobuf/dynamic_message.h
Defines an implementation of Message which can emulate types which are not known at compile-time.
google/protobuf/map.h
This file defines the map container and its helpers to support Protobuf maps.
google/protobuf/message.h
Defines Message, the abstract interface implemented by non-lite protocol message objects.
google/protobuf/message_lite.h
Defines MessageLite, the abstract interface implemented by all (lite and non-lite) protocol message objects.
google/protobuf/repeated_field.h
RepeatedField and RepeatedPtrField are used by generated protocol message classes to manipulate repeated fields.
google/protobuf/service.h
DEPRECATED: This module declares the abstract interfaces underlying proto2 RPC services.
google/protobuf/text_format.h
Utilities for printing and parsing protocol messages in a human-readable, text-based format.
google/protobuf/unknown_field_set.h
Contains classes used to keep track of unrecognized fields seen while parsing a protocol message.

google::protobuf::io

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

google/protobuf/io/coded_stream.h
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.
google/protobuf/io/printer.h
Utility class for writing text to a ZeroCopyOutputStream.
google/protobuf/io/tokenizer.h
Class for parsing tokenized text from a ZeroCopyInputStream.
google/protobuf/io/zero_copy_stream.h
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.
google/protobuf/io/zero_copy_stream_impl.h
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.
google/protobuf/io/zero_copy_stream_impl_lite.h
This file contains common implementations of the interfaces defined in zero_copy_stream.h which are included in the "lite" Protobuf library.

google::protobuf::util

Utility classes.

This package contains various utilities for message comparison, JSON conversion, well known types, etc.

+

Files

google/protobuf/util/field_comparator.h
Defines classes for field comparison.
google/protobuf/util/field_mask_util.h
Defines utilities for the FieldMask well known type.
google/protobuf/util/json_util.h
Utility functions to convert between Protobuf binary format and proto3 JSON format.
google/protobuf/util/message_differencer.h
This file defines static methods and classes for comparing Protocol Messages.
google/protobuf/util/time_util.h
Defines utilities for the Timestamp and Duration well known types.
google/protobuf/util/type_resolver.h
Defines a TypeResolver for the Any message.
google/protobuf/util/type_resolver_util.h
Defines utilities for the TypeResolver.

google::protobuf::compiler

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:

-

Files

google/protobuf/compiler/code_generator.h
Defines the abstract interface implemented by each of the language-specific code generators.
google/protobuf/compiler/command_line_interface.h
Implements the Protocol Compiler front-end such that it may be reused by custom compilers written to support other languages.
google/protobuf/compiler/importer.h
This file is the public interface to the .proto file parser.
google/protobuf/compiler/parser.h
Implements parsing of .proto files to FileDescriptorProtos.
google/protobuf/compiler/plugin.h
Front-end for protoc code generator plugins written in C++.
google/protobuf/compiler/plugin.pb.h
API for protoc plugins.
google/protobuf/compiler/cpp/cpp_generator.h
Generates C++ code for a given .proto file.
google/protobuf/compiler/csharp/csharp_generator.h
Generates C# code for a given .proto file.
google/protobuf/compiler/csharp/csharp_names.h
Provides a mechanism for mapping a descriptor to the fully-qualified name of the corresponding C# class.
google/protobuf/compiler/java/java_generator.h
Generates Java code for a given .proto file.
google/protobuf/compiler/java/java_names.h
Provides a mechanism for mapping a descriptor to the fully-qualified name of the corresponding Java class.
google/protobuf/compiler/js/js_generator.h
Generates JavaScript code for a given .proto file.
google/protobuf/compiler/objectivec/objectivec_generator.h
Generates ObjectiveC code for a given .proto file.
google/protobuf/compiler/objectivec/objectivec_helpers.h
Helper functions for generating ObjectiveC code.
google/protobuf/compiler/python/python_generator.h
Generates Python code for a given .proto file.
google/protobuf/compiler/ruby/ruby_generator.h
Generates Ruby code for a given .proto file.
+

Files

google/protobuf/compiler/code_generator.h
Defines the abstract interface implemented by each of the language-specific code generators.
google/protobuf/compiler/command_line_interface.h
Implements the Protocol Compiler front-end such that it may be reused by custom compilers written to support other languages.
google/protobuf/compiler/importer.h
This file is the public interface to the .proto file parser.
google/protobuf/compiler/parser.h
Implements parsing of .proto files to FileDescriptorProtos.
google/protobuf/compiler/plugin.h
Front-end for protoc code generator plugins written in C++.
google/protobuf/compiler/plugin.pb.h
API for protoc plugins.
google/protobuf/compiler/cpp/cpp_generator.h
Generates C++ code for a given .proto file.
google/protobuf/compiler/csharp/csharp_generator.h
Generates C# code for a given .proto file.
google/protobuf/compiler/csharp/csharp_names.h
Provides a mechanism for mapping a descriptor to the fully-qualified name of the corresponding C# class.
google/protobuf/compiler/java/java_generator.h
Generates Java code for a given .proto file.
google/protobuf/compiler/java/java_names.h
Provides a mechanism for mapping a descriptor to the fully-qualified name of the corresponding Java class.
google/protobuf/compiler/js/js_generator.h
Generates JavaScript code for a given .proto file.
google/protobuf/compiler/objectivec/objectivec_generator.h
Generates ObjectiveC code for a given .proto file.
google/protobuf/compiler/objectivec/objectivec_helpers.h
Helper functions for generating ObjectiveC code.
google/protobuf/compiler/python/python_generator.h
Generates Python code for a given .proto file.
google/protobuf/compiler/ruby/ruby_generator.h
Generates Ruby code for a given .proto file.
diff --git a/content/reference/cpp/api-docs/google.protobuf.arena.md b/content/reference/cpp/api-docs/google.protobuf.arena.md index bd09ff28..91fa75b2 100644 --- a/content/reference/cpp/api-docs/google.protobuf.arena.md +++ b/content/reference/cpp/api-docs/google.protobuf.arena.md @@ -8,14 +8,14 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

#include <google/protobuf/arena.h>
namespace google::protobuf

This file defines an Arena allocator for better allocation performance.

Classes in this file

ArenaOptions
ArenaOptions provides optional additional parameters to arena construction that control its block-allocation behavior.
Arena
Arena allocator.
Arena::InternalHelper
Arena::is_arena_constructable
Helper typetraits that indicates support for arenas in a type T at compile time.
Arena::is_destructor_skippable

struct ArenaOptions

#include <google/protobuf/arena.h>
namespace google::protobuf

ArenaOptions provides optional additional parameters to arena construction that control its block-allocation behavior.

Members

size_t
start_block_size
This defines the size of the first block requested from the system malloc. more...
size_t
max_block_size
This defines the maximum block size requested from system malloc (unless an individual arena allocation request occurs with a size larger than this maximum). more...
char *
initial_block
An initial block of memory for the arena to use, or NULL for none. more...
size_t
initial_block_size
The size of the initial block, if provided.
void *(*
block_alloc
A function pointer to an alloc method that returns memory blocks of size requested. more...
void(*
block_dealloc
A function pointer to a dealloc method that takes ownership of the blocks from the arena. more...
ArenaOptions()

size_t ArenaOptions::start_block_size

This defines the size of the first block requested from the system malloc.

Subsequent block sizes will increase in a geometric series up to a maximum.

+

#include <google/protobuf/arena.h>
namespace google::protobuf

This file defines an Arena allocator for better allocation performance.

Classes in this file

ArenaOptions provides optional additional parameters to arena construction that control its block-allocation behavior.
Arena allocator.
Helper typetraits that indicates support for arenas in a type T at compile time.

struct ArenaOptions

#include <google/protobuf/arena.h>
namespace google::protobuf

ArenaOptions provides optional additional parameters to arena construction that control its block-allocation behavior.

Members

size_t
start_block_size
This defines the size of the first block requested from the system malloc. more...
size_t
max_block_size
This defines the maximum block size requested from system malloc (unless an individual arena allocation request occurs with a size larger than this maximum). more...
char *
initial_block
An initial block of memory for the arena to use, or NULL for none. more...
size_t
initial_block_size
The size of the initial block, if provided.
void *(*
block_alloc
A function pointer to an alloc method that returns memory blocks of size requested. more...
void(*
block_dealloc
A function pointer to a dealloc method that takes ownership of the blocks from the arena. more...
ArenaOptions()

size_t ArenaOptions::start_block_size

This defines the size of the first block requested from the system malloc.

Subsequent block sizes will increase in a geometric series up to a maximum.


size_t ArenaOptions::max_block_size

This defines the maximum block size requested from system malloc (unless an individual arena allocation request occurs with a size larger than this maximum).

Requested block sizes increase up to this value, then remain here.


char * ArenaOptions::initial_block

An initial block of memory for the arena to use, or NULL for none.

If provided, the block must live at least as long as the arena itself. The creator of the Arena retains ownership of the block after the Arena is destroyed.


void *(* ArenaOptions::block_alloc

A function pointer to an alloc method that returns memory blocks of size requested.

By default, it contains a ptr to the malloc function.

NOTE: block_alloc and dealloc functions are expected to behave like malloc and free, including Asan poisoning.


void(* ArenaOptions::block_dealloc

A function pointer to a dealloc method that takes ownership of the blocks from the arena.

By default, it contains a ptr to a wrapper function that calls free.

-

class Arena

#include <google/protobuf/arena.h>
namespace google::protobuf

Arena allocator.

Arena allocation replaces ordinary (heap-based) allocation with new/delete, and improves performance by aggregating allocations into larger blocks and freeing allocations all at once. Protocol messages are allocated on an arena by using Arena::CreateMessage<T>(Arena*), below, and are automatically freed when the arena is destroyed.

+

class Arena

#include <google/protobuf/arena.h>
namespace google::protobuf

Arena allocator.

Arena allocation replaces ordinary (heap-based) allocation with new/delete, and improves performance by aggregating allocations into larger blocks and freeing allocations all at once. Protocol messages are allocated on an arena by using Arena::CreateMessage<T>(Arena*), below, and are automatically freed when the arena is destroyed.

This is a thread-safe implementation: multiple threads may allocate from the arena concurrently. Destruction is not thread-safe and the destructing thread must synchronize with users of the arena first.

@@ -29,7 +29,7 @@ type = "docs"
  • The type T may have the type trait |DestructorSkippable_|. If this type trait is present in the type, then its destructor will not be called if and only if it was passed a non-NULL arena pointer. If this type trait is not present on the type, then its destructor is always called when the containing arena is destroyed.
  • -

    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 + @@ -45,14 +45,14 @@ type = "docs"

    template void Arena::OwnDestructor(
            T * object)

    Adds |object| to a list of objects whose destructors will be manually called when the arena is destroyed or reset.

    This differs from Own() in that it does not free the underlying memory with |delete|; hence, it is normally only used for objects that are placement-newed into arena-allocated memory.


    void Arena::OwnCustomDestructor(
            void * object,
            void(*)(void *) destruct)

    Adds a custom member function on an object to the list of destructors that will be manually called when the arena is destroyed or reset.

    This differs from OwnDestructor() in that any member function may be specified, not only the class destructor.


    template static T * Arena::CreateMessage(
            Arena * arena,
            Args &&... args)

    API to create proto2 message objects on the arena.

    If the arena passed in is NULL, then a heap allocated object is returned. Type T must be a message defined in a .proto file with cc_enable_arenas set to true, otherwise a compilation error will occur.

    -

    RepeatedField and RepeatedPtrField may also be instantiated directly on an arena with this method.

    +

    RepeatedField and RepeatedPtrField may also be instantiated directly on an arena with this method.

    This function also accepts any type T that satisfies the arena message allocation protocol, documented above.


    template static PROTOBUF_NDEBUG_INLINE T *
        Arena::Create(
            Arena * arena,
            Args &&... args)

    API to create any objects on the arena.

    Note that only the object will be created on the arena; the underlying ptrs (in case of a proto2 message) will be still heap allocated. Proto messages should usually be allocated with CreateMessage<T>() instead.

    Note that even if T satisfies the arena message construction protocol (InternalArenaConstructable_ trait and optional DestructorSkippable_ trait), as described above, this function does not follow the protocol; instead, it treats T as a black-box type, just as if it did not have these traits. Specifically, T's constructor arguments will always be only those passed to Create<T>() – no additional arena pointer is implicitly added. Furthermore, the destructor will always be called at arena destruction time (unless the destructor is trivial). Hence, from T's point of view, it is as if the object were allocated on the heap (except that the underlying memory is obtained from the arena).


    template static PROTOBUF_NDEBUG_INLINE T *
        Arena::CreateArray(
            Arena * arena,
            size_t num_elements)

    Create an array of object type T on the arena without invoking the constructor of T.

    If arena is null, then the return value should be freed with delete[] x; (or ::operator delete[](x);). To ensure safe uses, this function checks at compile time (when compiled as C++11) that T is trivially default-constructible and trivially destructible.


    template static Arena * Arena::GetArena(
            const T * value)

    Retrieves the arena associated with |value| if |value| is an arena-capable message, or NULL otherwise.

    If possible, the call resolves at compile time. Note that we can often devirtualize calls to value->GetArena() so usually calling this method is unnecessary.

    -

    template class Arena::InternalHelper

    #include <google/protobuf/arena.h>
    namespace google::protobuf

    template <typename >

    Members

    static Arena *
    GetOwningArena(const T * p)
    Provides access to protected GetOwningArena to generated messages.
    static Arena *
    GetArenaForAllocation(const T * p)
    Provides access to protected GetArenaForAllocation to generated messages.

    template struct Arena::is_arena_constructable

    #include <google/protobuf/arena.h>
    namespace google::protobuf

    template <typename >

    Helper typetraits that indicates support for arenas in a type T at compile time.

    This is public only to allow construction of higher-level templated utilities.

    +

    template class Arena::InternalHelper

    #include <google/protobuf/arena.h>
    namespace google::protobuf

    template <typename >

    Members

    static Arena *
    GetOwningArena(const T * p)
    Provides access to protected GetOwningArena to generated messages.
    static Arena *
    GetArenaForAllocation(const T * p)
    Provides access to protected GetArenaForAllocation to generated messages.

    template struct Arena::is_arena_constructable

    #include <google/protobuf/arena.h>
    namespace google::protobuf

    template <typename >

    Helper typetraits that indicates support for arenas in a type T at compile time.

    This is public only to allow construction of higher-level templated utilities.

    is_arena_constructable<T>::value is true if the message type T has arena support enabled, and false otherwise.

    is_destructor_skippable<T>::value is true if the message type T has told the arena that it is safe to skip the destructor, and false otherwise.

    This is inside Arena because only Arena has the friend relationships necessary to see the underlying generated code traits.

    -

    Members

    template struct Arena::is_destructor_skippable

    #include <google/protobuf/arena.h>
    namespace google::protobuf

    template <typename >

    Members

    +

    Members

    template struct Arena::is_destructor_skippable

    #include <google/protobuf/arena.h>
    namespace google::protobuf

    template <typename >

    Members

    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 7ba7e550..848d7484 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 @@ -6,25 +6,25 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/code_generator.h>
    namespace google::protobuf::compiler

    Defines the abstract interface implemented by each of the language-specific code generators.

    Classes in this file

    The abstract interface to a class which generates code implementing a particular proto file in a particular language.
    CodeGenerators generate one or more files in a given directory.

    File Members

    These definitions are not part of any class.
    typedef
    GeneratorContext OutputDirectory
    The type GeneratorContext was once called OutputDirectory. more...
    void
    ParseGeneratorParameter(const std::string & , std::vector< std::pair< std::string, std::string > > * )
    Several code generators treat the parameter argument as holding a list of options separated by commas. more...
    std::string
    StripProto(const std::string & filename)
    Strips ".proto" or ".protodevel" from the end of a filename.

    typedef compiler::OutputDirectory

    The type GeneratorContext was once called OutputDirectory.

    This typedef provides backward compatibility.

    +

    #include <google/protobuf/compiler/code_generator.h>
    namespace google::protobuf::compiler

    Defines the abstract interface implemented by each of the language-specific code generators.

    Classes in this file

    The abstract interface to a class which generates code implementing a particular proto file in a particular language.
    CodeGenerators generate one or more files in a given directory.

    File Members

    These definitions are not part of any class.
    typedef
    GeneratorContext OutputDirectory
    The type GeneratorContext was once called OutputDirectory. more...
    void
    ParseGeneratorParameter(const std::string & , std::vector< std::pair< std::string, std::string > > * )
    Several code generators treat the parameter argument as holding a list of options separated by commas. more...
    std::string
    StripProto(const std::string & filename)
    Strips ".proto" or ".protodevel" from the end of a filename.

    typedef compiler::OutputDirectory

    The type GeneratorContext was once called OutputDirectory.

    This typedef provides backward compatibility.


    void compiler::ParseGeneratorParameter(
            const std::string & ,
            std::vector< std::pair< std::string, std::string > > * )

    Several code generators treat the parameter argument as holding a list of options separated by commas.

    This helper function parses a set of comma-delimited name/value pairs: e.g., "foo=bar,baz,qux=corge" parses to the pairs:

    ("foo", "bar"), ("baz", ""), ("qux", "corge")
    -

    class CodeGenerator

    #include <google/protobuf/compiler/code_generator.h>
    namespace google::protobuf::compiler

    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:

    Members

    enum
    Feature
    Sync with plugin.proto. more...
    CodeGenerator()
    virtual
    ~CodeGenerator()
    virtual bool
    Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) const = 0
    Generates 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) const
    Generates code for all given proto files. more...
    virtual uint64_t
    GetSupportedFeatures() const
    Implement this to indicate what features this code generator supports. more...
    virtual bool
    HasGenerateAll() const
    This 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 = 0

    Generates 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.

    +

    class CodeGenerator

    #include <google/protobuf/compiler/code_generator.h>
    namespace google::protobuf::compiler

    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:

    Members

    enum
    Feature
    Sync with plugin.proto. more...
    CodeGenerator()
    virtual
    ~CodeGenerator()
    virtual bool
    Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) const = 0
    Generates 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) const
    Generates code for all given proto files. more...
    virtual uint64_t
    GetSupportedFeatures() const
    Implement this to indicate what features this code generator supports. more...
    virtual bool
    HasGenerateAll() const
    This 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 = 0

    Generates 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) const

    Generates 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.

    +

    virtual bool CodeGenerator::GenerateAll(
            const std::vector< const FileDescriptor * > & files,
            const std::string & parameter,
            GeneratorContext * generator_context,
            std::string * error) const

    Generates 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() const

    Implement 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() const

    This 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.

    -

    class GeneratorContext

    #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) = 0
    Opens 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) const
    Retrieves the version number of the protocol compiler associated with this GeneratorContext.

    virtual io::ZeroCopyOutputStream *
        GeneratorContext::Open(
            const std::string & filename) = 0

    Opens 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).

    +

    class GeneratorContext

    #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) = 0
    Opens 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) const
    Retrieves the version number of the protocol compiler associated with this GeneratorContext.

    virtual io::ZeroCopyOutputStream *
        GeneratorContext::Open(
            const std::string & filename) = 0

    Opens 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.

    -

    virtual io::ZeroCopyOutputStream *
        GeneratorContext::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.

    See plugin.proto (plugin.pb.h) for more information on insertion points. The default implementation assert-fails – it exists only for backwards-compatibility.

    +

    virtual io::ZeroCopyOutputStream *
        GeneratorContext::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.

    See plugin.proto (plugin.pb.h) for more information on insertion points. The default implementation assert-fails – it exists only for backwards-compatibility.

    WARNING: This feature is currently EXPERIMENTAL and is subject to change.

    -

    virtual io::ZeroCopyOutputStream *
        GeneratorContext::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.

    The default implementation ignores info.

    +

    virtual io::ZeroCopyOutputStream *
        GeneratorContext::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.

    The default implementation ignores info.

    WARNING: This feature will be REMOVED in the near future.

    -

    virtual void GeneratorContext::ListParsedFiles(
            std::vector< const FileDescriptor * > * output)

    Returns a vector of FileDescriptors for all the files being compiled in this run.

    Useful for languages, such as Go, that treat files differently when compiled as a set rather than individually.

    +

    virtual void GeneratorContext::ListParsedFiles(
            std::vector< const FileDescriptor * > * output)

    Returns a vector of FileDescriptors for all the files being compiled in this run.

    Useful for languages, such as Go, that treat files differently when compiled as a set rather than individually.

    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 185026ec..b3be86fd 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 @@ -6,7 +6,7 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/command_line_interface.h>
    namespace google::protobuf::compiler

    Implements the Protocol Compiler front-end such that it may be reused by custom compilers written to support other languages.

    Classes in this file

    This class implements the command-line interface to the protocol compiler.

    class CommandLineInterface

    #include <google/protobuf/compiler/command_line_interface.h>
    namespace google::protobuf::compiler

    This class implements the command-line interface to the protocol compiler.

    It is designed to make it very easy to create a custom protocol compiler supporting the languages of your choice. For example, if you wanted to create a custom protocol compiler binary which includes both the regular C++ support plus support for your own custom output "Foo", you would write a class "FooGenerator" which implements the CodeGenerator interface, then write a main() procedure like this:

    +

    #include <google/protobuf/compiler/command_line_interface.h>
    namespace google::protobuf::compiler

    Implements the Protocol Compiler front-end such that it may be reused by custom compilers written to support other languages.

    Classes in this file

    This class implements the command-line interface to the protocol compiler.

    class CommandLineInterface

    #include <google/protobuf/compiler/command_line_interface.h>
    namespace google::protobuf::compiler

    This class implements the command-line interface to the protocol compiler.

    It is designed to make it very easy to create a custom protocol compiler supporting the languages of your choice. For example, if you wanted to create a custom protocol compiler binary which includes both the regular C++ support plus support for your own custom output "Foo", you would write a class "FooGenerator" which implements the CodeGenerator interface, then write a main() procedure like this:

    int main(int argc, char* argv[]) {
       google::protobuf::compiler::CommandLineInterface cli;
    @@ -37,16 +37,16 @@ type = "docs"
     
     

    For a full description of the command-line syntax, invoke it with –help.

    -

    Members

    const char *const
    kPathSeparator
    CommandLineInterface()
    ~CommandLineInterface()
    void
    RegisterGenerator(const std::string & flag_name, CodeGenerator * generator, const std::string & help_text)
    Register a code generator for a language. more...
    void
    RegisterGenerator(const std::string & flag_name, const std::string & option_flag_name, CodeGenerator * generator, const std::string & help_text)
    Register a code generator for a language. more...
    void
    AllowPlugins(const std::string & exe_name_prefix)
    Enables "plugins". more...
    int
    Run(int argc, const char *const argv)
    Run the Protocol Compiler with the given command-line parameters. more...
    void
    SetInputsAreProtoPathRelative(bool )
    DEPRECATED. more...
    void
    SetVersionInfo(const std::string & text)
    Provides some text which will be printed when the –version flag is used. more...

    void CommandLineInterface::RegisterGenerator(
            const std::string & flag_name,
            CodeGenerator * generator,
            const std::string & help_text)

    Register a code generator for a language.

    Parameters:

    +

    Members

    const char *const
    kPathSeparator
    CommandLineInterface()
    ~CommandLineInterface()
    void
    RegisterGenerator(const std::string & flag_name, CodeGenerator * generator, const std::string & help_text)
    Register a code generator for a language. more...
    void
    RegisterGenerator(const std::string & flag_name, const std::string & option_flag_name, CodeGenerator * generator, const std::string & help_text)
    Register a code generator for a language. more...
    void
    AllowPlugins(const std::string & exe_name_prefix)
    Enables "plugins". more...
    int
    Run(int argc, const char *const argv)
    Run the Protocol Compiler with the given command-line parameters. more...
    void
    SetInputsAreProtoPathRelative(bool )
    DEPRECATED. more...
    void
    SetVersionInfo(const std::string & text)
    Provides some text which will be printed when the –version flag is used. more...

    void CommandLineInterface::RegisterGenerator(
            const std::string & flag_name,
            CodeGenerator * generator,
            const std::string & help_text)

    Register a code generator for a language.

    Parameters:

    • flag_name: The command-line flag used to specify an output file of this type. The name must start with a '-'. If the name is longer than one letter, it must start with two '-'s.
    • -
    • generator: The CodeGenerator which will be called to generate files of this type.
    • +
    • generator: The CodeGenerator which will be called to generate files of this type.
    • help_text: Text describing this flag in the –help output.

    Some generators accept extra parameters. You can specify this parameter on the command-line by placing it before the output directory, separated by a colon:

    protoc --foo_out=enable_bar:outdir
    -

    The text before the colon is passed to CodeGenerator::Generate() as the "parameter".

    -

    void CommandLineInterface::RegisterGenerator(
            const std::string & flag_name,
            const std::string & option_flag_name,
            CodeGenerator * generator,
            const std::string & help_text)

    Register a code generator for a language.

    Besides flag_name you can specify another option_flag_name that could be used to pass extra parameters to the registered code generator. Suppose you have registered a generator by calling:

    +

    The text before the colon is passed to CodeGenerator::Generate() as the "parameter".

    +

    void CommandLineInterface::RegisterGenerator(
            const std::string & flag_name,
            const std::string & option_flag_name,
            CodeGenerator * generator,
            const std::string & help_text)

    Register a code generator for a language.

    Besides flag_name you can specify another option_flag_name that could be used to pass extra parameters to the registered code generator. Suppose you have registered a generator by calling:

    command_line_interface.RegisterGenerator("--foo_out", "--foo_opt", ...)

    Then you could invoke the compiler with a command like:

    protoc --foo_out=enable_bar:outdir --foo_opt=enable_baz
    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 48672e93..f3f2e8e5 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 @@ -6,15 +6,15 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/cpp/cpp_generator.h>
    namespace google::protobuf::compiler::cpp

    Generates C++ code for a given .proto file.

    Classes in this file

    CodeGenerator implementation which generates a C++ source file and header.

    class CppGenerator: public CodeGenerator

    #include <google/protobuf/compiler/cpp/cpp_generator.h>
    namespace google::protobuf::compiler::cpp

    CodeGenerator implementation which generates a C++ source file and header.

    If you create your own protocol compiler binary and you want it to support C++ output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.

    +

    #include <google/protobuf/compiler/cpp/cpp_generator.h>
    namespace google::protobuf::compiler::cpp

    Generates C++ code for a given .proto file.

    Classes in this file

    CodeGenerator implementation which generates a C++ source file and header.

    class CppGenerator: public CodeGenerator

    #include <google/protobuf/compiler/cpp/cpp_generator.h>
    namespace google::protobuf::compiler::cpp

    CodeGenerator implementation which generates a C++ source file and header.

    If you create your own protocol compiler binary and you want it to support C++ output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.

    -

    Members

    enum
    Runtime
    CppGenerator()
    ~CppGenerator()
    void
    set_opensource_runtime(bool opensource)
    void
    set_runtime_include_base(const std::string & base)
    If set to a non-empty string, generated code will do: more...

    implements CodeGenerator

    virtual bool
    Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) const
    Generates code for the given proto file, generating one or more files in the given output directory. more...
    virtual uint64_t
    GetSupportedFeatures() const
    Implement this to indicate what features this code generator supports. more...

    enum CppGenerator::Runtime {
      kGoogle3,
      kOpensource,
      kOpensourceGoogle3
    }

    kGoogle3Use the internal google3 runtime.
    kOpensourceUse the open-source runtime.
    kOpensourceGoogle3

    Use the open-source runtime with google3 #include paths.

    We make these absolute to avoid ambiguity, so the runtime will be #included like:

    +

    Members

    enum
    Runtime
    CppGenerator()
    ~CppGenerator()
    void
    set_opensource_runtime(bool opensource)
    void
    set_runtime_include_base(const std::string & base)
    If set to a non-empty string, generated code will do: more...

    implements CodeGenerator

    virtual bool
    Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) const
    Generates code for the given proto file, generating one or more files in the given output directory. more...
    virtual uint64_t
    GetSupportedFeatures() const
    Implement this to indicate what features this code generator supports. more...

    enum CppGenerator::Runtime {
      kGoogle3,
      kOpensource,
      kOpensourceGoogle3
    }

    kGoogle3Use the internal google3 runtime.
    kOpensourceUse the open-source runtime.
    kOpensourceGoogle3

    Use the open-source runtime with google3 #include paths.

    We make these absolute to avoid ambiguity, so the runtime will be #included like:

    
     

    void CppGenerator::set_runtime_include_base(
            const std::string & base)

    If set to a non-empty string, generated code will do:

    /google/protobuf/message.h"

    instead of:

    
     

    This has no effect if opensource_runtime = false.

    -

    virtual bool CppGenerator::Generate(
            const FileDescriptor * file,
            const std::string & parameter,
            GeneratorContext * generator_context,
            std::string * error) const

    Generates 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.

    +

    virtual bool CppGenerator::Generate(
            const FileDescriptor * file,
            const std::string & parameter,
            GeneratorContext * generator_context,
            std::string * error) const

    Generates 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 uint64_t CppGenerator::GetSupportedFeatures() const

    Implement this to indicate what features this code generator supports.

    This should be a bitwise OR of features from the Features enum in plugin.proto.

    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 bfe0bb7d..2f4c0701 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 @@ -6,9 +6,9 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/csharp/csharp_generator.h>
    namespace google::protobuf::compiler::csharp

    Generates C# code for a given .proto file.

    Classes in this file

    CodeGenerator implementation which generates a C# source file and header.

    class Generator: public CodeGenerator

    #include <google/protobuf/compiler/csharp/csharp_generator.h>
    namespace google::protobuf::compiler::csharp

    CodeGenerator implementation which generates a C# source file and header.

    If you create your own protocol compiler binary and you want it to support C# output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.

    +

    #include <google/protobuf/compiler/csharp/csharp_generator.h>
    namespace google::protobuf::compiler::csharp

    Generates C# code for a given .proto file.

    Classes in this file

    CodeGenerator implementation which generates a C# source file and header.

    class Generator: public CodeGenerator

    #include <google/protobuf/compiler/csharp/csharp_generator.h>
    namespace google::protobuf::compiler::csharp

    CodeGenerator implementation which generates a C# source file and header.

    If you create your own protocol compiler binary and you want it to support C# output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.

    -

    Members

    Generator()
    ~Generator()
    virtual bool
    Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) const
    Generates code for the given proto file, generating one or more files in the given output directory. more...
    virtual uint64_t
    GetSupportedFeatures() const
    Implement 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) const

    Generates 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()
    ~Generator()
    virtual bool
    Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) const
    Generates code for the given proto file, generating one or more files in the given output directory. more...
    virtual uint64_t
    GetSupportedFeatures() const
    Implement 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) const

    Generates 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 uint64_t Generator::GetSupportedFeatures() const

    Implement this to indicate what features this code generator supports.

    This should be a bitwise OR of features from the Features enum in plugin.proto.

    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 08155068..56ae9169 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 @@ -6,23 +6,23 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/csharp/csharp_names.h>
    namespace google::protobuf::compiler::csharp

    Provides a mechanism for mapping a descriptor to the fully-qualified name of the corresponding C# class.

    Classes in this file

    File Members

    These definitions are not part of any class.
    std::string
    GetFileNamespace(const FileDescriptor * descriptor)
    Requires: more...
    std::string
    GetClassName(const Descriptor * descriptor)
    Requires: more...
    std::string
    GetReflectionClassName(const FileDescriptor * descriptor)
    Requires: more...
    std::string
    GetOutputFile(const FileDescriptor * descriptor, const std::string file_extension, const bool generate_directories, const std::string base_namespace, std::string * error)
    Generates output file name for given file descriptor. more...

    std::string csharp::GetFileNamespace(
            const FileDescriptor * descriptor)

    Requires:

    descriptor != NULL
    +

    #include <google/protobuf/compiler/csharp/csharp_names.h>
    namespace google::protobuf::compiler::csharp

    Provides a mechanism for mapping a descriptor to the fully-qualified name of the corresponding C# class.

    Classes in this file

    File Members

    These definitions are not part of any class.
    std::string
    GetFileNamespace(const FileDescriptor * descriptor)
    Requires: more...
    std::string
    GetClassName(const Descriptor * descriptor)
    Requires: more...
    std::string
    GetReflectionClassName(const FileDescriptor * descriptor)
    Requires: more...
    std::string
    GetOutputFile(const FileDescriptor * descriptor, const std::string file_extension, const bool generate_directories, const std::string base_namespace, std::string * error)
    Generates output file name for given file descriptor. more...

    std::string csharp::GetFileNamespace(
            const FileDescriptor * descriptor)

    Requires:

    descriptor != NULL

    Returns:

    The namespace to use for given file descriptor.
    -

    std::string csharp::GetClassName(
            const Descriptor * descriptor)

    Requires:

    descriptor != NULL
    +

    std::string csharp::GetClassName(
            const Descriptor * descriptor)

    Requires:

    descriptor != NULL

    Returns:

    The fully-qualified C# class name.
    -

    std::string csharp::GetReflectionClassName(
            const FileDescriptor * descriptor)

    Requires:

    descriptor != NULL
    +

    std::string csharp::GetReflectionClassName(
            const FileDescriptor * descriptor)

    Requires:

    descriptor != NULL

    Returns:

    The fully-qualified name of the C# class that provides
     access to the file descriptor. Proto compiler generates
     such class for each .proto file processed.
    -

    std::string csharp::GetOutputFile(
            const FileDescriptor * descriptor,
            const std::string file_extension,
            const bool generate_directories,
            const std::string base_namespace,
            std::string * error)

    Generates output file name for given file descriptor.

    If generate_directories is true, the output file will be put under directory corresponding to file's namespace. base_namespace can be used to strip some of the top level directories. E.g. for file with namespace "Bar.Foo" and base_namespace="Bar", the resulting file will be put under directory "Foo" (and not "Bar/Foo").

    +

    std::string csharp::GetOutputFile(
            const FileDescriptor * descriptor,
            const std::string file_extension,
            const bool generate_directories,
            const std::string base_namespace,
            std::string * error)

    Generates output file name for given file descriptor.

    If generate_directories is true, the output file will be put under directory corresponding to file's namespace. base_namespace can be used to strip some of the top level directories. E.g. for file with namespace "Bar.Foo" and base_namespace="Bar", the resulting file will be put under directory "Foo" (and not "Bar/Foo").

    Requires:

    descriptor != NULL
     error != NULL
    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 1804ffea..fbce6923 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.importer.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.importer.md @@ -6,25 +6,25 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    This file is the public interface to the .proto file parser.

    Classes in this file

    An implementation of DescriptorDatabase which loads files from a SourceTree and parses them.
    Simple interface for parsing .proto files.
    If the importer encounters problems while trying to import the proto files, it reports them to a MultiFileErrorCollector.
    Abstract interface which represents a directory tree containing proto files.
    An implementation of SourceTree which loads files from locations on disk.

    class SourceTreeDescriptorDatabase: public DescriptorDatabase

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    An implementation of DescriptorDatabase which loads files from a SourceTree and parses them.

    Note: This class is not thread-safe since it maintains a table of source code locations for error reporting. However, when a DescriptorPool wraps a DescriptorDatabase, it uses mutex locking to make sure only one method of the database is called at a time, even if the DescriptorPool is used from multiple threads. Therefore, there is only a problem if you create multiple DescriptorPools wrapping the same SourceTreeDescriptorDatabase and use them from multiple threads.

    +

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    This file is the public interface to the .proto file parser.

    Classes in this file

    An implementation of DescriptorDatabase which loads files from a SourceTree and parses them.
    Simple interface for parsing .proto files.
    If the importer encounters problems while trying to import the proto files, it reports them to a MultiFileErrorCollector.
    Abstract interface which represents a directory tree containing proto files.
    An implementation of SourceTree which loads files from locations on disk.

    class SourceTreeDescriptorDatabase: public DescriptorDatabase

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    An implementation of DescriptorDatabase which loads files from a SourceTree and parses them.

    Note: This class is not thread-safe since it maintains a table of source code locations for error reporting. However, when a DescriptorPool wraps a DescriptorDatabase, it uses mutex locking to make sure only one method of the database is called at a time, even if the DescriptorPool is used from multiple threads. Therefore, there is only a problem if you create multiple DescriptorPools wrapping the same SourceTreeDescriptorDatabase and use them from multiple threads.

    Note: This class does not implement FindFileContainingSymbol() or FindFileContainingExtension(); these will always return false.

    -

    Members

    SourceTreeDescriptorDatabase(SourceTree * source_tree)
    SourceTreeDescriptorDatabase(SourceTree * source_tree, DescriptorDatabase * fallback_database)
    If non-NULL, fallback_database will be checked if a file doesn't exist in the specified source_tree.
    ~SourceTreeDescriptorDatabase()
    void
    RecordErrorsTo(MultiFileErrorCollector * error_collector)
    Instructs the SourceTreeDescriptorDatabase to report any parse errors to the given MultiFileErrorCollector. more...
    DescriptorPool::ErrorCollector *
    GetValidationErrorCollector()
    Gets a DescriptorPool::ErrorCollector which records errors to the MultiFileErrorCollector specified with RecordErrorsTo(). more...

    implements DescriptorDatabase

    virtual bool
    FindFileByName(const std::string & filename, FileDescriptorProto * output)
    Find a file by file name. more...
    virtual bool
    FindFileContainingSymbol(const std::string & symbol_name, FileDescriptorProto * output)
    Find the file that declares the given fully-qualified symbol name. more...
    virtual bool
    FindFileContainingExtension(const std::string & containing_type, int field_number, FileDescriptorProto * output)
    Find the file which defines an extension extending the given message type with the given field number. more...

    void SourceTreeDescriptorDatabase::RecordErrorsTo(
            MultiFileErrorCollector * error_collector)

    Instructs the SourceTreeDescriptorDatabase to report any parse errors to the given MultiFileErrorCollector.

    This should be called before parsing. error_collector must remain valid until either this method is called again or the SourceTreeDescriptorDatabase is destroyed.

    -

    DescriptorPool::ErrorCollector *
        SourceTreeDescriptorDatabase::GetValidationErrorCollector()

    Gets a DescriptorPool::ErrorCollector which records errors to the MultiFileErrorCollector specified with RecordErrorsTo().

    This collector has the ability to determine exact line and column numbers of errors from the information given to it by the DescriptorPool.

    +

    Members

    SourceTreeDescriptorDatabase(SourceTree * source_tree)
    SourceTreeDescriptorDatabase(SourceTree * source_tree, DescriptorDatabase * fallback_database)
    If non-NULL, fallback_database will be checked if a file doesn't exist in the specified source_tree.
    ~SourceTreeDescriptorDatabase()
    void
    RecordErrorsTo(MultiFileErrorCollector * error_collector)
    Instructs the SourceTreeDescriptorDatabase to report any parse errors to the given MultiFileErrorCollector. more...
    DescriptorPool::ErrorCollector *
    GetValidationErrorCollector()
    Gets a DescriptorPool::ErrorCollector which records errors to the MultiFileErrorCollector specified with RecordErrorsTo(). more...

    implements DescriptorDatabase

    virtual bool
    FindFileByName(const std::string & filename, FileDescriptorProto * output)
    Find a file by file name. more...
    virtual bool
    FindFileContainingSymbol(const std::string & symbol_name, FileDescriptorProto * output)
    Find the file that declares the given fully-qualified symbol name. more...
    virtual bool
    FindFileContainingExtension(const std::string & containing_type, int field_number, FileDescriptorProto * output)
    Find the file which defines an extension extending the given message type with the given field number. more...

    void SourceTreeDescriptorDatabase::RecordErrorsTo(
            MultiFileErrorCollector * error_collector)

    Instructs the SourceTreeDescriptorDatabase to report any parse errors to the given MultiFileErrorCollector.

    This should be called before parsing. error_collector must remain valid until either this method is called again or the SourceTreeDescriptorDatabase is destroyed.

    +

    DescriptorPool::ErrorCollector *
        SourceTreeDescriptorDatabase::GetValidationErrorCollector()

    Gets a DescriptorPool::ErrorCollector which records errors to the MultiFileErrorCollector specified with RecordErrorsTo().

    This collector has the ability to determine exact line and column numbers of errors from the information given to it by the DescriptorPool.


    virtual bool SourceTreeDescriptorDatabase::FindFileByName(
            const std::string & filename,
            FileDescriptorProto * output)

    Find a file by file name.

    Fills in in *output and returns true if found. Otherwise, returns false, leaving the contents of *output undefined.


    virtual bool SourceTreeDescriptorDatabase::FindFileContainingSymbol(
            const std::string & symbol_name,
            FileDescriptorProto * output)

    Find the file that declares the given fully-qualified symbol name.

    If found, fills in *output and returns true, otherwise returns false and leaves *output undefined.


    virtual bool SourceTreeDescriptorDatabase::FindFileContainingExtension(
            const std::string & containing_type,
            int field_number,
            FileDescriptorProto * output)

    Find the file which defines an extension extending the given message type with the given field number.

    If found, fills in *output and returns true, otherwise returns false and leaves *output undefined. containing_type must be a fully-qualified type name.

    -

    class Importer

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    Simple interface for parsing .proto files.

    This wraps the process of opening the file, parsing it with a Parser, recursively parsing all its imports, and then cross-linking the results to produce a FileDescriptor.

    +

    class Importer

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    Simple interface for parsing .proto files.

    This wraps the process of opening the file, parsing it with a Parser, recursively parsing all its imports, and then cross-linking the results to produce a FileDescriptor.

    This is really just a thin wrapper around SourceTreeDescriptorDatabase. You may find that SourceTreeDescriptorDatabase is more flexible.

    -

    Members

    Importer(SourceTree * source_tree, MultiFileErrorCollector * error_collector)
    ~Importer()
    const FileDescriptor *
    Import(const std::string & filename)
    Import the given file and build a FileDescriptor representing it. more...
    const DescriptorPool *
    pool() const
    The DescriptorPool in which all imported FileDescriptors and their contents are stored.
    void
    AddUnusedImportTrackFile(const std::string & file_name, bool is_error = false)
    void
    ClearUnusedImportTrackFiles()

    const FileDescriptor *
        Importer::Import(
            const std::string & filename)

    Import the given file and build a FileDescriptor representing it.

    If the file is already in the DescriptorPool, the existing FileDescriptor will be returned. The FileDescriptor is property of the DescriptorPool, and will remain valid until it is destroyed. If any errors occur, they will be reported using the error collector and Import() will return NULL.

    -

    A particular Importer object will only report errors for a particular file once. All future attempts to import the same file will return NULL without reporting any errors. The idea is that you might want to import a lot of files without seeing the same errors over and over again. If you want to see errors for the same files repeatedly, you can use a separate Importer object to import each one (but use the same DescriptorPool so that they can be cross-linked).

    -

    class MultiFileErrorCollector

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    If the importer encounters problems while trying to import the proto files, it reports them to a MultiFileErrorCollector.

    Members

    MultiFileErrorCollector()
    virtual
    ~MultiFileErrorCollector()
    virtual void
    AddError(const std::string & filename, int line, int column, const std::string & message) = 0
    Line and column numbers are zero-based. more...
    virtual void
    AddWarning(const std::string & , int , int , const std::string & )

    virtual void MultiFileErrorCollector::AddError(
            const std::string & filename,
            int line,
            int column,
            const std::string & message) = 0

    Line and column numbers are zero-based.

    A line number of -1 indicates an error with the entire file (e.g. "not found").

    -

    class SourceTree

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    Abstract interface which represents a directory tree containing proto files.

    Used by the default implementation of Importer to resolve import statements Most users will probably want to use the DiskSourceTree implementation, below.

    -

    Known subclasses:

    Members

    SourceTree()
    virtual
    ~SourceTree()
    virtual io::ZeroCopyInputStream *
    Open(const std::string & filename) = 0
    Open the given file and return a stream that reads it, or NULL if not found. more...
    virtual std::string
    GetLastErrorMessage()
    If Open() returns NULL, calling this method immediately will return an description of the error. more...

    virtual io::ZeroCopyInputStream *
        SourceTree::Open(
            const std::string & filename) = 0

    Open the given file and return a stream that reads it, or NULL if not found.

    The caller takes ownership of the returned object. The filename must be a path relative to the root of the source tree and must not contain "." or ".." components.

    +

    Members

    Importer(SourceTree * source_tree, MultiFileErrorCollector * error_collector)
    ~Importer()
    const FileDescriptor *
    Import(const std::string & filename)
    Import the given file and build a FileDescriptor representing it. more...
    const DescriptorPool *
    pool() const
    The DescriptorPool in which all imported FileDescriptors and their contents are stored.
    void
    AddUnusedImportTrackFile(const std::string & file_name, bool is_error = false)
    void
    ClearUnusedImportTrackFiles()

    const FileDescriptor *
        Importer::Import(
            const std::string & filename)

    Import the given file and build a FileDescriptor representing it.

    If the file is already in the DescriptorPool, the existing FileDescriptor will be returned. The FileDescriptor is property of the DescriptorPool, and will remain valid until it is destroyed. If any errors occur, they will be reported using the error collector and Import() will return NULL.

    +

    A particular Importer object will only report errors for a particular file once. All future attempts to import the same file will return NULL without reporting any errors. The idea is that you might want to import a lot of files without seeing the same errors over and over again. If you want to see errors for the same files repeatedly, you can use a separate Importer object to import each one (but use the same DescriptorPool so that they can be cross-linked).

    +

    class MultiFileErrorCollector

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    If the importer encounters problems while trying to import the proto files, it reports them to a MultiFileErrorCollector.

    Members

    MultiFileErrorCollector()
    virtual
    ~MultiFileErrorCollector()
    virtual void
    AddError(const std::string & filename, int line, int column, const std::string & message) = 0
    Line and column numbers are zero-based. more...
    virtual void
    AddWarning(const std::string & , int , int , const std::string & )

    virtual void MultiFileErrorCollector::AddError(
            const std::string & filename,
            int line,
            int column,
            const std::string & message) = 0

    Line and column numbers are zero-based.

    A line number of -1 indicates an error with the entire file (e.g. "not found").

    +

    class SourceTree

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    Abstract interface which represents a directory tree containing proto files.

    Used by the default implementation of Importer to resolve import statements Most users will probably want to use the DiskSourceTree implementation, below.

    +

    Known subclasses:

    Members

    SourceTree()
    virtual
    ~SourceTree()
    virtual io::ZeroCopyInputStream *
    Open(const std::string & filename) = 0
    Open the given file and return a stream that reads it, or NULL if not found. more...
    virtual std::string
    GetLastErrorMessage()
    If Open() returns NULL, calling this method immediately will return an description of the error. more...

    virtual io::ZeroCopyInputStream *
        SourceTree::Open(
            const std::string & filename) = 0

    Open the given file and return a stream that reads it, or NULL if not found.

    The caller takes ownership of the returned object. The filename must be a path relative to the root of the source tree and must not contain "." or ".." components.


    virtual std::string SourceTree::GetLastErrorMessage()

    If Open() returns NULL, calling this method immediately will return an description of the error.

    Subclasses should implement this method and return a meaningful value for better error reporting.

    -

    class DiskSourceTree: public SourceTree

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    An implementation of SourceTree which loads files from locations on disk.

    Multiple mappings can be set up to map locations in the DiskSourceTree to locations in the physical filesystem.

    -

    Members

    enum
    DiskFileToVirtualFileResult
    DiskSourceTree()
    ~DiskSourceTree()
    void
    MapPath(const std::string & virtual_path, const std::string & disk_path)
    Map a path on disk to a location in the SourceTree. more...
    DiskFileToVirtualFileResult
    DiskFileToVirtualFile(const std::string & disk_file, std::string * virtual_file, std::string * shadowing_disk_file)
    Given a path to a file on disk, find a virtual path mapping to that file. more...
    bool
    VirtualFileToDiskFile(const std::string & virtual_file, std::string * disk_file)
    Given a virtual path, find the path to the file on disk. more...

    implements SourceTree

    virtual io::ZeroCopyInputStream *
    Open(const std::string & filename)
    Open the given file and return a stream that reads it, or NULL if not found. more...
    virtual std::string
    GetLastErrorMessage()
    If Open() returns NULL, calling this method immediately will return an description of the error. more...

    enum DiskSourceTree::DiskFileToVirtualFileResult {
      SUCCESS,
      SHADOWED,
      CANNOT_OPEN,
      NO_MAPPING
    }

    Return type for DiskFileToVirtualFile().

    SUCCESS
    SHADOWED
    CANNOT_OPEN
    NO_MAPPING

    void DiskSourceTree::MapPath(
            const std::string & virtual_path,
            const std::string & disk_path)

    Map a path on disk to a location in the SourceTree.

    The path may be either a file or a directory. If it is a directory, the entire tree under it will be mapped to the given virtual location. To map a directory to the root of the source tree, pass an empty string for virtual_path.

    +

    class DiskSourceTree: public SourceTree

    #include <google/protobuf/compiler/importer.h>
    namespace google::protobuf::compiler

    An implementation of SourceTree which loads files from locations on disk.

    Multiple mappings can be set up to map locations in the DiskSourceTree to locations in the physical filesystem.

    +

    Members

    enum
    DiskFileToVirtualFileResult
    DiskSourceTree()
    ~DiskSourceTree()
    void
    MapPath(const std::string & virtual_path, const std::string & disk_path)
    Map a path on disk to a location in the SourceTree. more...
    DiskFileToVirtualFileResult
    DiskFileToVirtualFile(const std::string & disk_file, std::string * virtual_file, std::string * shadowing_disk_file)
    Given a path to a file on disk, find a virtual path mapping to that file. more...
    bool
    VirtualFileToDiskFile(const std::string & virtual_file, std::string * disk_file)
    Given a virtual path, find the path to the file on disk. more...

    implements SourceTree

    virtual io::ZeroCopyInputStream *
    Open(const std::string & filename)
    Open the given file and return a stream that reads it, or NULL if not found. more...
    virtual std::string
    GetLastErrorMessage()
    If Open() returns NULL, calling this method immediately will return an description of the error. more...

    enum DiskSourceTree::DiskFileToVirtualFileResult {
      SUCCESS,
      SHADOWED,
      CANNOT_OPEN,
      NO_MAPPING
    }

    Return type for DiskFileToVirtualFile().

    SUCCESS
    SHADOWED
    CANNOT_OPEN
    NO_MAPPING

    void DiskSourceTree::MapPath(
            const std::string & virtual_path,
            const std::string & disk_path)

    Map a path on disk to a location in the SourceTree.

    The path may be either a file or a directory. If it is a directory, the entire tree under it will be mapped to the given virtual location. To map a directory to the root of the source tree, pass an empty string for virtual_path.

    If multiple mapped paths apply when opening a file, they will be searched in order. For example, if you do:

    MapPath("bar", "foo/bar");
     MapPath("", "baz");
    @@ -40,6 +40,6 @@ MapPath("", "baz");
  • NO_MAPPING: Indicates that no mapping was found which contains this file.

  • bool DiskSourceTree::VirtualFileToDiskFile(
            const std::string & virtual_file,
            std::string * disk_file)

    Given a virtual path, find the path to the file on disk.

    Return true and update disk_file with the on-disk path if the file exists. Return false and leave disk_file untouched if the file doesn't exist.

    -

    virtual io::ZeroCopyInputStream *
        DiskSourceTree::Open(
            const std::string & filename)

    Open the given file and return a stream that reads it, or NULL if not found.

    The caller takes ownership of the returned object. The filename must be a path relative to the root of the source tree and must not contain "." or ".." components.

    +

    virtual io::ZeroCopyInputStream *
        DiskSourceTree::Open(
            const std::string & filename)

    Open the given file and return a stream that reads it, or NULL if not found.

    The caller takes ownership of the returned object. The filename must be a path relative to the root of the source tree and must not contain "." or ".." components.


    virtual std::string DiskSourceTree::GetLastErrorMessage()

    If Open() returns NULL, calling this method immediately will return an description of the error.

    Subclasses should implement this method and return a meaningful value for better error reporting.

    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 9ca74e12..98ee6464 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 @@ -6,9 +6,9 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/java/java_generator.h>
    namespace google::protobuf::compiler::java

    Generates Java code for a given .proto file.

    Classes in this file

    CodeGenerator implementation which generates Java code.

    class JavaGenerator: public CodeGenerator

    #include <google/protobuf/compiler/java/java_generator.h>
    namespace google::protobuf::compiler::java

    CodeGenerator implementation which generates Java code.

    If you create your own protocol compiler binary and you want it to support Java output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.

    +

    #include <google/protobuf/compiler/java/java_generator.h>
    namespace google::protobuf::compiler::java

    Generates Java code for a given .proto file.

    Classes in this file

    CodeGenerator implementation which generates Java code.

    class JavaGenerator: public CodeGenerator

    #include <google/protobuf/compiler/java/java_generator.h>
    namespace google::protobuf::compiler::java

    CodeGenerator implementation which generates Java code.

    If you create your own protocol compiler binary and you want it to support Java output, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.

    -

    Members

    JavaGenerator()
    ~JavaGenerator()

    implements CodeGenerator

    virtual bool
    Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) const
    Generates code for the given proto file, generating one or more files in the given output directory. more...
    virtual uint64_t
    GetSupportedFeatures() const
    Implement this to indicate what features this code generator supports. more...

    virtual bool JavaGenerator::Generate(
            const FileDescriptor * file,
            const std::string & parameter,
            GeneratorContext * generator_context,
            std::string * error) const

    Generates 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

    JavaGenerator()
    ~JavaGenerator()

    implements CodeGenerator

    virtual bool
    Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) const
    Generates code for the given proto file, generating one or more files in the given output directory. more...
    virtual uint64_t
    GetSupportedFeatures() const
    Implement this to indicate what features this code generator supports. more...

    virtual bool JavaGenerator::Generate(
            const FileDescriptor * file,
            const std::string & parameter,
            GeneratorContext * generator_context,
            std::string * error) const

    Generates 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 uint64_t JavaGenerator::GetSupportedFeatures() const

    Implement this to indicate what features this code generator supports.

    This should be a bitwise OR of features from the Features enum in plugin.proto.

    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 f8b33d87..4ff12b06 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 @@ -6,31 +6,31 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/java/java_names.h>
    namespace google::protobuf::compiler::java

    Provides a mechanism for mapping a descriptor to the fully-qualified name of the corresponding Java class.

    Classes in this file

    File Members

    These definitions are not part of any class.
    std::string
    ClassName(const Descriptor * descriptor)
    Requires: more...
    std::string
    ClassName(const EnumDescriptor * descriptor)
    Requires: more...
    std::string
    ClassName(const FileDescriptor * descriptor)
    Requires: more...
    std::string
    ClassName(const ServiceDescriptor * descriptor)
    Requires: more...
    std::string
    FileJavaPackage(const FileDescriptor * descriptor)
    Requires: more...
    std::string
    CapitalizedFieldName(const FieldDescriptor * descriptor)
    Requires: more...

    std::string java::ClassName(
            const Descriptor * descriptor)

    Requires:

    descriptor != NULL
    +

    #include <google/protobuf/compiler/java/java_names.h>
    namespace google::protobuf::compiler::java

    Provides a mechanism for mapping a descriptor to the fully-qualified name of the corresponding Java class.

    Classes in this file

    File Members

    These definitions are not part of any class.
    std::string
    ClassName(const Descriptor * descriptor)
    Requires: more...
    std::string
    ClassName(const EnumDescriptor * descriptor)
    Requires: more...
    std::string
    ClassName(const FileDescriptor * descriptor)
    Requires: more...
    std::string
    ClassName(const ServiceDescriptor * descriptor)
    Requires: more...
    std::string
    FileJavaPackage(const FileDescriptor * descriptor)
    Requires: more...
    std::string
    CapitalizedFieldName(const FieldDescriptor * descriptor)
    Requires: more...

    std::string java::ClassName(
            const Descriptor * descriptor)

    Requires:

    descriptor != NULL

    Returns:

    The fully-qualified Java class name.
    -

    std::string java::ClassName(
            const EnumDescriptor * descriptor)

    Requires:

    descriptor != NULL
    +

    std::string java::ClassName(
            const EnumDescriptor * descriptor)

    Requires:

    descriptor != NULL

    Returns:

    The fully-qualified Java class name.
    -

    std::string java::ClassName(
            const FileDescriptor * descriptor)

    Requires:

    descriptor != NULL
    +

    std::string java::ClassName(
            const FileDescriptor * descriptor)

    Requires:

    descriptor != NULL

    Returns:

    The fully-qualified Java class name.
    -

    std::string java::ClassName(
            const ServiceDescriptor * descriptor)

    Requires:

    descriptor != NULL
    +

    std::string java::ClassName(
            const ServiceDescriptor * descriptor)

    Requires:

    descriptor != NULL

    Returns:

    The fully-qualified Java class name.
    -

    std::string java::FileJavaPackage(
            const FileDescriptor * descriptor)

    Requires:

    descriptor != NULL
    +

    std::string java::FileJavaPackage(
            const FileDescriptor * descriptor)

    Requires:

    descriptor != NULL

    Returns:

    Java package name.
    -

    std::string java::CapitalizedFieldName(
            const FieldDescriptor * descriptor)

    Requires:

    descriptor != NULL
    +

    std::string java::CapitalizedFieldName(
            const FieldDescriptor * descriptor)

    Requires:

    descriptor != NULL

    Returns:

    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 a293ed86..796eaffa 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 @@ -6,8 +6,8 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/javanano/javanano_generator.h>
    namespace google::protobuf::compiler::javanano

    Generates Java nano code for a given .proto file.

    Classes in this file

    CodeGenerator implementation which generates Java nano code.

    class JavaNanoGenerator: public CodeGenerator

    #include <google/protobuf/compiler/javanano/javanano_generator.h>
    namespace google::protobuf::compiler::javanano

    CodeGenerator implementation which generates Java nano code.

    If you create your own protocol compiler binary and you want it to support Java output for the nano runtime, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.

    +

    #include <google/protobuf/compiler/javanano/javanano_generator.h>
    namespace google::protobuf::compiler::javanano

    Generates Java nano code for a given .proto file.

    Classes in this file

    CodeGenerator implementation which generates Java nano code.

    class JavaNanoGenerator: public CodeGenerator

    #include <google/protobuf/compiler/javanano/javanano_generator.h>
    namespace google::protobuf::compiler::javanano

    CodeGenerator implementation which generates Java nano code.

    If you create your own protocol compiler binary and you want it to support Java output for the nano runtime, you can do so by registering an instance of this CodeGenerator with the CommandLineInterface in your main() function.

    -

    Members

    JavaNanoGenerator()
    ~JavaNanoGenerator()

    implements CodeGenerator

    virtual bool
    Generate(const FileDescriptor * file, const string & parameter, GeneratorContext * generator_context, string * error) const
    Generates code for the given proto file, generating one or more files in the given output directory. more...

    virtual bool JavaNanoGenerator::Generate(
            const FileDescriptor * file,
            const string & parameter,
            GeneratorContext * generator_context,
            string * error) const

    Generates 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

    JavaNanoGenerator()
    ~JavaNanoGenerator()

    implements CodeGenerator

    virtual bool
    Generate(const FileDescriptor * file, const string & parameter, GeneratorContext * generator_context, string * error) const
    Generates code for the given proto file, generating one or more files in the given output directory. more...

    virtual bool JavaNanoGenerator::Generate(
            const FileDescriptor * file,
            const string & parameter,
            GeneratorContext * generator_context,
            string * error) const

    Generates 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.

    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 6ab34ccb..418b740d 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 @@ -6,14 +6,14 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/js/js_generator.h>
    namespace google::protobuf::compiler::js

    Generates JavaScript code for a given .proto file.

    Classes in this file

    CodeGenerator implementation which generates a JavaScript source file and header.

    struct GeneratorOptions

    #include <google/protobuf/compiler/js/js_generator.h>
    namespace google::protobuf::compiler::js

    Members

    enum
    ImportStyle
    What style of imports should be used. more...
    enum
    OutputMode
    std::string
    output_dir
    Output path.
    std::string
    namespace_prefix
    Namespace prefix.
    bool
    binary
    Enable binary-format support?
    enum google::protobuf::compiler::js::GeneratorOptions::ImportStyle
    import_style
    bool
    add_require_for_enums
    Add a goog.requires() call for each enum type used. more...
    bool
    testonly
    Set this as a test-only module via goog.setTestOnly();.
    std::string
    library
    Create a library with name <name>_lib.js rather than a separate .js file per type?
    bool
    error_on_name_conflict
    Error if there are two types that would generate the same output file?
    std::string
    extension
    The extension to use for output file names.
    bool
    one_output_file_per_input_file
    Create a separate output file for each input file?
    bool
    annotate_code
    If true, we should append annotations as comments on the last line for generated .js file. more...
    GeneratorOptions()
    bool
    ParseFromOptions(const std::vector< std::pair< std::string, std::string > > & options, std::string * error)
    std::string
    GetFileNameExtension() const
    Returns the file name extension to use for generated code.
    OutputMode
    output_mode() const
    Indicates how to output the generated code based on the provided options.

    enum GeneratorOptions::ImportStyle {
      kImportClosure,
      kImportCommonJs,
      kImportCommonJsStrict,
      kImportBrowser,
      kImportEs6
    }

    What style of imports should be used.

    kImportClosuregoog.require()
    kImportCommonJsrequire()
    kImportCommonJsStrictrequire() with no global export
    kImportBrowserno import statements
    kImportEs6import { member } from ''

    enum GeneratorOptions::OutputMode {
      kOneOutputFilePerInputFile,
      kOneOutputFilePerSCC,
      kEverythingInOneFile
    }

    kOneOutputFilePerInputFileCreate an output file for each input .proto file.
    kOneOutputFilePerSCCCreate an output file for each type.
    kEverythingInOneFilePut everything in a single file named by the library option.

    bool GeneratorOptions::add_require_for_enums

    Add a goog.requires() call for each enum type used.

    If not set, a forward declaration with goog.forwardDeclare is produced instead.

    +

    #include <google/protobuf/compiler/js/js_generator.h>
    namespace google::protobuf::compiler::js

    Generates JavaScript code for a given .proto file.

    Classes in this file

    CodeGenerator implementation which generates a JavaScript source file and header.

    struct GeneratorOptions

    #include <google/protobuf/compiler/js/js_generator.h>
    namespace google::protobuf::compiler::js

    Members

    enum
    ImportStyle
    What style of imports should be used. more...
    enum
    OutputMode
    std::string
    output_dir
    Output path.
    std::string
    namespace_prefix
    Namespace prefix.
    bool
    binary
    Enable binary-format support?
    enum google::protobuf::compiler::js::GeneratorOptions::ImportStyle
    import_style
    bool
    add_require_for_enums
    Add a goog.requires() call for each enum type used. more...
    bool
    testonly
    Set this as a test-only module via goog.setTestOnly();.
    std::string
    library
    Create a library with name <name>_lib.js rather than a separate .js file per type?
    bool
    error_on_name_conflict
    Error if there are two types that would generate the same output file?
    std::string
    extension
    The extension to use for output file names.
    bool
    one_output_file_per_input_file
    Create a separate output file for each input file?
    bool
    annotate_code
    If true, we should append annotations as comments on the last line for generated .js file. more...
    GeneratorOptions()
    bool
    ParseFromOptions(const std::vector< std::pair< std::string, std::string > > & options, std::string * error)
    std::string
    GetFileNameExtension() const
    Returns the file name extension to use for generated code.
    OutputMode
    output_mode() const
    Indicates how to output the generated code based on the provided options.

    enum GeneratorOptions::ImportStyle {
      kImportClosure,
      kImportCommonJs,
      kImportCommonJsStrict,
      kImportBrowser,
      kImportEs6
    }

    What style of imports should be used.

    kImportClosuregoog.require()
    kImportCommonJsrequire()
    kImportCommonJsStrictrequire() with no global export
    kImportBrowserno import statements
    kImportEs6import { member } from ''

    enum GeneratorOptions::OutputMode {
      kOneOutputFilePerInputFile,
      kOneOutputFilePerSCC,
      kEverythingInOneFile
    }

    kOneOutputFilePerInputFileCreate an output file for each input .proto file.
    kOneOutputFilePerSCCCreate an output file for each type.
    kEverythingInOneFilePut everything in a single file named by the library option.

    bool GeneratorOptions::add_require_for_enums

    Add a goog.requires() call for each enum type used.

    If not set, a forward declaration with goog.forwardDeclare is produced instead.


    bool GeneratorOptions::annotate_code

    If 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).

    -

    class Generator: public CodeGenerator

    #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.

    +

    class Generator: public CodeGenerator

    #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) const
    Generates code for the given proto file, generating one or more files in the given output directory. more...
    virtual bool
    HasGenerateAll() const
    This 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) const
    Generates code for all given proto files. more...
    virtual uint64
    GetSupportedFeatures() const
    Implement 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) const

    Generates 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) const
    Generates code for the given proto file, generating one or more files in the given output directory. more...
    virtual bool
    HasGenerateAll() const
    This 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) const
    Generates code for all given proto files. more...
    virtual uint64
    GetSupportedFeatures() const
    Implement 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) const

    Generates 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() const

    This 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) const

    Generates 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.

    +

    virtual bool Generator::GenerateAll(
            const std::vector< const FileDescriptor * > & files,
            const std::string & parameter,
            GeneratorContext * generator_context,
            std::string * error) const

    Generates 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 Generator::GetSupportedFeatures() const

    Implement this to indicate what features this code generator supports.

    This should be a bitwise OR of features from the Features enum in plugin.proto.

    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 e994ce5b..472c68e6 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 @@ -6,12 +6,12 @@ description = "This section contains reference documentation for working with Pr 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.

    class ObjectiveCGenerator: public CodeGenerator

    #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.

    +

    #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.

    class ObjectiveCGenerator: public CodeGenerator

    #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() const
    This 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) const
    Generates 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) const
    Generates code for all given proto files. more...
    virtual uint64_t
    GetSupportedFeatures() const
    Implement this to indicate what features this code generator supports. more...

    virtual bool ObjectiveCGenerator::HasGenerateAll() const

    This 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) const

    Generates 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

    ObjectiveCGenerator()
    ~ObjectiveCGenerator()
    ObjectiveCGenerator(const ObjectiveCGenerator & )
    ObjectiveCGenerator &
    operator=(const ObjectiveCGenerator & )

    implements CodeGenerator

    virtual bool
    HasGenerateAll() const
    This 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) const
    Generates 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) const
    Generates code for all given proto files. more...
    virtual uint64_t
    GetSupportedFeatures() const
    Implement this to indicate what features this code generator supports. more...

    virtual bool ObjectiveCGenerator::HasGenerateAll() const

    This 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) const

    Generates 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) const

    Generates 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.

    +

    virtual bool ObjectiveCGenerator::GenerateAll(
            const std::vector< const FileDescriptor * > & files,
            const std::string & parameter,
            GeneratorContext * generator_context,
            std::string * error) const

    Generates 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 ObjectiveCGenerator::GetSupportedFeatures() const

    Implement this to indicate what features this code generator supports.

    This should be a bitwise OR of features from the Features enum in plugin.proto.

    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 07557d4f..bec4c089 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 @@ -6,9 +6,9 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
    namespace google::protobuf::compiler::objectivec

    Helper functions for generating ObjectiveC code.

    Classes in this file

    Generator options (see objectivec_generator.cc for a description of each):
    Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform the input into the expected output.
    Helper for parsing simple files.
    Helper class for parsing framework import mappings and generating import statements.

    File Members

    These definitions are not part of any class.
    enum
    ObjectiveCType
    enum
    FlagType
    const char *const
    ProtobufLibraryFrameworkName
    The name the commonly used by the library when built as a framework. more...
    std::string
    EscapeTrigraphs(const std::string & to_escape)
    Escape C++ trigraphs by escaping question marks to "\?".
    void
    TrimWhitespace(StringPiece * input)
    Remove white space from either end of a StringPiece.
    bool
    IsRetainedName(const std::string & name)
    Returns true if the name requires a ns_returns_not_retained attribute applied to it.
    bool
    IsInitName(const std::string & name)
    Returns true if the name starts with "init" and will need to have special handling under ARC.
    std::string
    FileClassPrefix(const FileDescriptor * file)
    Gets the objc_class_prefix.
    std::string
    FilePath(const FileDescriptor * file)
    Gets the path of the file we're going to generate (sans the .pb.h extension). more...
    std::string
    FilePathBasename(const FileDescriptor * file)
    Just like FilePath(), but without the directory part.
    std::string
    FileClassName(const FileDescriptor * file)
    Gets the name of the root class we'll generate in the file. more...
    std::string
    ClassName(const Descriptor * descriptor)
    These return the fully-qualified class name corresponding to the given descriptor.
    std::string
    ClassName(const Descriptor * descriptor, std::string * out_suffix_added)
    std::string
    EnumName(const EnumDescriptor * descriptor)
    std::string
    EnumValueName(const EnumValueDescriptor * descriptor)
    Returns the fully-qualified name of the enum value corresponding to the the descriptor.
    std::string
    EnumValueShortName(const EnumValueDescriptor * descriptor)
    Returns the name of the enum value corresponding to the descriptor.
    std::string
    UnCamelCaseEnumShortName(const std::string & name)
    Reverse what an enum does.
    std::string
    ExtensionMethodName(const FieldDescriptor * descriptor)
    Returns the name to use for the extension (used as the method off the file's Root class).
    std::string
    FieldName(const FieldDescriptor * field)
    Returns the transformed field name.
    std::string
    FieldNameCapitalized(const FieldDescriptor * field)
    std::string
    OneofEnumName(const OneofDescriptor * descriptor)
    Returns the transformed oneof name.
    std::string
    OneofName(const OneofDescriptor * descriptor)
    std::string
    OneofNameCapitalized(const OneofDescriptor * descriptor)
    std::string
    ObjCClass(const std::string & class_name)
    Returns a symbol that can be used in C code to refer to an Objective C class without initializing the class.
    std::string
    ObjCClassDeclaration(const std::string & class_name)
    Declares an Objective C class without initializing the class so that it can be refrerred to by ObjCClass.
    bool
    HasPreservingUnknownEnumSemantics(const FileDescriptor * file)
    bool
    IsMapEntryMessage(const Descriptor * descriptor)
    std::string
    UnCamelCaseFieldName(const std::string & name, const FieldDescriptor * field)
    Reverse of the above.
    template std::string
    GetOptionalDeprecatedAttribute(const TDescriptor * descriptor, const FileDescriptor * file = NULL, bool preSpace = true, bool postNewline = false)
    std::string
    GetCapitalizedType(const FieldDescriptor * field)
    ObjectiveCType
    GetObjectiveCType(FieldDescriptor::Type field_type)
    ObjectiveCType
    GetObjectiveCType(const FieldDescriptor * field)
    bool
    IsPrimitiveType(const FieldDescriptor * field)
    bool
    IsReferenceType(const FieldDescriptor * field)
    std::string
    GPBGenericValueFieldName(const FieldDescriptor * field)
    std::string
    DefaultValue(const FieldDescriptor * field)
    bool
    HasNonZeroDefaultValue(const FieldDescriptor * field)
    std::string
    BuildFlagsString(const FlagType type, const std::vector< std::string > & strings)
    std::string
    BuildCommentsString(const SourceLocation & location, bool prefer_single_line)
    Builds HeaderDoc/appledoc style comments out of the comments in the .proto file.
    std::string
    ProtobufFrameworkImportSymbol(const std::string & framework_name)
    Returns the CPP symbol name to use as the gate for framework style imports for the given framework name to use.
    bool
    IsProtobufLibraryBundledProtoFile(const FileDescriptor * file)
    Checks if the file is one of the proto's bundled with the library.
    bool
    ValidateObjCClassPrefixes(const std::vector< const FileDescriptor * > & files, const Options & generation_options, std::string * out_error)
    Checks the prefix for the given files and outputs any warnings as needed. more...
    bool
    ParseSimpleFile(const std::string & path, LineConsumer * line_consumer, std::string * out_error)

    enum objectivec::ObjectiveCType {
      OBJECTIVECTYPE_INT32,
      OBJECTIVECTYPE_UINT32,
      OBJECTIVECTYPE_INT64,
      OBJECTIVECTYPE_UINT64,
      OBJECTIVECTYPE_FLOAT,
      OBJECTIVECTYPE_DOUBLE,
      OBJECTIVECTYPE_BOOLEAN,
      OBJECTIVECTYPE_STRING,
      OBJECTIVECTYPE_DATA,
      OBJECTIVECTYPE_ENUM,
      OBJECTIVECTYPE_MESSAGE
    }

    OBJECTIVECTYPE_INT32
    OBJECTIVECTYPE_UINT32
    OBJECTIVECTYPE_INT64
    OBJECTIVECTYPE_UINT64
    OBJECTIVECTYPE_FLOAT
    OBJECTIVECTYPE_DOUBLE
    OBJECTIVECTYPE_BOOLEAN
    OBJECTIVECTYPE_STRING
    OBJECTIVECTYPE_DATA
    OBJECTIVECTYPE_ENUM
    OBJECTIVECTYPE_MESSAGE

    enum objectivec::FlagType {
      FLAGTYPE_DESCRIPTOR_INITIALIZATION,
      FLAGTYPE_EXTENSION,
      FLAGTYPE_FIELD
    }

    FLAGTYPE_DESCRIPTOR_INITIALIZATION
    FLAGTYPE_EXTENSION
    FLAGTYPE_FIELD

    const char *const objectivec::ProtobufLibraryFrameworkName

    The name the commonly used by the library when built as a framework.

    This lines up to the name used in the CocoaPod.

    +

    #include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
    namespace google::protobuf::compiler::objectivec

    Helper functions for generating ObjectiveC code.

    Classes in this file

    Generator options (see objectivec_generator.cc for a description of each):
    Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform the input into the expected output.
    Helper for parsing simple files.
    Helper class for parsing framework import mappings and generating import statements.

    File Members

    These definitions are not part of any class.
    enum
    ObjectiveCType
    enum
    FlagType
    const char *const
    ProtobufLibraryFrameworkName
    The name the commonly used by the library when built as a framework. more...
    std::string
    EscapeTrigraphs(const std::string & to_escape)
    Escape C++ trigraphs by escaping question marks to "\?".
    void
    TrimWhitespace(StringPiece * input)
    Remove white space from either end of a StringPiece.
    bool
    IsRetainedName(const std::string & name)
    Returns true if the name requires a ns_returns_not_retained attribute applied to it.
    bool
    IsInitName(const std::string & name)
    Returns true if the name starts with "init" and will need to have special handling under ARC.
    std::string
    FileClassPrefix(const FileDescriptor * file)
    Gets the objc_class_prefix.
    std::string
    FilePath(const FileDescriptor * file)
    Gets the path of the file we're going to generate (sans the .pb.h extension). more...
    std::string
    FilePathBasename(const FileDescriptor * file)
    Just like FilePath(), but without the directory part.
    std::string
    FileClassName(const FileDescriptor * file)
    Gets the name of the root class we'll generate in the file. more...
    std::string
    ClassName(const Descriptor * descriptor)
    These return the fully-qualified class name corresponding to the given descriptor.
    std::string
    ClassName(const Descriptor * descriptor, std::string * out_suffix_added)
    std::string
    EnumName(const EnumDescriptor * descriptor)
    std::string
    EnumValueName(const EnumValueDescriptor * descriptor)
    Returns the fully-qualified name of the enum value corresponding to the the descriptor.
    std::string
    EnumValueShortName(const EnumValueDescriptor * descriptor)
    Returns the name of the enum value corresponding to the descriptor.
    std::string
    UnCamelCaseEnumShortName(const std::string & name)
    Reverse what an enum does.
    std::string
    ExtensionMethodName(const FieldDescriptor * descriptor)
    Returns the name to use for the extension (used as the method off the file's Root class).
    std::string
    FieldName(const FieldDescriptor * field)
    Returns the transformed field name.
    std::string
    FieldNameCapitalized(const FieldDescriptor * field)
    std::string
    OneofEnumName(const OneofDescriptor * descriptor)
    Returns the transformed oneof name.
    std::string
    OneofName(const OneofDescriptor * descriptor)
    std::string
    OneofNameCapitalized(const OneofDescriptor * descriptor)
    std::string
    ObjCClass(const std::string & class_name)
    Returns a symbol that can be used in C code to refer to an Objective C class without initializing the class.
    std::string
    ObjCClassDeclaration(const std::string & class_name)
    Declares an Objective C class without initializing the class so that it can be refrerred to by ObjCClass.
    bool
    HasPreservingUnknownEnumSemantics(const FileDescriptor * file)
    bool
    IsMapEntryMessage(const Descriptor * descriptor)
    std::string
    UnCamelCaseFieldName(const std::string & name, const FieldDescriptor * field)
    Reverse of the above.
    template std::string
    GetOptionalDeprecatedAttribute(const TDescriptor * descriptor, const FileDescriptor * file = NULL, bool preSpace = true, bool postNewline = false)
    std::string
    GetCapitalizedType(const FieldDescriptor * field)
    ObjectiveCType
    GetObjectiveCType(FieldDescriptor::Type field_type)
    ObjectiveCType
    GetObjectiveCType(const FieldDescriptor * field)
    bool
    IsPrimitiveType(const FieldDescriptor * field)
    bool
    IsReferenceType(const FieldDescriptor * field)
    std::string
    GPBGenericValueFieldName(const FieldDescriptor * field)
    std::string
    DefaultValue(const FieldDescriptor * field)
    bool
    HasNonZeroDefaultValue(const FieldDescriptor * field)
    std::string
    BuildFlagsString(const FlagType type, const std::vector< std::string > & strings)
    std::string
    BuildCommentsString(const SourceLocation & location, bool prefer_single_line)
    Builds HeaderDoc/appledoc style comments out of the comments in the .proto file.
    std::string
    ProtobufFrameworkImportSymbol(const std::string & framework_name)
    Returns the CPP symbol name to use as the gate for framework style imports for the given framework name to use.
    bool
    IsProtobufLibraryBundledProtoFile(const FileDescriptor * file)
    Checks if the file is one of the proto's bundled with the library.
    bool
    ValidateObjCClassPrefixes(const std::vector< const FileDescriptor * > & files, const Options & generation_options, std::string * out_error)
    Checks the prefix for the given files and outputs any warnings as needed. more...
    bool
    ParseSimpleFile(const std::string & path, LineConsumer * line_consumer, std::string * out_error)

    enum objectivec::ObjectiveCType {
      OBJECTIVECTYPE_INT32,
      OBJECTIVECTYPE_UINT32,
      OBJECTIVECTYPE_INT64,
      OBJECTIVECTYPE_UINT64,
      OBJECTIVECTYPE_FLOAT,
      OBJECTIVECTYPE_DOUBLE,
      OBJECTIVECTYPE_BOOLEAN,
      OBJECTIVECTYPE_STRING,
      OBJECTIVECTYPE_DATA,
      OBJECTIVECTYPE_ENUM,
      OBJECTIVECTYPE_MESSAGE
    }

    OBJECTIVECTYPE_INT32
    OBJECTIVECTYPE_UINT32
    OBJECTIVECTYPE_INT64
    OBJECTIVECTYPE_UINT64
    OBJECTIVECTYPE_FLOAT
    OBJECTIVECTYPE_DOUBLE
    OBJECTIVECTYPE_BOOLEAN
    OBJECTIVECTYPE_STRING
    OBJECTIVECTYPE_DATA
    OBJECTIVECTYPE_ENUM
    OBJECTIVECTYPE_MESSAGE

    enum objectivec::FlagType {
      FLAGTYPE_DESCRIPTOR_INITIALIZATION,
      FLAGTYPE_EXTENSION,
      FLAGTYPE_FIELD
    }

    FLAGTYPE_DESCRIPTOR_INITIALIZATION
    FLAGTYPE_EXTENSION
    FLAGTYPE_FIELD

    const char *const objectivec::ProtobufLibraryFrameworkName

    The name the commonly used by the library when built as a framework.

    This lines up to the name used in the CocoaPod.

    -

    std::string objectivec::FilePath(
            const FileDescriptor * file)

    Gets the path of the file we're going to generate (sans the .pb.h extension).

    The path will be dependent on the objectivec package declared in the proto package.

    -

    std::string objectivec::FileClassName(
            const FileDescriptor * file)

    Gets the name of the root class we'll generate in the file.

    This class is not meant for external consumption, but instead contains helpers that the rest of the classes need

    -

    bool objectivec::ValidateObjCClassPrefixes(
            const std::vector< const FileDescriptor * > & files,
            const Options & generation_options,
            std::string * out_error)

    Checks the prefix for the given files and outputs any warnings as needed.

    If there are flat out errors, then out_error is filled in with the first error and the result is false.

    -

    struct Options

    #include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
    namespace google::protobuf::compiler::objectivec

    Generator options (see objectivec_generator.cc for a description of each):

    Members

    std::string
    expected_prefixes_path
    std::vector< std::string >
    expected_prefixes_suppressions
    std::string
    generate_for_named_framework
    std::string
    named_framework_to_proto_path_mappings_path
    std::string
    runtime_import_prefix
    Options()

    class TextFormatDecodeData

    #include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
    namespace google::protobuf::compiler::objectivec

    Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform the input into the expected output.

    Members

    TextFormatDecodeData()
    ~TextFormatDecodeData()
    TextFormatDecodeData(const TextFormatDecodeData & )
    TextFormatDecodeData &
    operator=(const TextFormatDecodeData & )
    void
    AddString(int32 key, const std::string & input_for_decode, const std::string & desired_output)
    size_t
    num_entries() const
    std::string
    Data() const
    static std::string
    DecodeDataForString(const std::string & input_for_decode, const std::string & desired_output)

    class LineConsumer

    #include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
    namespace google::protobuf::compiler::objectivec

    Helper for parsing simple files.

    Members

    LineConsumer()
    virtual
    ~LineConsumer()
    virtual bool
    ConsumeLine(const StringPiece & line, std::string * out_error) = 0

    class ImportWriter

    #include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
    namespace google::protobuf::compiler::objectivec

    Helper class for parsing framework import mappings and generating import statements.

    Members

    ImportWriter(const std::string & generate_for_named_framework, const std::string & named_framework_to_proto_path_mappings_path, const std::string & runtime_import_prefix, bool include_wkt_imports)
    ~ImportWriter()
    void
    AddFile(const FileDescriptor * file, const std::string & header_extension)
    void
    Print(io::Printer * printer) const
    static void
    PrintRuntimeImports(io::Printer * printer, const std::vector< std::string > & header_to_import, const std::string & runtime_import_prefix, bool default_cpp_symbol = false)
    +

    std::string objectivec::FilePath(
            const FileDescriptor * file)

    Gets the path of the file we're going to generate (sans the .pb.h extension).

    The path will be dependent on the objectivec package declared in the proto package.

    +

    std::string objectivec::FileClassName(
            const FileDescriptor * file)

    Gets the name of the root class we'll generate in the file.

    This class is not meant for external consumption, but instead contains helpers that the rest of the classes need

    +

    bool objectivec::ValidateObjCClassPrefixes(
            const std::vector< const FileDescriptor * > & files,
            const Options & generation_options,
            std::string * out_error)

    Checks the prefix for the given files and outputs any warnings as needed.

    If there are flat out errors, then out_error is filled in with the first error and the result is false.

    +

    struct Options

    #include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
    namespace google::protobuf::compiler::objectivec

    Generator options (see objectivec_generator.cc for a description of each):

    Members

    std::string
    expected_prefixes_path
    std::vector< std::string >
    expected_prefixes_suppressions
    std::string
    generate_for_named_framework
    std::string
    named_framework_to_proto_path_mappings_path
    std::string
    runtime_import_prefix
    Options()

    class TextFormatDecodeData

    #include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
    namespace google::protobuf::compiler::objectivec

    Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform the input into the expected output.

    Members

    TextFormatDecodeData()
    ~TextFormatDecodeData()
    TextFormatDecodeData(const TextFormatDecodeData & )
    TextFormatDecodeData &
    operator=(const TextFormatDecodeData & )
    void
    AddString(int32 key, const std::string & input_for_decode, const std::string & desired_output)
    size_t
    num_entries() const
    std::string
    Data() const
    static std::string
    DecodeDataForString(const std::string & input_for_decode, const std::string & desired_output)

    class LineConsumer

    #include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
    namespace google::protobuf::compiler::objectivec

    Helper for parsing simple files.

    Members

    LineConsumer()
    virtual
    ~LineConsumer()
    virtual bool
    ConsumeLine(const StringPiece & line, std::string * out_error) = 0

    class ImportWriter

    #include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
    namespace google::protobuf::compiler::objectivec

    Helper class for parsing framework import mappings and generating import statements.

    Members

    ImportWriter(const std::string & generate_for_named_framework, const std::string & named_framework_to_proto_path_mappings_path, const std::string & runtime_import_prefix, bool include_wkt_imports)
    ~ImportWriter()
    void
    AddFile(const FileDescriptor * file, const std::string & header_extension)
    void
    Print(io::Printer * printer) const
    static void
    PrintRuntimeImports(io::Printer * printer, const std::vector< std::string > & header_to_import, const std::string & runtime_import_prefix, bool default_cpp_symbol = false)
    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 17de7af2..fbc0f641 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.parser.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.parser.md @@ -6,14 +6,14 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/parser.h>
    namespace google::protobuf::compiler

    Implements parsing of .proto files to FileDescriptorProtos.

    Classes in this file

    Implements parsing of protocol definitions (such as .proto files).
    A table mapping (descriptor, ErrorLocation) pairs – as reported by DescriptorPool when validating descriptors – to line and column numbers within the original source code.

    class Parser

    #include <google/protobuf/compiler/parser.h>
    namespace google::protobuf::compiler

    Implements parsing of protocol definitions (such as .proto files).

    Note that most users will be more interested in the Importer class. Parser is a lower-level class which simply converts a single .proto file to a FileDescriptorProto. It does not resolve import directives or perform many other kinds of validation needed to construct a complete FileDescriptor.

    +

    #include <google/protobuf/compiler/parser.h>
    namespace google::protobuf::compiler

    Implements parsing of .proto files to FileDescriptorProtos.

    Classes in this file

    Implements parsing of protocol definitions (such as .proto files).
    A table mapping (descriptor, ErrorLocation) pairs – as reported by DescriptorPool when validating descriptors – to line and column numbers within the original source code.

    class Parser

    #include <google/protobuf/compiler/parser.h>
    namespace google::protobuf::compiler

    Implements parsing of protocol definitions (such as .proto files).

    Note that most users will be more interested in the Importer class. Parser is a lower-level class which simply converts a single .proto file to a FileDescriptorProto. It does not resolve import directives or perform many other kinds of validation needed to construct a complete FileDescriptor.

    -

    Members

    Parser()
    ~Parser()
    bool
    Parse(io::Tokenizer * input, FileDescriptorProto * file)
    Parse the entire input and construct a FileDescriptorProto representing it. more...
    void
    RecordSourceLocationsTo(SourceLocationTable * location_table)
    DEPRECATED: New code should use the SourceCodeInfo embedded in the FileDescriptorProto. more...
    void
    RecordErrorsTo(io::ErrorCollector * error_collector)
    Requests that errors be recorded to the given ErrorCollector while parsing. more...
    const std::string &
    GetSyntaxIdentifier()
    Returns the identifier used in the "syntax = " declaration, if one was seen during the last call to Parse(), or the empty string otherwise.
    void
    SetRequireSyntaxIdentifier(bool value)
    If set true, input files will be required to begin with a syntax identifier. more...
    void
    SetStopAfterSyntaxIdentifier(bool value)
    Call SetStopAfterSyntaxIdentifier(true) to tell the parser to stop parsing as soon as it has seen the syntax identifier, or lack thereof. more...

    bool Parser::Parse(
            io::Tokenizer * input,
            FileDescriptorProto * file)

    Parse the entire input and construct a FileDescriptorProto representing it.

    Returns true if no errors occurred, false otherwise.

    -

    void Parser::RecordSourceLocationsTo(
            SourceLocationTable * location_table)

    DEPRECATED: New code should use the SourceCodeInfo embedded in the FileDescriptorProto.

    Requests that locations of certain definitions be recorded to the given SourceLocationTable while parsing. This can be used to look up exact line and column numbers for errors reported by DescriptorPool during validation. Set to NULL (the default) to discard source location information.

    -

    void Parser::RecordErrorsTo(
            io::ErrorCollector * error_collector)

    Requests that errors be recorded to the given ErrorCollector while parsing.

    Set to NULL (the default) to discard error messages.

    +

    Members

    Parser()
    ~Parser()
    bool
    Parse(io::Tokenizer * input, FileDescriptorProto * file)
    Parse the entire input and construct a FileDescriptorProto representing it. more...
    void
    RecordSourceLocationsTo(SourceLocationTable * location_table)
    DEPRECATED: New code should use the SourceCodeInfo embedded in the FileDescriptorProto. more...
    void
    RecordErrorsTo(io::ErrorCollector * error_collector)
    Requests that errors be recorded to the given ErrorCollector while parsing. more...
    const std::string &
    GetSyntaxIdentifier()
    Returns the identifier used in the "syntax = " declaration, if one was seen during the last call to Parse(), or the empty string otherwise.
    void
    SetRequireSyntaxIdentifier(bool value)
    If set true, input files will be required to begin with a syntax identifier. more...
    void
    SetStopAfterSyntaxIdentifier(bool value)
    Call SetStopAfterSyntaxIdentifier(true) to tell the parser to stop parsing as soon as it has seen the syntax identifier, or lack thereof. more...

    bool Parser::Parse(
            io::Tokenizer * input,
            FileDescriptorProto * file)

    Parse the entire input and construct a FileDescriptorProto representing it.

    Returns true if no errors occurred, false otherwise.

    +

    void Parser::RecordSourceLocationsTo(
            SourceLocationTable * location_table)

    DEPRECATED: New code should use the SourceCodeInfo embedded in the FileDescriptorProto.

    Requests that locations of certain definitions be recorded to the given SourceLocationTable while parsing. This can be used to look up exact line and column numbers for errors reported by DescriptorPool during validation. Set to NULL (the default) to discard source location information.

    +

    void Parser::RecordErrorsTo(
            io::ErrorCollector * error_collector)

    Requests that errors be recorded to the given ErrorCollector while parsing.

    Set to NULL (the default) to discard error messages.


    void Parser::SetRequireSyntaxIdentifier(
            bool value)

    If set true, input files will be required to begin with a syntax identifier.

    Otherwise, files may omit this. If a syntax identifier is provided, it must be 'syntax = "proto2";' and must appear at the top of this file regardless of whether or not it was required.


    void Parser::SetStopAfterSyntaxIdentifier(
            bool value)

    Call SetStopAfterSyntaxIdentifier(true) to tell the parser to stop parsing as soon as it has seen the syntax identifier, or lack thereof.

    This is useful for quickly identifying the syntax of the file without parsing the whole thing. If this is enabled, no error will be recorded if the syntax identifier is something other than "proto2" (since presumably the caller intends to deal with that), but other kinds of errors (e.g. parse errors) will still be reported. When this is enabled, you may pass a NULL FileDescriptorProto to Parse().

    -

    class SourceLocationTable

    #include <google/protobuf/compiler/parser.h>
    namespace google::protobuf::compiler

    A table mapping (descriptor, ErrorLocation) pairs – as reported by DescriptorPool when validating descriptors – to line and column numbers within the original source code.

    This is semi-obsolete: FileDescriptorProto.source_code_info now contains far more complete information about source locations. However, as of this writing you still need to use SourceLocationTable when integrating with DescriptorPool.

    -

    Members

    SourceLocationTable()
    ~SourceLocationTable()
    bool
    Find(const Message * descriptor, DescriptorPool::ErrorCollector::ErrorLocation location, int * line, int * column) const
    Finds the precise location of the given error and fills in *line and *column with the line and column numbers. more...
    bool
    FindImport(const Message * descriptor, const std::string & name, int * line, int * column) const
    void
    Add(const Message * descriptor, DescriptorPool::ErrorCollector::ErrorLocation location, int line, int column)
    Adds a location to the table.
    void
    AddImport(const Message * descriptor, const std::string & name, int line, int column)
    void
    Clear()
    Clears the contents of the table.

    bool SourceLocationTable::Find(
            const Message * descriptor,
            DescriptorPool::ErrorCollector::ErrorLocation location,
            int * line,
            int * column) const

    Finds the precise location of the given error and fills in *line and *column with the line and column numbers.

    If not found, sets *line to -1 and *column to 0 (since line = -1 is used to mean "error has no exact +

    class SourceLocationTable

    #include <google/protobuf/compiler/parser.h>
    namespace google::protobuf::compiler

    A table mapping (descriptor, ErrorLocation) pairs – as reported by DescriptorPool when validating descriptors – to line and column numbers within the original source code.

    This is semi-obsolete: FileDescriptorProto.source_code_info now contains far more complete information about source locations. However, as of this writing you still need to use SourceLocationTable when integrating with DescriptorPool.

    +

    Members

    SourceLocationTable()
    ~SourceLocationTable()
    bool
    Find(const Message * descriptor, DescriptorPool::ErrorCollector::ErrorLocation location, int * line, int * column) const
    Finds the precise location of the given error and fills in *line and *column with the line and column numbers. more...
    bool
    FindImport(const Message * descriptor, const std::string & name, int * line, int * column) const
    void
    Add(const Message * descriptor, DescriptorPool::ErrorCollector::ErrorLocation location, int line, int column)
    Adds a location to the table.
    void
    AddImport(const Message * descriptor, const std::string & name, int line, int column)
    void
    Clear()
    Clears the contents of the table.

    bool SourceLocationTable::Find(
            const Message * descriptor,
            DescriptorPool::ErrorCollector::ErrorLocation location,
            int * line,
            int * column) const

    Finds the precise location of the given error and fills in *line and *column with the line and column numbers.

    If not found, sets *line to -1 and *column to 0 (since line = -1 is used to mean "error has no exact location" in the ErrorCollector interface). Returns true if found, false otherwise.

    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 61bc007f..a14d1473 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.plugin.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.plugin.md @@ -6,7 +6,7 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/plugin.h>
    namespace google::protobuf::compiler

    Front-end for protoc code generator plugins written in C++.

    To implement a protoc plugin in C++, simply write an implementation of CodeGenerator, then create a main() function like:

    +

    #include <google/protobuf/compiler/plugin.h>
    namespace google::protobuf::compiler

    Front-end for protoc code generator plugins written in C++.

    To implement a protoc plugin in C++, simply write an implementation of CodeGenerator, then create a main() function like:

    int main(int argc, char* argv[]) {
       MyCodeGenerator generator;
    @@ -15,7 +15,7 @@ type = "docs"
     
     

    You must link your plugin against libprotobuf and libprotoc.

    -

    The core part of PluginMain is to invoke the given CodeGenerator on a CodeGeneratorRequest to generate a CodeGeneratorResponse. This part is abstracted out and made into function GenerateCode so that it can be reused, for example, to implement a variant of PluginMain that does some preprocessing on the input CodeGeneratorRequest before feeding the request to the given code generator.

    +

    The core part of PluginMain is to invoke the given CodeGenerator on a CodeGeneratorRequest to generate a CodeGeneratorResponse. This part is abstracted out and made into function GenerateCode so that it can be reused, for example, to implement a variant of PluginMain that does some preprocessing on the input CodeGeneratorRequest before feeding the request to the given code generator.

    To get protoc to use the plugin, do one of the following:

    @@ -29,5 +29,5 @@ type = "docs" -

    Classes in this file

    File Members

    These definitions are not part of any class.
    int
    PluginMain(int argc, char * argv, const CodeGenerator * generator)
    Implements main() for a protoc plugin exposing the given code generator.
    bool
    GenerateCode(const CodeGeneratorRequest & request, const CodeGenerator & generator, CodeGeneratorResponse * response, std::string * error_msg)
    Generates code using the given code generator. more...

    bool compiler::GenerateCode(
            const CodeGeneratorRequest & request,
            const CodeGenerator & generator,
            CodeGeneratorResponse * response,
            std::string * error_msg)

    Generates code using the given code generator.

    Returns true if the code generation is successful. If the code generation fails, error_msg may be populated to describe the failure cause.

    +

    Classes in this file

    File Members

    These definitions are not part of any class.
    int
    PluginMain(int argc, char * argv, const CodeGenerator * generator)
    Implements main() for a protoc plugin exposing the given code generator.
    bool
    GenerateCode(const CodeGeneratorRequest & request, const CodeGenerator & generator, CodeGeneratorResponse * response, std::string * error_msg)
    Generates code using the given code generator. more...

    bool compiler::GenerateCode(
            const CodeGeneratorRequest & request,
            const CodeGenerator & generator,
            CodeGeneratorResponse * response,
            std::string * error_msg)

    Generates code using the given code generator.

    Returns true if the code generation is successful. If the code generation fails, error_msg may be populated to describe the failure cause.

    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 37ce5409..c545ad51 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 @@ -6,7 +6,7 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/compiler/plugin.pb.h>
    namespace google::protobuf::compiler

    API for protoc plugins.

    This file defines a set of protocol message classes which make up the API to protoc code generator plugins. Plugins written in C++ should probably build on the API in plugin.h instead of dealing with the protobuf-level API, but plugins in other languages will need to deal with the raw messages as defined below.

    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 plugin.proto, whose contents are as follows:

    +

    #include <google/protobuf/compiler/plugin.pb.h>
    namespace google::protobuf::compiler

    API for protoc plugins.

    This file defines a set of protocol message classes which make up the API to protoc code generator plugins. Plugins written in C++ should probably build on the API in plugin.h instead of dealing with the protobuf-level API, but plugins in other languages will need to deal with the raw messages as defined below.

    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 plugin.proto, whose contents are as follows:

    // Protocol Buffers - Google's data interchange format
     // Copyright 2008 Google Inc.  All rights reserved.
    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 d8cad39d..dc8d7c05 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
    @@ -6,7 +6,7 @@ description = "This section contains reference documentation for working with Pr
     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 Protobuf classes.

    class Generator: public CodeGenerator

    #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.

    +

    #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.

    class Generator: public CodeGenerator

    #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) const
    CodeGenerator methods.
    virtual uint64_t
    GetSupportedFeatures() const
    Implement this to indicate what features this code generator supports. more...

    virtual uint64_t Generator::GetSupportedFeatures() const

    Implement this to indicate what features this code generator supports.

    This should be a bitwise OR of features from the Features enum in plugin.proto.

    +

    Members

    Generator()
    virtual
    ~Generator()
    virtual bool
    Generate(const FileDescriptor * file, const std::string & parameter, GeneratorContext * generator_context, std::string * error) const
    CodeGenerator methods.
    virtual uint64_t
    GetSupportedFeatures() const
    Implement this to indicate what features this code generator supports. more...

    virtual uint64_t Generator::GetSupportedFeatures() const

    Implement this to indicate what features this code generator supports.

    This should be a bitwise OR of features from the Features enum in plugin.proto.

    diff --git a/content/reference/cpp/api-docs/google.protobuf.compiler.ruby_generator.md b/content/reference/cpp/api-docs/google.protobuf.compiler.ruby_generator.md index 29e95017..6c5e8a06 100644 --- a/content/reference/cpp/api-docs/google.protobuf.compiler.ruby_generator.md +++ b/content/reference/cpp/api-docs/google.protobuf.compiler.ruby_generator.md @@ -8,6 +8,6 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #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.

    class Generator: public CodeGenerator

    #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.

    +

    #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.

    class Generator: public CodeGenerator

    #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

    diff --git a/content/reference/cpp/api-docs/google.protobuf.descriptor.md b/content/reference/cpp/api-docs/google.protobuf.descriptor.md index 3680f7cf..b255c116 100644 --- a/content/reference/cpp/api-docs/google.protobuf.descriptor.md +++ b/content/reference/cpp/api-docs/google.protobuf.descriptor.md @@ -6,15 +6,15 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    This file contains classes which describe a type of protocol message.

    You can use a message's descriptor to learn at runtime what fields it contains and what the types of those fields are. The Message interface also allows you to dynamically access and modify individual fields by passing the FieldDescriptor of the field you are interested in.

    +

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    This file contains classes which describe a type of protocol message.

    You can use a message's descriptor to learn at runtime what fields it contains and what the types of those fields are. The Message interface also allows you to dynamically access and modify individual fields by passing the FieldDescriptor of the field you are interested in.

    -

    Most users will not care about descriptors, because they will write code specific to certain protocol types and will simply use the classes generated by the protocol compiler directly. Advanced users who want to operate on arbitrary types (not known at compile time) may want to read descriptors in order to learn about the contents of a message. A very small number of users will want to construct their own Descriptors, either because they are implementing Message manually or because they are writing something like the protocol compiler.

    +

    Most users will not care about descriptors, because they will write code specific to certain protocol types and will simply use the classes generated by the protocol compiler directly. Advanced users who want to operate on arbitrary types (not known at compile time) may want to read descriptors in order to learn about the contents of a message. A very small number of users will want to construct their own Descriptors, either because they are implementing Message manually or because they are writing something like the protocol compiler.

    -

    For an example of how you might use descriptors, see the code example at the top of message.h.

    +

    For an example of how you might use descriptors, see the code example at the top of message.h.

    -

    Classes in this file

    NB, all indices are zero-based.
    Options when generating machine-parsable output from a descriptor with DebugString().
    Describes a type of protocol message, or a particular group within a message.
    A range of field numbers which are designated for third-party extensions.
    A range of reserved field numbers.
    Describes a single field of a message.
    Describes a oneof defined in a message type.
    Describes an enum type defined in a .proto file.
    A range of reserved field numbers.
    Describes an individual enum constant of a particular type.
    Describes an RPC service.
    Describes an individual service method.
    Describes a whole .proto file.
    Used to construct descriptors.
    When converting a FileDescriptorProto to a FileDescriptor, various errors might be detected in the input.

    struct SourceLocation

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    NB, all indices are zero-based.

    Members

    int
    start_line
    int
    end_line
    int
    start_column
    int
    end_column
    std::string
    leading_comments
    Doc comments found at the source location. more...
    std::string
    trailing_comments
    std::vector< std::string >
    leading_detached_comments

    std::string SourceLocation::leading_comments

    Doc comments found at the source location.

    See the comments in SourceCodeInfo.Location (descriptor.proto) for details.

    -

    struct DebugStringOptions

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Options when generating machine-parsable output from a descriptor with DebugString().

    Members

    bool
    include_comments
    include original user comments as recorded in SourceLocation entries. more...
    bool
    elide_group_body
    If true, elide the braced body in the debug string.
    bool
    elide_oneof_body
    DebugStringOptions()

    bool DebugStringOptions::include_comments

    include original user comments as recorded in SourceLocation entries.

    N.B. that this must be |false| by default: several other pieces of code (for example, the C++ code generation for fields in the proto compiler) rely on DebugString() output being unobstructed by user comments.

    -

    class Descriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes a type of protocol message, or a particular group within a message.

    To obtain the Descriptor for a given message object, call Message::GetDescriptor(). Generated message classes also have a static method called descriptor() which returns the type's descriptor. Use DescriptorPool to construct your own descriptors.

    +

    Classes in this file

    NB, all indices are zero-based.
    Options when generating machine-parsable output from a descriptor with DebugString().
    Describes a type of protocol message, or a particular group within a message.
    A range of field numbers which are designated for third-party extensions.
    A range of reserved field numbers.
    Describes a single field of a message.
    Describes a oneof defined in a message type.
    Describes an enum type defined in a .proto file.
    A range of reserved field numbers.
    Describes an individual enum constant of a particular type.
    Describes an RPC service.
    Describes an individual service method.
    Describes a whole .proto file.
    Used to construct descriptors.
    When converting a FileDescriptorProto to a FileDescriptor, various errors might be detected in the input.

    struct SourceLocation

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    NB, all indices are zero-based.

    Members

    int
    start_line
    int
    end_line
    int
    start_column
    int
    end_column
    std::string
    leading_comments
    Doc comments found at the source location. more...
    std::string
    trailing_comments
    std::vector< std::string >
    leading_detached_comments

    std::string SourceLocation::leading_comments

    Doc comments found at the source location.

    See the comments in SourceCodeInfo.Location (descriptor.proto) for details.

    +

    struct DebugStringOptions

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Options when generating machine-parsable output from a descriptor with DebugString().

    Members

    bool
    include_comments
    include original user comments as recorded in SourceLocation entries. more...
    bool
    elide_group_body
    If true, elide the braced body in the debug string.
    bool
    elide_oneof_body
    DebugStringOptions()

    bool DebugStringOptions::include_comments

    include original user comments as recorded in SourceLocation entries.

    N.B. that this must be |false| by default: several other pieces of code (for example, the C++ code generation for fields in the proto compiler) rely on DebugString() output being unobstructed by user comments.

    +

    class Descriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes a type of protocol message, or a particular group within a message.

    To obtain the Descriptor for a given message object, call Message::GetDescriptor(). Generated message classes also have a static method called descriptor() which returns the type's descriptor. Use DescriptorPool to construct your own descriptors.

    Members

    enum
    WellKnownType
    typedef
    DescriptorProto Proto
    const std::string &
    name() const
    The name of the message type, not including its scope.
    const std::string &
    full_name() const
    The fully-qualified name of the message type, scope delimited by periods. more...
    int
    index() const
    Index of this descriptor within the file or containing type's message type array.
    const FileDescriptor *
    file() const
    The .proto file in which this message type was defined. Never nullptr.
    const Descriptor *
    containing_type() const
    If this Descriptor describes a nested type, this returns the type in which it is nested. more...
    const MessageOptions &
    options() const
    Get options for this message type. more...
    void
    CopyTo(DescriptorProto * proto) const
    Write the contents of this Descriptor into the given DescriptorProto. more...
    std::string
    DebugString() const
    Write the contents of this descriptor in a human-readable form. more...
    std::string
    DebugStringWithOptions(const DebugStringOptions & options) const
    Similar to DebugString(), but additionally takes options (e.g., include original user comments in output).
    bool
    is_placeholder() const
    Returns true if this is a placeholder for an unknown type. more...
    WellKnownType
    well_known_type() const

    Field stuff

    int
    field_count() const
    The number of fields in this message type.
    const FieldDescriptor *
    field(int index) const
    Gets a field by index, where 0 <= index < field_count(). more...
    const FieldDescriptor *
    FindFieldByNumber(int number) const
    Looks up a field by declared tag number. more...
    const FieldDescriptor *
    FindFieldByName(ConstStringParam name) const
    Looks up a field by name. Returns nullptr if no such field exists.
    const FieldDescriptor *
    FindFieldByLowercaseName(ConstStringParam lowercase_name) const
    Looks up a field by lowercased name (as returned by lowercase_name()). more...
    const FieldDescriptor *
    FindFieldByCamelcaseName(ConstStringParam camelcase_name) const
    Looks up a field by camel-case name (as returned by camelcase_name()). more...
    int
    oneof_decl_count() const
    The number of oneofs in this message type.
    int
    real_oneof_decl_count() const
    The number of oneofs in this message type, excluding synthetic oneofs. more...
    const OneofDescriptor *
    oneof_decl(int index) const
    Get a oneof by index, where 0 <= index < oneof_decl_count(). more...
    const OneofDescriptor *
    FindOneofByName(ConstStringParam name) const
    Looks up a oneof by name. Returns nullptr if no such oneof exists.

    Nested type stuff

    int
    nested_type_count() const
    The number of nested types in this message type.
    const Descriptor *
    nested_type(int index) const
    Gets a nested type by index, where 0 <= index < nested_type_count(). more...
    const Descriptor *
    FindNestedTypeByName(ConstStringParam name) const
    Looks up a nested type by name. more...

    Enum stuff

    int
    enum_type_count() const
    The number of enum types in this message type.
    const EnumDescriptor *
    enum_type(int index) const
    Gets an enum type by index, where 0 <= index < enum_type_count(). more...
    const EnumDescriptor *
    FindEnumTypeByName(ConstStringParam name) const
    Looks up an enum type by name. more...
    const EnumValueDescriptor *
    FindEnumValueByName(ConstStringParam name) const
    Looks up an enum value by name, among all enum types in this message. more...

    Extensions

    int
    extension_range_count() const
    The number of extension ranges in this message type.
    const ExtensionRange *
    extension_range(int index) const
    Gets an extension range by index, where 0 <= index < extension_range_count(). more...
    bool
    IsExtensionNumber(int number) const
    Returns true if the number is in one of the extension ranges.
    const ExtensionRange *
    FindExtensionRangeContainingNumber(int number) const
    Returns nullptr if no extension range contains the given number.
    int
    extension_count() const
    The number of extensions defined nested within this message type's scope. more...
    const FieldDescriptor *
    extension(int index) const
    Get an extension by index, where 0 <= index < extension_count(). more...
    const FieldDescriptor *
    FindExtensionByName(ConstStringParam name) const
    Looks up a named extension (which extends some other message type) defined within this message type's scope.
    const FieldDescriptor *
    FindExtensionByLowercaseName(ConstStringParam name) const
    Similar to FindFieldByLowercaseName(), but finds extensions defined within this message type's scope.
    const FieldDescriptor *
    FindExtensionByCamelcaseName(ConstStringParam name) const
    Similar to FindFieldByCamelcaseName(), but finds extensions defined within this message type's scope.

    Reserved fields

    int
    reserved_range_count() const
    The number of reserved ranges in this message type.
    const ReservedRange *
    reserved_range(int index) const
    Gets an reserved range by index, where 0 <= index < reserved_range_count(). more...
    bool
    IsReservedNumber(int number) const
    Returns true if the number is in one of the reserved ranges.
    const ReservedRange *
    FindReservedRangeContainingNumber(int number) const
    Returns nullptr if no reserved range contains the given number.
    int
    reserved_name_count() const
    The number of reserved field names in this message type.
    const std::string &
    reserved_name(int index) const
    Gets a reserved name by index, where 0 <= index < reserved_name_count(). more...
    bool
    IsReservedName(ConstStringParam name) const
    Returns true if the field name is reserved.

    Source Location

    bool
    GetSourceLocation(SourceLocation * out_location) const
    Updates |*out_location| to the source location of the complete extent of this message declaration. more...

    Maps

    const FieldDescriptor *
    map_key() const
    Returns the FieldDescriptor for the "key" field. more...
    const FieldDescriptor *
    map_value() const
    Returns the FieldDescriptor for the "value" field. more...

    enum Descriptor::WellKnownType {
      WELLKNOWNTYPE_UNSPECIFIED,
      WELLKNOWNTYPE_DOUBLEVALUE,
      WELLKNOWNTYPE_FLOATVALUE,
      WELLKNOWNTYPE_INT64VALUE,
      WELLKNOWNTYPE_UINT64VALUE,
      WELLKNOWNTYPE_INT32VALUE,
      WELLKNOWNTYPE_UINT32VALUE,
      WELLKNOWNTYPE_STRINGVALUE,
      WELLKNOWNTYPE_BYTESVALUE,
      WELLKNOWNTYPE_BOOLVALUE,
      WELLKNOWNTYPE_ANY,
      WELLKNOWNTYPE_FIELDMASK,
      WELLKNOWNTYPE_DURATION,
      WELLKNOWNTYPE_TIMESTAMP,
      WELLKNOWNTYPE_VALUE,
      WELLKNOWNTYPE_LISTVALUE,
      WELLKNOWNTYPE_STRUCT,
      **WELLKNOWNTYPE**DO_NOT_USE__ADD_DEFAULT_INSTEAD__
    }

    WELLKNOWNTYPE_UNSPECIFIEDNot a well-known type.
    WELLKNOWNTYPE_DOUBLEVALUE

    Wrapper types.

    google.protobuf.DoubleValue

    WELLKNOWNTYPE_FLOATVALUEgoogle.protobuf.FloatValue
    WELLKNOWNTYPE_INT64VALUEgoogle.protobuf.Int64Value
    WELLKNOWNTYPE_UINT64VALUEgoogle.protobuf.UInt64Value
    WELLKNOWNTYPE_INT32VALUEgoogle.protobuf.Int32Value
    WELLKNOWNTYPE_UINT32VALUEgoogle.protobuf.UInt32Value
    WELLKNOWNTYPE_STRINGVALUEgoogle.protobuf.StringValue
    WELLKNOWNTYPE_BYTESVALUEgoogle.protobuf.BytesValue
    WELLKNOWNTYPE_BOOLVALUEgoogle.protobuf.BoolValue
    WELLKNOWNTYPE_ANY

    Other well known types.

    google.protobuf.Any

    WELLKNOWNTYPE_FIELDMASKgoogle.protobuf.FieldMask
    WELLKNOWNTYPE_DURATIONgoogle.protobuf.Duration
    WELLKNOWNTYPE_TIMESTAMPgoogle.protobuf.Timestamp
    WELLKNOWNTYPE_VALUEgoogle.protobuf.Value
    WELLKNOWNTYPE_LISTVALUEgoogle.protobuf.ListValue
    WELLKNOWNTYPE_STRUCTgoogle.protobuf.Struct
    **WELLKNOWNTYPE**DO_NOT_USE__ADD_DEFAULT_INSTEAD__

    New well-known types may be added in the future.

    Please make sure any switch() statements have a 'default' case.


    const std::string &
        Descriptor::full_name() const

    The fully-qualified name of the message type, scope delimited by periods.

    For example, message type "Foo" which is declared in package "bar" has full name "bar.Foo". If a type "Baz" is nested within Foo, Baz's full_name is "bar.Foo.Baz". To get only the part that comes after the last '.', use name().


    const Descriptor *
        Descriptor::containing_type() const

    If this Descriptor describes a nested type, this returns the type in which it is nested.

    Otherwise, returns nullptr.

    @@ -54,12 +54,12 @@ type = "docs"

    bool Descriptor::GetSourceLocation(
            SourceLocation * out_location) const

    Updates |*out_location| to the source location of the complete extent of this message declaration.

    Returns false and leaves |*out_location| unchanged iff location information was not available.


    const FieldDescriptor *
        Descriptor::map_key() const

    Returns the FieldDescriptor for the "key" field.

    If this isn't a map entry field, returns nullptr.


    const FieldDescriptor *
        Descriptor::map_value() const

    Returns the FieldDescriptor for the "value" field.

    If this isn't a map entry field, returns nullptr.

    -

    struct Descriptor::ExtensionRange

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    A range of field numbers which are designated for third-party extensions.

    Members

    typedef
    DescriptorProto_ExtensionRange Proto
    typedef
    ExtensionRangeOptions OptionsType
    int
    start
    inclusive
    int
    end
    exclusive
    const ExtensionRangeOptions *
    options_
    void
    CopyTo(DescriptorProto_ExtensionRange * proto) const

    struct Descriptor::ReservedRange

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    A range of reserved field numbers.

    Members

    int
    start
    inclusive
    int
    end
    exclusive

    class FieldDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes a single field of a message.

    To get the descriptor for a given field, first get the Descriptor for the message in which it is defined, then call Descriptor::FindFieldByName(). To get a FieldDescriptor for an extension, do one of the following:

    +

    struct Descriptor::ExtensionRange

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    A range of field numbers which are designated for third-party extensions.

    Members

    typedef
    DescriptorProto_ExtensionRange Proto
    typedef
    ExtensionRangeOptions OptionsType
    int
    start
    inclusive
    int
    end
    exclusive
    const ExtensionRangeOptions *
    options_
    void
    CopyTo(DescriptorProto_ExtensionRange * proto) const

    struct Descriptor::ReservedRange

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    A range of reserved field numbers.

    Members

    int
    start
    inclusive
    int
    end
    exclusive

    class FieldDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes a single field of a message.

    To get the descriptor for a given field, first get the Descriptor for the message in which it is defined, then call Descriptor::FindFieldByName(). To get a FieldDescriptor for an extension, do one of the following:

    -

    Members

    enum
    Type
    Identifies a field type. more...
    enum
    CppType
    Specifies the C++ data type used to represent the field. more...
    enum
    Label
    Identifies whether the field is optional, required, or repeated. more...
    typedef
    FieldDescriptorProto Proto
    const int
    kMaxNumber = = (1 << 29) - 1
    Valid field numbers are positive integers up to kMaxNumber.
    const int
    kFirstReservedNumber = = 19000
    First field number reserved for the Protobuf library implementation. more...
    const int
    kLastReservedNumber = = 19999
    Last 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() const
    Name of this field within the message.
    const std::string &
    full_name() const
    Fully-qualified name of the field.
    const std::string &
    json_name() const
    JSON name of this field.
    const FileDescriptor *
    file() const
    File in which this field was defined.
    bool
    is_extension() const
    Is this an extension field?
    int
    number() const
    Declared tag number.
    const std::string &
    lowercase_name() const
    Same as name() except converted to lower-case. more...
    const std::string &
    camelcase_name() const
    Same as name() except converted to camel-case. more...
    Type
    type() const
    Declared type of this field.
    const char *
    type_name() const
    Name of the declared type.
    CppType
    cpp_type() const
    C++ type of this field.
    const char *
    cpp_type_name() const
    Name of the C++ type.
    Label
    label() const
    optional/required/repeated
    bool
    is_required() const
    shorthand for label() == LABEL_REQUIRED
    bool
    is_optional() const
    shorthand for label() == LABEL_OPTIONAL
    bool
    is_repeated() const
    shorthand for label() == LABEL_REPEATED
    bool
    is_packable() const
    shorthand for is_repeated() && IsTypePackable(type())
    bool
    is_packed() const
    shorthand for is_packable() && options().packed()
    bool
    is_map() const
    shorthand for type() == TYPE_MESSAGE && message_type()->options().map_entry()
    bool
    has_optional_keyword() const
    Returns true if this field was syntactically written with "optional" in the .proto file. more...
    bool
    has_presence() const
    Returns true if this field tracks presence, ie. more...
    int
    index() const
    Index of this field within the message's field array, or the file or extension scope's extensions array.
    bool
    has_default_value() const
    Does this field have an explicitly-declared default value?
    bool
    has_json_name() const
    Whether the user has specified the json_name field option in the .proto file.
    int32
    default_value_int32() const
    Get the field default value if cpp_type() == CPPTYPE_INT32. more...
    int64
    default_value_int64() const
    Get the field default value if cpp_type() == CPPTYPE_INT64. more...
    uint32
    default_value_uint32() const
    Get the field default value if cpp_type() == CPPTYPE_UINT32. more...
    uint64
    default_value_uint64() const
    Get the field default value if cpp_type() == CPPTYPE_UINT64. more...
    float
    default_value_float() const
    Get the field default value if cpp_type() == CPPTYPE_FLOAT. more...
    double
    default_value_double() const
    Get the field default value if cpp_type() == CPPTYPE_DOUBLE. more...
    bool
    default_value_bool() const
    Get the field default value if cpp_type() == CPPTYPE_BOOL. more...
    const EnumValueDescriptor *
    default_value_enum() const
    Get the field default value if cpp_type() == CPPTYPE_ENUM. more...
    const std::string &
    default_value_string() const
    Get the field default value if cpp_type() == CPPTYPE_STRING. more...
    const Descriptor *
    containing_type() const
    The Descriptor for the message of which this is a field. more...
    const OneofDescriptor *
    containing_oneof() const
    If the field is a member of a oneof, this is the one, otherwise this is nullptr.
    const OneofDescriptor *
    real_containing_oneof() const
    If the field is a member of a non-synthetic oneof, returns the descriptor for the oneof, otherwise returns nullptr.
    int
    index_in_oneof() const
    If the field is a member of a oneof, returns the index in that oneof.
    const Descriptor *
    extension_scope() const
    An extension may be declared within the scope of another message. more...
    const Descriptor *
    message_type() const
    If type is TYPE_MESSAGE or TYPE_GROUP, returns a descriptor for the message or the group type. more...
    const EnumDescriptor *
    enum_type() const
    If type is TYPE_ENUM, returns a descriptor for the enum. more...
    const FieldOptions &
    options() const
    Get the FieldOptions for this field. more...
    void
    CopyTo(FieldDescriptorProto * proto) const
    std::string
    DebugString() const
    std::string
    DebugStringWithOptions(const DebugStringOptions & options) const
    const std::string &
    PrintableNameForExtension() const
    Returns 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) const
    Updates |*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
    Type
    Identifies a field type. more...
    enum
    CppType
    Specifies the C++ data type used to represent the field. more...
    enum
    Label
    Identifies whether the field is optional, required, or repeated. more...
    typedef
    FieldDescriptorProto Proto
    const int
    kMaxNumber = = (1 << 29) - 1
    Valid field numbers are positive integers up to kMaxNumber.
    const int
    kFirstReservedNumber = = 19000
    First field number reserved for the Protobuf library implementation. more...
    const int
    kLastReservedNumber = = 19999
    Last 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() const
    Name of this field within the message.
    const std::string &
    full_name() const
    Fully-qualified name of the field.
    const std::string &
    json_name() const
    JSON name of this field.
    const FileDescriptor *
    file() const
    File in which this field was defined.
    bool
    is_extension() const
    Is this an extension field?
    int
    number() const
    Declared tag number.
    const std::string &
    lowercase_name() const
    Same as name() except converted to lower-case. more...
    const std::string &
    camelcase_name() const
    Same as name() except converted to camel-case. more...
    Type
    type() const
    Declared type of this field.
    const char *
    type_name() const
    Name of the declared type.
    CppType
    cpp_type() const
    C++ type of this field.
    const char *
    cpp_type_name() const
    Name of the C++ type.
    Label
    label() const
    optional/required/repeated
    bool
    is_required() const
    shorthand for label() == LABEL_REQUIRED
    bool
    is_optional() const
    shorthand for label() == LABEL_OPTIONAL
    bool
    is_repeated() const
    shorthand for label() == LABEL_REPEATED
    bool
    is_packable() const
    shorthand for is_repeated() && IsTypePackable(type())
    bool
    is_packed() const
    shorthand for is_packable() && options().packed()
    bool
    is_map() const
    shorthand for type() == TYPE_MESSAGE && message_type()->options().map_entry()
    bool
    has_optional_keyword() const
    Returns true if this field was syntactically written with "optional" in the .proto file. more...
    bool
    has_presence() const
    Returns true if this field tracks presence, ie. more...
    int
    index() const
    Index of this field within the message's field array, or the file or extension scope's extensions array.
    bool
    has_default_value() const
    Does this field have an explicitly-declared default value?
    bool
    has_json_name() const
    Whether the user has specified the json_name field option in the .proto file.
    int32
    default_value_int32() const
    Get the field default value if cpp_type() == CPPTYPE_INT32. more...
    int64
    default_value_int64() const
    Get the field default value if cpp_type() == CPPTYPE_INT64. more...
    uint32
    default_value_uint32() const
    Get the field default value if cpp_type() == CPPTYPE_UINT32. more...
    uint64
    default_value_uint64() const
    Get the field default value if cpp_type() == CPPTYPE_UINT64. more...
    float
    default_value_float() const
    Get the field default value if cpp_type() == CPPTYPE_FLOAT. more...
    double
    default_value_double() const
    Get the field default value if cpp_type() == CPPTYPE_DOUBLE. more...
    bool
    default_value_bool() const
    Get the field default value if cpp_type() == CPPTYPE_BOOL. more...
    const EnumValueDescriptor *
    default_value_enum() const
    Get the field default value if cpp_type() == CPPTYPE_ENUM. more...
    const std::string &
    default_value_string() const
    Get the field default value if cpp_type() == CPPTYPE_STRING. more...
    const Descriptor *
    containing_type() const
    The Descriptor for the message of which this is a field. more...
    const OneofDescriptor *
    containing_oneof() const
    If the field is a member of a oneof, this is the one, otherwise this is nullptr.
    const OneofDescriptor *
    real_containing_oneof() const
    If the field is a member of a non-synthetic oneof, returns the descriptor for the oneof, otherwise returns nullptr.
    int
    index_in_oneof() const
    If the field is a member of a oneof, returns the index in that oneof.
    const Descriptor *
    extension_scope() const
    An extension may be declared within the scope of another message. more...
    const Descriptor *
    message_type() const
    If type is TYPE_MESSAGE or TYPE_GROUP, returns a descriptor for the message or the group type. more...
    const EnumDescriptor *
    enum_type() const
    If type is TYPE_ENUM, returns a descriptor for the enum. more...
    const FieldOptions &
    options() const
    Get the FieldOptions for this field. more...
    void
    CopyTo(FieldDescriptorProto * proto) const
    std::string
    DebugString() const
    std::string
    DebugStringWithOptions(const DebugStringOptions & options) const
    const std::string &
    PrintableNameForExtension() const
    Returns 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) const
    Updates |*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_DOUBLEdouble, exactly eight bytes on the wire.
    TYPE_FLOATfloat, 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_UINT64uint64, 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_FIXED64uint64, exactly eight bytes on the wire.
    TYPE_FIXED32uint32, exactly four bytes on the wire.
    TYPE_BOOLbool, varint on the wire.
    TYPE_STRINGUTF-8 text.
    TYPE_GROUPTag-delimited message. Deprecated.
    TYPE_MESSAGELength-delimited message.
    TYPE_BYTESArbitrary byte array.
    TYPE_UINT32uint32, varint on the wire
    TYPE_ENUMEnum, varint on the wire.
    TYPE_SFIXED32int32, exactly four bytes on the wire
    TYPE_SFIXED64int64, exactly eight bytes on the wire
    TYPE_SINT32int32, ZigZag-encoded varint on the wire
    TYPE_SINT64int64, ZigZag-encoded varint on the wire
    MAX_TYPEConstant 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.

    @@ -74,7 +74,7 @@ fooBar -> fooBar

    This (and especially the FindFieldByCamelcaseName() method) can be useful when parsing formats which prefer to use camel-case naming style.


    bool FieldDescriptor::has_optional_keyword() const

    Returns true if this field was syntactically written with "optional" in the .proto file.

    Excludes singular proto3 fields that do not have a label.


    bool FieldDescriptor::has_presence() const

    Returns true if this field tracks presence, ie.

    does the field distinguish between "unset" and "present with default value." This includes required, optional, and oneof fields. It excludes maps, repeated fields, and singular proto3 fields without "optional".

    -

    For fields where has_presence() == true, the return value of Reflection::HasField() is semantically meaningful.

    +

    For fields where has_presence() == true, the return value of Reflection::HasField() is semantically meaningful.


    int32 FieldDescriptor::default_value_int32() const

    Get the field default value if cpp_type() == CPPTYPE_INT32.

    If no explicit default was defined, the default is 0.


    int64 FieldDescriptor::default_value_int64() const

    Get the field default value if cpp_type() == CPPTYPE_INT64.

    If no explicit default was defined, the default is 0.


    uint32 FieldDescriptor::default_value_uint32() const

    Get the field default value if cpp_type() == CPPTYPE_UINT32.

    If no explicit default was defined, the default is 0.

    @@ -96,11 +96,11 @@ fooBar -> fooBar
    message->file()->pool()->FindExtensionByPrintableName(message, name)

    where the extension extends "message".


    bool FieldDescriptor::GetSourceLocation(
            SourceLocation * out_location) const

    Updates |*out_location| to the source location of the complete extent of this field declaration.

    Returns false and leaves |*out_location| unchanged iff location information was not available.

    -

    class OneofDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes a oneof defined in a message type.

    Members

    typedef
    OneofDescriptorProto Proto
    const std::string &
    name() const
    Name of this oneof.
    const std::string &
    full_name() const
    Fully-qualified name of the oneof.
    int
    index() const
    Index of this oneof within the message's oneof array.
    bool
    is_synthetic() const
    Returns whether this oneof was inserted by the compiler to wrap a proto3 optional field. more...
    const FileDescriptor *
    file() const
    The .proto file in which this oneof was defined. Never nullptr.
    const Descriptor *
    containing_type() const
    The Descriptor for the message containing this oneof.
    int
    field_count() const
    The number of (non-extension) fields which are members of this oneof.
    const FieldDescriptor *
    field(int index) const
    Get a member of this oneof, in the order in which they were declared in the .proto file. more...
    const OneofOptions &
    options() const
    void
    CopyTo(OneofDescriptorProto * proto) const
    std::string
    DebugString() const
    std::string
    DebugStringWithOptions(const DebugStringOptions & options) const

    Source Location

    bool
    GetSourceLocation(SourceLocation * out_location) const
    Updates |*out_location| to the source location of the complete extent of this oneof declaration. more...

    bool OneofDescriptor::is_synthetic() const

    Returns whether this oneof was inserted by the compiler to wrap a proto3 optional field.

    If this returns true, code generators should not emit it.

    +

    class OneofDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes a oneof defined in a message type.

    Members

    typedef
    OneofDescriptorProto Proto
    const std::string &
    name() const
    Name of this oneof.
    const std::string &
    full_name() const
    Fully-qualified name of the oneof.
    int
    index() const
    Index of this oneof within the message's oneof array.
    bool
    is_synthetic() const
    Returns whether this oneof was inserted by the compiler to wrap a proto3 optional field. more...
    const FileDescriptor *
    file() const
    The .proto file in which this oneof was defined. Never nullptr.
    const Descriptor *
    containing_type() const
    The Descriptor for the message containing this oneof.
    int
    field_count() const
    The number of (non-extension) fields which are members of this oneof.
    const FieldDescriptor *
    field(int index) const
    Get a member of this oneof, in the order in which they were declared in the .proto file. more...
    const OneofOptions &
    options() const
    void
    CopyTo(OneofDescriptorProto * proto) const
    std::string
    DebugString() const
    std::string
    DebugStringWithOptions(const DebugStringOptions & options) const

    Source Location

    bool
    GetSourceLocation(SourceLocation * out_location) const
    Updates |*out_location| to the source location of the complete extent of this oneof declaration. more...

    bool OneofDescriptor::is_synthetic() const

    Returns whether this oneof was inserted by the compiler to wrap a proto3 optional field.

    If this returns true, code generators should not emit it.


    const FieldDescriptor *
        OneofDescriptor::field(
            int index) const

    Get a member of this oneof, in the order in which they were declared in the .proto file.

    Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because fields_ is actually an array of pointers rather than the usual array of objects.

    Does not include extensions.


    bool OneofDescriptor::GetSourceLocation(
            SourceLocation * out_location) const

    Updates |*out_location| to the source location of the complete extent of this oneof declaration.

    Returns false and leaves |*out_location| unchanged iff location information was not available.

    -

    class EnumDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes an enum type defined in a .proto file.

    To get the EnumDescriptor for a generated enum type, call TypeName_descriptor(). Use DescriptorPool to construct your own descriptors.

    +

    class EnumDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes an enum type defined in a .proto file.

    To get the EnumDescriptor for a generated enum type, call TypeName_descriptor(). Use DescriptorPool to construct your own descriptors.

    Members

    typedef
    EnumDescriptorProto Proto
    const std::string &
    name() const
    The name of this enum type in the containing scope.
    const std::string &
    full_name() const
    The fully-qualified name of the enum type, scope delimited by periods.
    int
    index() const
    Index of this enum within the file or containing message's enum array.
    const FileDescriptor *
    file() const
    The .proto file in which this enum type was defined. Never nullptr.
    int
    value_count() const
    The number of values for this EnumDescriptor. more...
    const EnumValueDescriptor *
    value(int index) const
    Gets a value by index, where 0 <= index < value_count(). more...
    const EnumValueDescriptor *
    FindValueByName(ConstStringParam name) const
    Looks up a value by name. Returns nullptr if no such value exists.
    const EnumValueDescriptor *
    FindValueByNumber(int number) const
    Looks up a value by number. more...
    const Descriptor *
    containing_type() const
    If this enum type is nested in a message type, this is that message type. more...
    const EnumOptions &
    options() const
    Get options for this enum type. more...
    void
    CopyTo(EnumDescriptorProto * proto) const
    std::string
    DebugString() const
    std::string
    DebugStringWithOptions(const DebugStringOptions & options) const
    bool
    is_placeholder() const
    Returns true if this is a placeholder for an unknown enum. more...

    Reserved fields

    int
    reserved_range_count() const
    The number of reserved ranges in this message type.
    const EnumDescriptor::ReservedRange *
    reserved_range(int index) const
    Gets an reserved range by index, where 0 <= index < reserved_range_count(). more...
    bool
    IsReservedNumber(int number) const
    Returns true if the number is in one of the reserved ranges.
    const EnumDescriptor::ReservedRange *
    FindReservedRangeContainingNumber(int number) const
    Returns nullptr if no reserved range contains the given number.
    int
    reserved_name_count() const
    The number of reserved field names in this message type.
    const std::string &
    reserved_name(int index) const
    Gets a reserved name by index, where 0 <= index < reserved_name_count(). more...
    bool
    IsReservedName(ConstStringParam name) const
    Returns true if the field name is reserved.

    Source Location

    bool
    GetSourceLocation(SourceLocation * out_location) const
    Updates |*out_location| to the source location of the complete extent of this enum declaration. more...

    int EnumDescriptor::value_count() const

    The number of values for this EnumDescriptor.

    Guaranteed to be greater than zero.


    const EnumValueDescriptor *
        EnumDescriptor::value(
            int index) const

    Gets a value by index, where 0 <= index < value_count().

    These are returned in the order they were defined in the .proto file.


    const EnumValueDescriptor *
        EnumDescriptor::FindValueByNumber(
            int number) const

    Looks up a value by number.

    Returns nullptr if no such value exists. If multiple values have this number, the first one defined is returned.

    @@ -110,18 +110,18 @@ fooBar -> fooBar

    const EnumDescriptor::ReservedRange *
        EnumDescriptor::reserved_range(
            int index) const

    Gets an reserved range by index, where 0 <= index < reserved_range_count().

    These are returned in the order they were defined in the .proto file.


    const std::string &
        EnumDescriptor::reserved_name(
            int index) const

    Gets a reserved name by index, where 0 <= index < reserved_name_count().

    Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because reserved_names_ is actually an array of pointers rather than the usual array of objects.


    bool EnumDescriptor::GetSourceLocation(
            SourceLocation * out_location) const

    Updates |*out_location| to the source location of the complete extent of this enum declaration.

    Returns false and leaves |*out_location| unchanged iff location information was not available.

    -

    struct EnumDescriptor::ReservedRange

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    A range of reserved field numbers.

    Members

    int
    start
    inclusive
    int
    end
    inclusive

    class EnumValueDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes an individual enum constant of a particular type.

    To get the EnumValueDescriptor for a given enum value, first get the EnumDescriptor for its type, then use EnumDescriptor::FindValueByName() or EnumDescriptor::FindValueByNumber(). Use DescriptorPool to construct your own descriptors.

    +

    struct EnumDescriptor::ReservedRange

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    A range of reserved field numbers.

    Members

    int
    start
    inclusive
    int
    end
    inclusive

    class EnumValueDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes an individual enum constant of a particular type.

    To get the EnumValueDescriptor for a given enum value, first get the EnumDescriptor for its type, then use EnumDescriptor::FindValueByName() or EnumDescriptor::FindValueByNumber(). Use DescriptorPool to construct your own descriptors.

    Members

    typedef
    EnumValueDescriptorProto Proto
    const std::string &
    name() const
    Name of this enum constant.
    int
    index() const
    Index within the enums's Descriptor.
    int
    number() const
    Numeric value of this enum constant.
    const std::string &
    full_name() const
    The full_name of an enum value is a sibling symbol of the enum type. more...
    const FileDescriptor *
    file() const
    The .proto file in which this value was defined. Never nullptr.
    const EnumDescriptor *
    type() const
    The type of this value. Never nullptr.
    const EnumValueOptions &
    options() const
    Get options for this enum value. more...
    void
    CopyTo(EnumValueDescriptorProto * proto) const
    std::string
    DebugString() const
    std::string
    DebugStringWithOptions(const DebugStringOptions & options) const

    Source Location

    bool
    GetSourceLocation(SourceLocation * out_location) const
    Updates |*out_location| to the source location of the complete extent of this enum value declaration. more...

    const std::string &
        EnumValueDescriptor::full_name() const

    The full_name of an enum value is a sibling symbol of the enum type.

    e.g. the full name of FieldDescriptorProto::TYPE_INT32 is actually "google.protobuf.FieldDescriptorProto.TYPE_INT32", NOT "google.protobuf.FieldDescriptorProto.Type.TYPE_INT32". This is to conform with C++ scoping rules for enums.


    const EnumValueOptions &
        EnumValueDescriptor::options() const

    Get options for this enum value.

    These are specified in the .proto file by adding text like "[[]foo = 1234]" after an enum value definition. Allowed options are defined by EnumValueOptions in descriptor.proto, and any available extensions of that message.


    bool EnumValueDescriptor::GetSourceLocation(
            SourceLocation * out_location) const

    Updates |*out_location| to the source location of the complete extent of this enum value declaration.

    Returns false and leaves |*out_location| unchanged iff location information was not available.

    -

    class ServiceDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes an RPC service.

    Use DescriptorPool to construct your own descriptors.

    +

    class ServiceDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes an RPC service.

    Use DescriptorPool to construct your own descriptors.

    Members

    typedef
    ServiceDescriptorProto Proto
    const std::string &
    name() const
    The name of the service, not including its containing scope.
    const std::string &
    full_name() const
    The fully-qualified name of the service, scope delimited by periods.
    int
    index() const
    Index of this service within the file's services array.
    const FileDescriptor *
    file() const
    The .proto file in which this service was defined. Never nullptr.
    const ServiceOptions &
    options() const
    Get options for this service type. more...
    int
    method_count() const
    The number of methods this service defines.
    const MethodDescriptor *
    method(int index) const
    Gets a MethodDescriptor by index, where 0 <= index < method_count(). more...
    const MethodDescriptor *
    FindMethodByName(ConstStringParam name) const
    Look up a MethodDescriptor by name.
    void
    CopyTo(ServiceDescriptorProto * proto) const
    std::string
    DebugString() const
    std::string
    DebugStringWithOptions(const DebugStringOptions & options) const

    Source Location

    bool
    GetSourceLocation(SourceLocation * out_location) const
    Updates |*out_location| to the source location of the complete extent of this service declaration. more...

    const ServiceOptions &
        ServiceDescriptor::options() const

    Get options for this service type.

    These are specified in the .proto file by placing lines like "option foo = 1234;" in the service definition. Allowed options are defined by ServiceOptions in descriptor.proto, and any available extensions of that message.


    const MethodDescriptor *
        ServiceDescriptor::method(
            int index) const

    Gets a MethodDescriptor by index, where 0 <= index < method_count().

    These are returned in the order they were defined in the .proto file.


    bool ServiceDescriptor::GetSourceLocation(
            SourceLocation * out_location) const

    Updates |*out_location| to the source location of the complete extent of this service declaration.

    Returns false and leaves |*out_location| unchanged iff location information was not available.

    -

    class MethodDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes an individual service method.

    To obtain a MethodDescriptor given a service, first get its ServiceDescriptor, then call ServiceDescriptor::FindMethodByName(). Use DescriptorPool to construct your own descriptors.

    +

    class MethodDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes an individual service method.

    To obtain a MethodDescriptor given a service, first get its ServiceDescriptor, then call ServiceDescriptor::FindMethodByName(). Use DescriptorPool to construct your own descriptors.

    Members

    typedef
    MethodDescriptorProto Proto
    const std::string &
    name() const
    Name of this method, not including containing scope.
    const std::string &
    full_name() const
    The fully-qualified name of the method, scope delimited by periods.
    int
    index() const
    Index within the service's Descriptor.
    const FileDescriptor *
    file() const
    The .proto file in which this method was defined. Never nullptr.
    const ServiceDescriptor *
    service() const
    Gets the service to which this method belongs. Never nullptr.
    const Descriptor *
    input_type() const
    Gets the type of protocol message which this method accepts as input.
    const Descriptor *
    output_type() const
    Gets the type of protocol message which this message produces as output.
    bool
    client_streaming() const
    Gets whether the client streams multiple requests.
    bool
    server_streaming() const
    Gets whether the server streams multiple responses.
    const MethodOptions &
    options() const
    Get options for this method. more...
    void
    CopyTo(MethodDescriptorProto * proto) const
    std::string
    DebugString() const
    std::string
    DebugStringWithOptions(const DebugStringOptions & options) const

    Source Location

    bool
    GetSourceLocation(SourceLocation * out_location) const
    Updates |*out_location| to the source location of the complete extent of this method declaration. more...

    const MethodOptions &
        MethodDescriptor::options() const

    Get options for this method.

    These are specified in the .proto file by placing lines like "option foo = 1234;" in curly-braces after a method declaration. Allowed options are defined by MethodOptions in descriptor.proto, and any available extensions of that message.


    bool MethodDescriptor::GetSourceLocation(
            SourceLocation * out_location) const

    Updates |*out_location| to the source location of the complete extent of this method declaration.

    Returns false and leaves |*out_location| unchanged iff location information was not available.

    -

    class FileDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes a whole .proto file.

    To get the FileDescriptor for a compiled-in file, get the descriptor for something defined in that file and call descriptor->file(). Use DescriptorPool to construct your own descriptors.

    +

    class FileDescriptor

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Describes a whole .proto file.

    To get the FileDescriptor for a compiled-in file, get the descriptor for something defined in that file and call descriptor->file(). Use DescriptorPool to construct your own descriptors.

    Members

    enum
    Syntax
    Syntax of this file. more...
    typedef
    FileDescriptorProto Proto
    const std::string &
    name() const
    The filename, relative to the source tree. more...
    const std::string &
    package() const
    The package, e.g. "google.protobuf.compiler".
    const DescriptorPool *
    pool() const
    The DescriptorPool in which this FileDescriptor and all its contents were allocated. more...
    int
    dependency_count() const
    The number of files imported by this one.
    const FileDescriptor *
    dependency(int index) const
    Gets an imported file by index, where 0 <= index < dependency_count(). more...
    int
    public_dependency_count() const
    The number of files public imported by this one. more...
    const FileDescriptor *
    public_dependency(int index) const
    Gets a public imported file by index, where 0 <= index < public_dependency_count(). more...
    int
    weak_dependency_count() const
    The number of files that are imported for weak fields. more...
    const FileDescriptor *
    weak_dependency(int index) const
    Gets a weak imported file by index, where 0 <= index < weak_dependency_count(). more...
    int
    message_type_count() const
    Number of top-level message types defined in this file. more...
    const Descriptor *
    message_type(int index) const
    Gets a top-level message type, where 0 <= index < message_type_count(). more...
    int
    enum_type_count() const
    Number of top-level enum types defined in this file. more...
    const EnumDescriptor *
    enum_type(int index) const
    Gets a top-level enum type, where 0 <= index < enum_type_count(). more...
    int
    service_count() const
    Number of services defined in this file.
    const ServiceDescriptor *
    service(int index) const
    Gets a service, where 0 <= index < service_count(). more...
    int
    extension_count() const
    Number of extensions defined at file scope. more...
    const FieldDescriptor *
    extension(int index) const
    Gets an extension's descriptor, where 0 <= index < extension_count(). more...
    const FileOptions &
    options() const
    Get options for this file. more...
    Syntax
    syntax() const
    const Descriptor *
    FindMessageTypeByName(ConstStringParam name) const
    Find a top-level message type by name (not full_name). more...
    const EnumDescriptor *
    FindEnumTypeByName(ConstStringParam name) const
    Find a top-level enum type by name. Returns nullptr if not found.
    const EnumValueDescriptor *
    FindEnumValueByName(ConstStringParam name) const
    Find an enum value defined in any top-level enum by name. more...
    const ServiceDescriptor *
    FindServiceByName(ConstStringParam name) const
    Find a service definition by name. Returns nullptr if not found.
    const FieldDescriptor *
    FindExtensionByName(ConstStringParam name) const
    Find a top-level extension definition by name. more...
    const FieldDescriptor *
    FindExtensionByLowercaseName(ConstStringParam name) const
    Similar to FindExtensionByName(), but searches by lowercased-name. more...
    const FieldDescriptor *
    FindExtensionByCamelcaseName(ConstStringParam name) const
    Similar to FindExtensionByName(), but searches by camelcased-name. more...
    void
    CopyTo(FileDescriptorProto * proto) const
    void
    CopySourceCodeInfoTo(FileDescriptorProto * proto) const
    Write the source code information of this FileDescriptor into the given FileDescriptorProto. more...
    void
    CopyJsonNameTo(FileDescriptorProto * proto) const
    Fill the json_name field of FieldDescriptorProto for all fields. more...
    std::string
    DebugString() const
    std::string
    DebugStringWithOptions(const DebugStringOptions & options) const
    bool
    is_placeholder() const
    Returns true if this is a placeholder for an unknown file. more...
    bool
    GetSourceLocation(SourceLocation * out_location) const
    Updates |*out_location| to the source location of the complete extent of this file declaration (namely, the empty path).
    bool
    GetSourceLocation(const std::vector< int > & path, SourceLocation * out_location) const
    Updates |*out_location| to the source location of the complete extent of the declaration or declaration-part denoted by |path|. more...
    static const char *
    SyntaxName(Syntax syntax)

    enum FileDescriptor::Syntax {
      SYNTAX_UNKNOWN = = 0,
      SYNTAX_PROTO2 = = 2,
      SYNTAX_PROTO3 = = 3
    }

    Syntax of this file.

    SYNTAX_UNKNOWN
    SYNTAX_PROTO2
    SYNTAX_PROTO3

    const std::string &
        FileDescriptor::name() const

    The filename, relative to the source tree.

    e.g. "foo/bar/baz.proto"


    const DescriptorPool *
        FileDescriptor::pool() const

    The DescriptorPool in which this FileDescriptor and all its contents were allocated.

    Never nullptr.


    const FileDescriptor *
        FileDescriptor::dependency(
            int index) const

    Gets an imported file by index, where 0 <= index < dependency_count().

    These are returned in the order they were defined in the .proto file.

    @@ -150,21 +150,21 @@ fooBar -> fooBar

    void FileDescriptor::CopyJsonNameTo(
            FileDescriptorProto * proto) const

    Fill the json_name field of FieldDescriptorProto for all fields.

    Can only be called after CopyTo().


    bool FileDescriptor::is_placeholder() const

    Returns true if this is a placeholder for an unknown file.

    This will only be the case if this descriptor comes from a DescriptorPool with AllowUnknownDependencies() set.


    bool FileDescriptor::GetSourceLocation(
            const std::vector< int > & path,
            SourceLocation * out_location) const

    Updates |*out_location| to the source location of the complete extent of the declaration or declaration-part denoted by |path|.

    Returns false and leaves |*out_location| unchanged iff location information was not available. (See SourceCodeInfo for description of path encoding.)

    -

    class DescriptorPool

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Used to construct descriptors.

    Normally you won't want to build your own descriptors. Message classes constructed by the protocol compiler will provide them for you. However, if you are implementing Message on your own, or if you are writing a program which can operate on totally arbitrary types and needs to load them from some sort of database, you might need to.

    +

    class DescriptorPool

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    Used to construct descriptors.

    Normally you won't want to build your own descriptors. Message classes constructed by the protocol compiler will provide them for you. However, if you are implementing Message on your own, or if you are writing a program which can operate on totally arbitrary types and needs to load them from some sort of database, you might need to.

    Since Descriptors are composed of a whole lot of cross-linked bits of data that would be a pain to put together manually, the DescriptorPool class is provided to make the process easier. It can take a FileDescriptorProto (defined in descriptor.proto), validate it, and convert it to a set of nicely cross-linked Descriptors.

    DescriptorPool also helps with memory management. Descriptors are composed of many objects containing static data and pointers to each other. In all likelihood, when it comes time to delete this data, you'll want to delete it all at once. In fact, it is not uncommon to have a whole pool of descriptors all cross-linked with each other which you wish to delete all at once. This class represents such a pool, and handles the memory management for you.

    You can also search for descriptors within a DescriptorPool by name, and extensions by number.

    -

    Members

    DescriptorPool()
    Create a normal, empty DescriptorPool.
    explicit
    DescriptorPool(DescriptorDatabase * fallback_database, ErrorCollector * error_collector = nullptr)
    ~DescriptorPool()
    const FileDescriptor *
    FindFileByName(ConstStringParam name) const
    Find a FileDescriptor in the pool by file name. more...
    const FileDescriptor *
    FindFileContainingSymbol(ConstStringParam symbol_name) const
    Find the FileDescriptor in the pool which defines the given symbol. more...
    static const DescriptorPool *
    generated_pool()
    Get a pointer to the generated pool. more...

    Looking up descriptors

    These find descriptors by fully-qualified name. These will find both top-level descriptors and nested descriptors. They return nullptr if not found.
    const Descriptor *
    FindMessageTypeByName(ConstStringParam name) const
    const FieldDescriptor *
    FindFieldByName(ConstStringParam name) const
    const FieldDescriptor *
    FindExtensionByName(ConstStringParam name) const
    const OneofDescriptor *
    FindOneofByName(ConstStringParam name) const
    const EnumDescriptor *
    FindEnumTypeByName(ConstStringParam name) const
    const EnumValueDescriptor *
    FindEnumValueByName(ConstStringParam name) const
    const ServiceDescriptor *
    FindServiceByName(ConstStringParam name) const
    const MethodDescriptor *
    FindMethodByName(ConstStringParam name) const
    const FieldDescriptor *
    FindExtensionByNumber(const Descriptor * extendee, int number) const
    Finds an extension of the given type by number. more...
    const FieldDescriptor *
    FindExtensionByPrintableName(const Descriptor * extendee, ConstStringParam printable_name) const
    Finds an extension of the given type by its printable name. more...
    void
    FindAllExtensions(const Descriptor * extendee, std::vector< const FieldDescriptor * > * out) const
    Finds extensions of extendee. more...

    Building descriptors

    const FileDescriptor *
    BuildFile(const FileDescriptorProto & proto)
    Convert the FileDescriptorProto to real descriptors and place them in this DescriptorPool. more...
    const FileDescriptor *
    BuildFileCollectingErrors(const FileDescriptorProto & proto, ErrorCollector * error_collector)
    Same as BuildFile() except errors are sent to the given ErrorCollector.
    void
    AllowUnknownDependencies()
    By default, it is an error if a FileDescriptorProto contains references to types or other files that are not found in the DescriptorPool (or its backing DescriptorDatabase, if any). more...
    void
    EnforceWeakDependencies(bool enforce)
    By default, weak imports are allowed to be missing, in which case we will use a placeholder for the dependency and convert the field to be an Empty message field. more...

    Internal stuff

    +

    Members

    DescriptorPool()
    Create a normal, empty DescriptorPool.
    explicit
    DescriptorPool(DescriptorDatabase * fallback_database, ErrorCollector * error_collector = nullptr)
    ~DescriptorPool()
    const FileDescriptor *
    FindFileByName(ConstStringParam name) const
    Find a FileDescriptor in the pool by file name. more...
    const FileDescriptor *
    FindFileContainingSymbol(ConstStringParam symbol_name) const
    Find the FileDescriptor in the pool which defines the given symbol. more...
    static const DescriptorPool *
    generated_pool()
    Get a pointer to the generated pool. more...

    Looking up descriptors

    These find descriptors by fully-qualified name. These will find both top-level descriptors and nested descriptors. They return nullptr if not found.
    const Descriptor *
    FindMessageTypeByName(ConstStringParam name) const
    const FieldDescriptor *
    FindFieldByName(ConstStringParam name) const
    const FieldDescriptor *
    FindExtensionByName(ConstStringParam name) const
    const OneofDescriptor *
    FindOneofByName(ConstStringParam name) const
    const EnumDescriptor *
    FindEnumTypeByName(ConstStringParam name) const
    const EnumValueDescriptor *
    FindEnumValueByName(ConstStringParam name) const
    const ServiceDescriptor *
    FindServiceByName(ConstStringParam name) const
    const MethodDescriptor *
    FindMethodByName(ConstStringParam name) const
    const FieldDescriptor *
    FindExtensionByNumber(const Descriptor * extendee, int number) const
    Finds an extension of the given type by number. more...
    const FieldDescriptor *
    FindExtensionByPrintableName(const Descriptor * extendee, ConstStringParam printable_name) const
    Finds an extension of the given type by its printable name. more...
    void
    FindAllExtensions(const Descriptor * extendee, std::vector< const FieldDescriptor * > * out) const
    Finds extensions of extendee. more...

    Building descriptors

    const FileDescriptor *
    BuildFile(const FileDescriptorProto & proto)
    Convert the FileDescriptorProto to real descriptors and place them in this DescriptorPool. more...
    const FileDescriptor *
    BuildFileCollectingErrors(const FileDescriptorProto & proto, ErrorCollector * error_collector)
    Same as BuildFile() except errors are sent to the given ErrorCollector.
    void
    AllowUnknownDependencies()
    By default, it is an error if a FileDescriptorProto contains references to types or other files that are not found in the DescriptorPool (or its backing DescriptorDatabase, if any). more...
    void
    EnforceWeakDependencies(bool enforce)
    By default, weak imports are allowed to be missing, in which case we will use a placeholder for the dependency and convert the field to be an Empty message field. more...

    Internal stuff

    These methods MUST NOT be called from outside the proto2 library.

    These methods may contain hidden pitfalls and may be removed in a future library version.

    -
    explicit
    DescriptorPool(const DescriptorPool * underlay)
    Create a DescriptorPool which is overlaid on top of some other pool. more...
    void
    DisallowEnforceUtf8()
    Disallow [[]enforce_utf8 = false] in .proto files.
    void
    InternalDontEnforceDependencies()
    For internal use only: Changes the behavior of BuildFile() such that it allows the file to make reference to message types declared in other files which it did not officially declare as dependencies.
    void
    InternalSetLazilyBuildDependencies()
    For internal use only: Enables lazy building of dependencies of a file. more...
    void
    internal_set_underlay(const DescriptorPool * underlay)
    For internal use only.
    bool
    InternalIsFileLoaded(ConstStringParam filename) const
    For internal (unit test) use only: Returns true if a FileDescriptor has been constructed for the given file, false otherwise. more...
    void
    AddUnusedImportTrackFile(ConstStringParam file_name, bool is_error = false)
    Add a file to unused_import_track_files_. more...
    void
    ClearUnusedImportTrackFiles()
    static void
    InternalAddGeneratedFile(const void * encoded_file_descriptor, int size)
    Called by generated classes at init time to add their descriptors to generated_pool. more...
    static DescriptorPool *
    internal_generated_pool()
    For internal use only: Gets a non-const pointer to the generated pool. more...
    static DescriptorDatabase *
    internal_generated_database()
    For internal use only: Gets a non-const pointer to the generated descriptor database. more...

    const FileDescriptor *
        DescriptorPool::FindFileByName(
            ConstStringParam name) const

    Find a FileDescriptor in the pool by file name.

    Returns nullptr if not found.

    +
    explicit
    DescriptorPool(const DescriptorPool * underlay)
    Create a DescriptorPool which is overlaid on top of some other pool. more...
    void
    DisallowEnforceUtf8()
    Disallow [[]enforce_utf8 = false] in .proto files.
    void
    InternalDontEnforceDependencies()
    For internal use only: Changes the behavior of BuildFile() such that it allows the file to make reference to message types declared in other files which it did not officially declare as dependencies.
    void
    InternalSetLazilyBuildDependencies()
    For internal use only: Enables lazy building of dependencies of a file. more...
    void
    internal_set_underlay(const DescriptorPool * underlay)
    For internal use only.
    bool
    InternalIsFileLoaded(ConstStringParam filename) const
    For internal (unit test) use only: Returns true if a FileDescriptor has been constructed for the given file, false otherwise. more...
    void
    AddUnusedImportTrackFile(ConstStringParam file_name, bool is_error = false)
    Add a file to unused_import_track_files_. more...
    void
    ClearUnusedImportTrackFiles()
    static void
    InternalAddGeneratedFile(const void * encoded_file_descriptor, int size)
    Called by generated classes at init time to add their descriptors to generated_pool. more...
    static DescriptorPool *
    internal_generated_pool()
    For internal use only: Gets a non-const pointer to the generated pool. more...
    static DescriptorDatabase *
    internal_generated_database()
    For internal use only: Gets a non-const pointer to the generated descriptor database. more...

    const FileDescriptor *
        DescriptorPool::FindFileByName(
            ConstStringParam name) const

    Find a FileDescriptor in the pool by file name.

    Returns nullptr if not found.


    const FileDescriptor *
        DescriptorPool::FindFileContainingSymbol(
            ConstStringParam symbol_name) const

    Find the FileDescriptor in the pool which defines the given symbol.

    If any of the Find*ByName() methods below would succeed, then this is equivalent to calling that method and calling the result's file() method. Otherwise this returns nullptr.


    static const DescriptorPool *
        DescriptorPool::generated_pool()

    Get a pointer to the generated pool.

    Generated protocol message classes which are compiled into the binary will allocate their descriptors in this pool. Do not add your own descriptors to this pool.


    const FieldDescriptor *
        DescriptorPool::FindExtensionByNumber(
            const Descriptor * extendee,
            int number) const

    Finds an extension of the given type by number.

    The extendee must be a member of this DescriptorPool or one of its underlays.


    const FieldDescriptor *
        DescriptorPool::FindExtensionByPrintableName(
            const Descriptor * extendee,
            ConstStringParam printable_name) const

    Finds an extension of the given type by its printable name.

    See comments above PrintableNameForExtension() for the definition of "printable name". The extendee must be a member of this DescriptorPool or one of its underlays. Returns nullptr if there is no known message extension with the given printable name.


    void DescriptorPool::FindAllExtensions(
            const Descriptor * extendee,
            std::vector< const FieldDescriptor * > * out) const

    Finds extensions of extendee.

    The extensions will be appended to out in an undefined order. Only extensions defined directly in this DescriptorPool or one of its underlays are guaranteed to be found: extensions defined in the fallback database might not be found depending on the database implementation.


    const FileDescriptor *
        DescriptorPool::BuildFile(
            const FileDescriptorProto & proto)

    Convert the FileDescriptorProto to real descriptors and place them in this DescriptorPool.

    All dependencies of the file must already be in the pool. Returns the resulting FileDescriptor, or nullptr if there were problems with the input (e.g. the message was invalid, or dependencies were missing). Details about the errors are written to GOOGLE_LOG(ERROR).

    -

    void DescriptorPool::AllowUnknownDependencies()

    By default, it is an error if a FileDescriptorProto contains references to types or other files that are not found in the DescriptorPool (or its backing DescriptorDatabase, if any).

    If you call AllowUnknownDependencies(), however, then unknown types and files will be replaced by placeholder descriptors (which can be identified by the is_placeholder() method). This can allow you to perform some useful operations with a .proto file even if you do not have access to other .proto files on which it depends. However, some heuristics must be used to fill in the gaps in information, and these can lead to descriptors which are inaccurate. For example, the DescriptorPool may be forced to guess whether an unknown type is a message or an enum, as well as what package it resides in. Furthermore, placeholder types will not be discoverable via FindMessageTypeByName() and similar methods, which could confuse some descriptor-based algorithms. Generally, the results of this option should be handled with extreme care.

    +

    void DescriptorPool::AllowUnknownDependencies()

    By default, it is an error if a FileDescriptorProto contains references to types or other files that are not found in the DescriptorPool (or its backing DescriptorDatabase, if any).

    If you call AllowUnknownDependencies(), however, then unknown types and files will be replaced by placeholder descriptors (which can be identified by the is_placeholder() method). This can allow you to perform some useful operations with a .proto file even if you do not have access to other .proto files on which it depends. However, some heuristics must be used to fill in the gaps in information, and these can lead to descriptors which are inaccurate. For example, the DescriptorPool may be forced to guess whether an unknown type is a message or an enum, as well as what package it resides in. Furthermore, placeholder types will not be discoverable via FindMessageTypeByName() and similar methods, which could confuse some descriptor-based algorithms. Generally, the results of this option should be handled with extreme care.


    void DescriptorPool::EnforceWeakDependencies(
            bool enforce)

    By default, weak imports are allowed to be missing, in which case we will use a placeholder for the dependency and convert the field to be an Empty message field.

    If you call EnforceWeakDependencies(true), however, the DescriptorPool will report a import not found error.


    explicit DescriptorPool::DescriptorPool(
            const DescriptorPool * underlay)

    Create a DescriptorPool which is overlaid on top of some other pool.

    If you search for a descriptor in the overlay and it is not found, the underlay will be searched as a backup. If the underlay has its own underlay, that will be searched next, and so on. This also means that files built in the overlay will be cross-linked with the underlay's descriptors if necessary. The underlay remains property of the caller; it must remain valid for the lifetime of the newly-constructed pool.

    Example: Say you want to parse a .proto file at runtime in order to use its type with a DynamicMessage. Say this .proto file has dependencies, but you know that all the dependencies will be things that are already compiled into the binary. For ease of use, you'd like to load the types right out of generated_pool() rather than have to parse redundant copies of all these .protos and runtime. But, you don't want to add the parsed types directly into generated_pool(): this is not allowed, and would be bad design anyway. So, instead, you could use generated_pool() as an underlay for a new DescriptorPool in which you add only the new file.

    @@ -174,9 +174,9 @@ fooBar -> fooBar

    void DescriptorPool::AddUnusedImportTrackFile(
            ConstStringParam file_name,
            bool is_error = false)

    Add a file to unused_import_track_files_.

    DescriptorBuilder will log warnings or errors for those files if there is any unused import.


    static void DescriptorPool::InternalAddGeneratedFile(
            const void * encoded_file_descriptor,
            int size)

    Called by generated classes at init time to add their descriptors to generated_pool.

    Do NOT call this in your own code! filename must be a permanent string (e.g. a string literal).


    static DescriptorPool * DescriptorPool::internal_generated_pool()

    For internal use only: Gets a non-const pointer to the generated pool.

    This is called at static-initialization time only, so thread-safety is not a concern. If both an underlay and a fallback database are present, the underlay takes precedence.

    -

    static DescriptorDatabase *
        DescriptorPool::internal_generated_database()

    For internal use only: Gets a non-const pointer to the generated descriptor database.

    Only used for testing.

    -

    class DescriptorPool::ErrorCollector

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    When converting a FileDescriptorProto to a FileDescriptor, various errors might be detected in the input.

    The caller may handle these programmatically by implementing an ErrorCollector.

    -

    Members

    enum
    ErrorLocation
    These constants specify what exact part of the construct is broken. more...
    ErrorCollector()
    virtual
    ~ErrorCollector()
    virtual void
    AddError(const std::string & filename, const std::string & element_name, const Message * descriptor, ErrorLocation location, const std::string & message) = 0
    Reports an error in the FileDescriptorProto. more...
    virtual void
    AddWarning(const std::string & , const std::string & , const Message * , ErrorLocation , const std::string & )
    Reports a warning in the FileDescriptorProto. more...

    enum ErrorCollector::ErrorLocation {
      NAME,
      NUMBER,
      TYPE,
      EXTENDEE,
      DEFAULT_VALUE,
      INPUT_TYPE,
      OUTPUT_TYPE,
      OPTION_NAME,
      OPTION_VALUE,
      IMPORT,
      OTHER
    }

    These constants specify what exact part of the construct is broken.

    This is useful e.g. for mapping the error back to an exact location in a .proto file.

    -
    NAMEthe symbol name, or the package name for files
    NUMBERfield or extension range number
    TYPEfield type
    EXTENDEEfield extendee
    DEFAULT_VALUEfield default value
    INPUT_TYPEmethod input type
    OUTPUT_TYPEmethod output type
    OPTION_NAMEname in assignment
    OPTION_VALUEvalue in option assignment
    IMPORTimport error
    OTHERsome other problem

    virtual void ErrorCollector::AddError(
            const std::string & filename,
            const std::string & element_name,
            const Message * descriptor,
            ErrorLocation location,
            const std::string & message) = 0

    Reports an error in the FileDescriptorProto.

    Use this function if the problem occurred should interrupt building the FileDescriptorProto.

    -

    virtual void ErrorCollector::AddWarning(
            const std::string & ,
            const std::string & ,
            const Message * ,
            ErrorLocation ,
            const std::string & )

    Reports a warning in the FileDescriptorProto.

    Use this function if the problem occurred should NOT interrupt building the FileDescriptorProto.

    +

    static DescriptorDatabase *
        DescriptorPool::internal_generated_database()

    For internal use only: Gets a non-const pointer to the generated descriptor database.

    Only used for testing.

    +

    class DescriptorPool::ErrorCollector

    #include <google/protobuf/descriptor.h>
    namespace google::protobuf

    When converting a FileDescriptorProto to a FileDescriptor, various errors might be detected in the input.

    The caller may handle these programmatically by implementing an ErrorCollector.

    +

    Members

    enum
    ErrorLocation
    These constants specify what exact part of the construct is broken. more...
    ErrorCollector()
    virtual
    ~ErrorCollector()
    virtual void
    AddError(const std::string & filename, const std::string & element_name, const Message * descriptor, ErrorLocation location, const std::string & message) = 0
    Reports an error in the FileDescriptorProto. more...
    virtual void
    AddWarning(const std::string & , const std::string & , const Message * , ErrorLocation , const std::string & )
    Reports a warning in the FileDescriptorProto. more...

    enum ErrorCollector::ErrorLocation {
      NAME,
      NUMBER,
      TYPE,
      EXTENDEE,
      DEFAULT_VALUE,
      INPUT_TYPE,
      OUTPUT_TYPE,
      OPTION_NAME,
      OPTION_VALUE,
      IMPORT,
      OTHER
    }

    These constants specify what exact part of the construct is broken.

    This is useful e.g. for mapping the error back to an exact location in a .proto file.

    +
    NAMEthe symbol name, or the package name for files
    NUMBERfield or extension range number
    TYPEfield type
    EXTENDEEfield extendee
    DEFAULT_VALUEfield default value
    INPUT_TYPEmethod input type
    OUTPUT_TYPEmethod output type
    OPTION_NAMEname in assignment
    OPTION_VALUEvalue in option assignment
    IMPORTimport error
    OTHERsome other problem

    virtual void ErrorCollector::AddError(
            const std::string & filename,
            const std::string & element_name,
            const Message * descriptor,
            ErrorLocation location,
            const std::string & message) = 0

    Reports an error in the FileDescriptorProto.

    Use this function if the problem occurred should interrupt building the FileDescriptorProto.

    +

    virtual void ErrorCollector::AddWarning(
            const std::string & ,
            const std::string & ,
            const Message * ,
            ErrorLocation ,
            const std::string & )

    Reports a warning in the FileDescriptorProto.

    Use this function if the problem occurred should NOT interrupt building the FileDescriptorProto.

    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 3e966f8a..e230f868 100644 --- a/content/reference/cpp/api-docs/google.protobuf.descriptor.pb.md +++ b/content/reference/cpp/api-docs/google.protobuf.descriptor.pb.md @@ -6,7 +6,7 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/descriptor.pb.h>
    namespace google::protobuf

    Protobuf 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::protobuf

    Protobuf 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 descriptor.proto, whose contents are as follows:

    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 c787ecac..c3f239bd 100644 --- a/content/reference/cpp/api-docs/google.protobuf.descriptor_database.md +++ b/content/reference/cpp/api-docs/google.protobuf.descriptor_database.md @@ -6,9 +6,9 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    Interface for manipulating databases of descriptors.

    Classes in this file

    Abstract interface for a database of descriptors.
    A DescriptorDatabase into which you can insert files manually.
    Very similar to SimpleDescriptorDatabase, but stores all the descriptors as raw bytes and generally tries to use as little memory as possible.
    A DescriptorDatabase that fetches files from a given pool.
    A DescriptorDatabase that wraps two or more others.

    class DescriptorDatabase

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    Abstract interface for a database of descriptors.

    This is useful if you want to create a DescriptorPool which loads descriptors on-demand from some sort of large database. If the database is large, it may be inefficient to enumerate every .proto file inside it calling DescriptorPool::BuildFile() for each one. Instead, a DescriptorPool can be created which wraps a DescriptorDatabase and only builds particular descriptors when they are needed.

    +

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    Interface for manipulating databases of descriptors.

    Classes in this file

    Abstract interface for a database of descriptors.
    A DescriptorDatabase into which you can insert files manually.
    Very similar to SimpleDescriptorDatabase, but stores all the descriptors as raw bytes and generally tries to use as little memory as possible.
    A DescriptorDatabase that fetches files from a given pool.
    A DescriptorDatabase that wraps two or more others.

    class DescriptorDatabase

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    Abstract interface for a database of descriptors.

    This is useful if you want to create a DescriptorPool which loads descriptors on-demand from some sort of large database. If the database is large, it may be inefficient to enumerate every .proto file inside it calling DescriptorPool::BuildFile() for each one. Instead, a DescriptorPool can be created which wraps a DescriptorDatabase and only builds particular descriptors when they are needed.

    -

    Known subclasses:

    Members

    DescriptorDatabase()
    virtual
    ~DescriptorDatabase()
    virtual bool
    FindFileByName(const std::string & filename, FileDescriptorProto * output) = 0
    Find a file by file name. more...
    virtual bool
    FindFileContainingSymbol(const std::string & symbol_name, FileDescriptorProto * output) = 0
    Find the file that declares the given fully-qualified symbol name. more...
    virtual bool
    FindFileContainingExtension(const std::string & containing_type, int field_number, FileDescriptorProto * output) = 0
    Find the file which defines an extension extending the given message type with the given field number. more...
    virtual bool
    FindAllExtensionNumbers(const std::string & , std::vector< int > * )
    Finds the tag numbers used by all known extensions of extendee_type, and appends them to output in an undefined order. more...
    virtual bool
    FindAllFileNames(std::vector< std::string > * )
    Finds the file names and appends them to the output in an undefined order. more...
    bool
    FindAllPackageNames(std::vector< std::string > * output)
    Finds the package names and appends them to the output in an undefined order. more...
    bool
    FindAllMessageNames(std::vector< std::string > * output)
    Finds the message names and appends them to the output in an undefined order. more...

    virtual bool DescriptorDatabase::FindFileByName(
            const std::string & filename,
            FileDescriptorProto * output) = 0

    Find a file by file name.

    Fills in in *output and returns true if found. Otherwise, returns false, leaving the contents of *output undefined.

    +

    Known subclasses:

    Members

    DescriptorDatabase()
    virtual
    ~DescriptorDatabase()
    virtual bool
    FindFileByName(const std::string & filename, FileDescriptorProto * output) = 0
    Find a file by file name. more...
    virtual bool
    FindFileContainingSymbol(const std::string & symbol_name, FileDescriptorProto * output) = 0
    Find the file that declares the given fully-qualified symbol name. more...
    virtual bool
    FindFileContainingExtension(const std::string & containing_type, int field_number, FileDescriptorProto * output) = 0
    Find the file which defines an extension extending the given message type with the given field number. more...
    virtual bool
    FindAllExtensionNumbers(const std::string & , std::vector< int > * )
    Finds the tag numbers used by all known extensions of extendee_type, and appends them to output in an undefined order. more...
    virtual bool
    FindAllFileNames(std::vector< std::string > * )
    Finds the file names and appends them to the output in an undefined order. more...
    bool
    FindAllPackageNames(std::vector< std::string > * output)
    Finds the package names and appends them to the output in an undefined order. more...
    bool
    FindAllMessageNames(std::vector< std::string > * output)
    Finds the message names and appends them to the output in an undefined order. more...

    virtual bool DescriptorDatabase::FindFileByName(
            const std::string & filename,
            FileDescriptorProto * output) = 0

    Find a file by file name.

    Fills in in *output and returns true if found. Otherwise, returns false, leaving the contents of *output undefined.


    virtual bool DescriptorDatabase::FindFileContainingSymbol(
            const std::string & symbol_name,
            FileDescriptorProto * output) = 0

    Find the file that declares the given fully-qualified symbol name.

    If found, fills in *output and returns true, otherwise returns false and leaves *output undefined.


    virtual bool DescriptorDatabase::FindFileContainingExtension(
            const std::string & containing_type,
            int field_number,
            FileDescriptorProto * output) = 0

    Find the file which defines an extension extending the given message type with the given field number.

    If found, fills in *output and returns true, otherwise returns false and leaves *output undefined. containing_type must be a fully-qualified type name.


    virtual bool DescriptorDatabase::FindAllExtensionNumbers(
            const std::string & ,
            std::vector< int > * )

    Finds the tag numbers used by all known extensions of extendee_type, and appends them to output in an undefined order.

    This method is best-effort: it's not guaranteed that the database will find all extensions, and it's not guaranteed that FindFileContainingExtension will return true on all of the found numbers. Returns true if the search was successful, otherwise returns false and leaves output unchanged.

    @@ -19,9 +19,9 @@ type = "docs"

    This method has a default implementation that always returns false.


    bool DescriptorDatabase::FindAllPackageNames(
            std::vector< std::string > * output)

    Finds the package names and appends them to the output in an undefined order.

    This method is best-effort: it's not guaranteed that the database will find all packages. Returns true if the database supports searching all package names, otherwise returns false and leaves output unchanged.


    bool DescriptorDatabase::FindAllMessageNames(
            std::vector< std::string > * output)

    Finds the message names and appends them to the output in an undefined order.

    This method is best-effort: it's not guaranteed that the database will find all messages. Returns true if the database supports searching all message names, otherwise returns false and leaves output unchanged.

    -

    class SimpleDescriptorDatabase: public DescriptorDatabase

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    A DescriptorDatabase into which you can insert files manually.

    FindFileContainingSymbol() is fully-implemented. When you add a file, its symbols will be indexed for this purpose. Note that the implementation may return false positives, but only if it isn't possible for the symbol to be defined in any other file. In particular, if a file defines a symbol "Foo", then searching for "Foo.[anything]" will match that file. This way, the database does not need to aggressively index all children of a symbol.

    +

    class SimpleDescriptorDatabase: public DescriptorDatabase

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    A DescriptorDatabase into which you can insert files manually.

    FindFileContainingSymbol() is fully-implemented. When you add a file, its symbols will be indexed for this purpose. Note that the implementation may return false positives, but only if it isn't possible for the symbol to be defined in any other file. In particular, if a file defines a symbol "Foo", then searching for "Foo.[anything]" will match that file. This way, the database does not need to aggressively index all children of a symbol.

    -

    FindFileContainingExtension() is mostly-implemented. It works if and only if the original FieldDescriptorProto defining the extension has a fully-qualified type name in its "extendee" field (i.e. starts with a '.'). If the extendee is a relative name, SimpleDescriptorDatabase will not attempt to resolve the type, so it will not know what type the extension is extending. Therefore, calling FindFileContainingExtension() with the extension's containing type will never actually find that extension. Note that this is an unlikely problem, as all FileDescriptorProtos created by the protocol compiler (as well as ones created by calling FileDescriptor::CopyTo()) will always use fully-qualified names for all types. You only need to worry if you are constructing FileDescriptorProtos yourself, or are calling compiler::Parser directly.

    +

    FindFileContainingExtension() is mostly-implemented. It works if and only if the original FieldDescriptorProto defining the extension has a fully-qualified type name in its "extendee" field (i.e. starts with a '.'). If the extendee is a relative name, SimpleDescriptorDatabase will not attempt to resolve the type, so it will not know what type the extension is extending. Therefore, calling FindFileContainingExtension() with the extension's containing type will never actually find that extension. Note that this is an unlikely problem, as all FileDescriptorProtos created by the protocol compiler (as well as ones created by calling FileDescriptor::CopyTo()) will always use fully-qualified names for all types. You only need to worry if you are constructing FileDescriptorProtos yourself, or are calling compiler::Parser directly.

    Members

    SimpleDescriptorDatabase()
    ~SimpleDescriptorDatabase()
    bool
    Add(const FileDescriptorProto & file)
    Adds the FileDescriptorProto to the database, making a copy. more...
    bool
    AddAndOwn(const FileDescriptorProto * file)
    Adds the FileDescriptorProto to the database and takes ownership of it.

    implements DescriptorDatabase

    virtual bool
    FindFileByName(const std::string & filename, FileDescriptorProto * output)
    Find a file by file name. more...
    virtual bool
    FindFileContainingSymbol(const std::string & symbol_name, FileDescriptorProto * output)
    Find the file that declares the given fully-qualified symbol name. more...
    virtual bool
    FindFileContainingExtension(const std::string & containing_type, int field_number, FileDescriptorProto * output)
    Find the file which defines an extension extending the given message type with the given field number. more...
    virtual bool
    FindAllExtensionNumbers(const std::string & , std::vector< int > * )
    Finds the tag numbers used by all known extensions of extendee_type, and appends them to output in an undefined order. more...
    virtual bool
    FindAllFileNames(std::vector< std::string > * )
    Finds the file names and appends them to the output in an undefined order. more...

    bool SimpleDescriptorDatabase::Add(
            const FileDescriptorProto & file)

    Adds the FileDescriptorProto to the database, making a copy.

    The object can be deleted after Add() returns. Returns false if the file conflicted with a file already in the database, in which case an error will have been written to GOOGLE_LOG(ERROR).


    virtual bool SimpleDescriptorDatabase::FindFileByName(
            const std::string & filename,
            FileDescriptorProto * output)

    Find a file by file name.

    Fills in in *output and returns true if found. Otherwise, returns false, leaving the contents of *output undefined.

    @@ -31,7 +31,7 @@ type = "docs"

    This method has a default implementation that always returns false.


    virtual bool SimpleDescriptorDatabase::FindAllFileNames(
            std::vector< std::string > * )

    Finds the file names and appends them to the output in an undefined order.

    This method is best-effort: it's not guaranteed that the database will find all files. Returns true if the database supports searching all file names, otherwise returns false and leaves output unchanged.

    This method has a default implementation that always returns false.

    -

    class EncodedDescriptorDatabase: public DescriptorDatabase

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    Very similar to SimpleDescriptorDatabase, but stores all the descriptors as raw bytes and generally tries to use as little memory as possible.

    The same caveats regarding FindFileContainingExtension() apply as with SimpleDescriptorDatabase.

    +

    class EncodedDescriptorDatabase: public DescriptorDatabase

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    Very similar to SimpleDescriptorDatabase, but stores all the descriptors as raw bytes and generally tries to use as little memory as possible.

    The same caveats regarding FindFileContainingExtension() apply as with SimpleDescriptorDatabase.

    Members

    EncodedDescriptorDatabase()
    ~EncodedDescriptorDatabase()
    bool
    Add(const void * encoded_file_descriptor, int size)
    Adds the FileDescriptorProto to the database. more...
    bool
    AddCopy(const void * encoded_file_descriptor, int size)
    Like Add(), but makes a copy of the data, so that the caller does not need to keep it around.
    bool
    FindNameOfFileContainingSymbol(const std::string & symbol_name, std::string * output)
    Like FindFileContainingSymbol but returns only the name of the file.

    implements DescriptorDatabase

    virtual bool
    FindFileByName(const std::string & filename, FileDescriptorProto * output)
    Find a file by file name. more...
    virtual bool
    FindFileContainingSymbol(const std::string & symbol_name, FileDescriptorProto * output)
    Find the file that declares the given fully-qualified symbol name. more...
    virtual bool
    FindFileContainingExtension(const std::string & containing_type, int field_number, FileDescriptorProto * output)
    Find the file which defines an extension extending the given message type with the given field number. more...
    virtual bool
    FindAllExtensionNumbers(const std::string & , std::vector< int > * )
    Finds the tag numbers used by all known extensions of extendee_type, and appends them to output in an undefined order. more...
    virtual bool
    FindAllFileNames(std::vector< std::string > * )
    Finds the file names and appends them to the output in an undefined order. more...

    bool EncodedDescriptorDatabase::Add(
            const void * encoded_file_descriptor,
            int size)

    Adds the FileDescriptorProto to the database.

    The descriptor is provided in encoded form. The database does not make a copy of the bytes, nor does it take ownership; it's up to the caller to make sure the bytes remain valid for the life of the database. Returns false and logs an error if the bytes are not a valid FileDescriptorProto or if the file conflicted with a file already in the database.


    virtual bool EncodedDescriptorDatabase::FindFileByName(
            const std::string & filename,
            FileDescriptorProto * output)

    Find a file by file name.

    Fills in in *output and returns true if found. Otherwise, returns false, leaving the contents of *output undefined.


    virtual bool EncodedDescriptorDatabase::FindFileContainingSymbol(
            const std::string & symbol_name,
            FileDescriptorProto * output)

    Find the file that declares the given fully-qualified symbol name.

    If found, fills in *output and returns true, otherwise returns false and leaves *output undefined.

    @@ -40,12 +40,12 @@ type = "docs"

    This method has a default implementation that always returns false.


    virtual bool EncodedDescriptorDatabase::FindAllFileNames(
            std::vector< std::string > * )

    Finds the file names and appends them to the output in an undefined order.

    This method is best-effort: it's not guaranteed that the database will find all files. Returns true if the database supports searching all file names, otherwise returns false and leaves output unchanged.

    This method has a default implementation that always returns false.

    -

    class DescriptorPoolDatabase: public DescriptorDatabase

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    A DescriptorDatabase that fetches files from a given pool.

    Members

    explicit
    DescriptorPoolDatabase(const DescriptorPool & pool)
    ~DescriptorPoolDatabase()

    implements DescriptorDatabase

    virtual bool
    FindFileByName(const std::string & filename, FileDescriptorProto * output)
    Find a file by file name. more...
    virtual bool
    FindFileContainingSymbol(const std::string & symbol_name, FileDescriptorProto * output)
    Find the file that declares the given fully-qualified symbol name. more...
    virtual bool
    FindFileContainingExtension(const std::string & containing_type, int field_number, FileDescriptorProto * output)
    Find the file which defines an extension extending the given message type with the given field number. more...
    virtual bool
    FindAllExtensionNumbers(const std::string & , std::vector< int > * )
    Finds the tag numbers used by all known extensions of extendee_type, and appends them to output in an undefined order. more...

    virtual bool DescriptorPoolDatabase::FindFileByName(
            const std::string & filename,
            FileDescriptorProto * output)

    Find a file by file name.

    Fills in in *output and returns true if found. Otherwise, returns false, leaving the contents of *output undefined.

    +

    class DescriptorPoolDatabase: public DescriptorDatabase

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    A DescriptorDatabase that fetches files from a given pool.

    Members

    explicit
    DescriptorPoolDatabase(const DescriptorPool & pool)
    ~DescriptorPoolDatabase()

    implements DescriptorDatabase

    virtual bool
    FindFileByName(const std::string & filename, FileDescriptorProto * output)
    Find a file by file name. more...
    virtual bool
    FindFileContainingSymbol(const std::string & symbol_name, FileDescriptorProto * output)
    Find the file that declares the given fully-qualified symbol name. more...
    virtual bool
    FindFileContainingExtension(const std::string & containing_type, int field_number, FileDescriptorProto * output)
    Find the file which defines an extension extending the given message type with the given field number. more...
    virtual bool
    FindAllExtensionNumbers(const std::string & , std::vector< int > * )
    Finds the tag numbers used by all known extensions of extendee_type, and appends them to output in an undefined order. more...

    virtual bool DescriptorPoolDatabase::FindFileByName(
            const std::string & filename,
            FileDescriptorProto * output)

    Find a file by file name.

    Fills in in *output and returns true if found. Otherwise, returns false, leaving the contents of *output undefined.


    virtual bool DescriptorPoolDatabase::FindFileContainingSymbol(
            const std::string & symbol_name,
            FileDescriptorProto * output)

    Find the file that declares the given fully-qualified symbol name.

    If found, fills in *output and returns true, otherwise returns false and leaves *output undefined.


    virtual bool DescriptorPoolDatabase::FindFileContainingExtension(
            const std::string & containing_type,
            int field_number,
            FileDescriptorProto * output)

    Find the file which defines an extension extending the given message type with the given field number.

    If found, fills in *output and returns true, otherwise returns false and leaves *output undefined. containing_type must be a fully-qualified type name.


    virtual bool DescriptorPoolDatabase::FindAllExtensionNumbers(
            const std::string & ,
            std::vector< int > * )

    Finds the tag numbers used by all known extensions of extendee_type, and appends them to output in an undefined order.

    This method is best-effort: it's not guaranteed that the database will find all extensions, and it's not guaranteed that FindFileContainingExtension will return true on all of the found numbers. Returns true if the search was successful, otherwise returns false and leaves output unchanged.

    This method has a default implementation that always returns false.

    -

    class MergedDescriptorDatabase: public DescriptorDatabase

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    A DescriptorDatabase that wraps two or more others.

    It first searches the first database and, if that fails, tries the second, and so on.

    +

    class MergedDescriptorDatabase: public DescriptorDatabase

    #include <google/protobuf/descriptor_database.h>
    namespace google::protobuf

    A DescriptorDatabase that wraps two or more others.

    It first searches the first database and, if that fails, tries the second, and so on.

    Members

    MergedDescriptorDatabase(DescriptorDatabase * source1, DescriptorDatabase * source2)
    Merge just two databases. The sources remain property of the caller.
    explicit
    MergedDescriptorDatabase(const std::vector< DescriptorDatabase * > & sources)
    Merge more than two databases. more...
    ~MergedDescriptorDatabase()

    implements DescriptorDatabase

    virtual bool
    FindFileByName(const std::string & filename, FileDescriptorProto * output)
    Find a file by file name. more...
    virtual bool
    FindFileContainingSymbol(const std::string & symbol_name, FileDescriptorProto * output)
    Find the file that declares the given fully-qualified symbol name. more...
    virtual bool
    FindFileContainingExtension(const std::string & containing_type, int field_number, FileDescriptorProto * output)
    Find the file which defines an extension extending the given message type with the given field number. more...
    virtual bool
    FindAllExtensionNumbers(const std::string & extendee_type, std::vector< int > * output)
    Merges the results of calling all databases. more...

    explicit MergedDescriptorDatabase::MergedDescriptorDatabase(
            const std::vector< DescriptorDatabase * > & sources)

    Merge more than two databases.

    The sources remain property of the caller. The vector may be deleted after the constructor returns but the DescriptorDatabases need to stick around.


    virtual bool MergedDescriptorDatabase::FindFileByName(
            const std::string & filename,
            FileDescriptorProto * output)

    Find a file by file name.

    Fills in in *output and returns true if found. Otherwise, returns false, leaving the contents of *output undefined.


    virtual bool MergedDescriptorDatabase::FindFileContainingSymbol(
            const std::string & symbol_name,
            FileDescriptorProto * output)

    Find the file that declares the given fully-qualified symbol name.

    If found, fills in *output and returns true, otherwise returns false and leaves *output undefined.

    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 be22de33..2d7529eb 100644 --- a/content/reference/cpp/api-docs/google.protobuf.dynamic_message.md +++ b/content/reference/cpp/api-docs/google.protobuf.dynamic_message.md @@ -8,15 +8,15 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/dynamic_message.h>
    namespace google::protobuf

    Defines an implementation of Message which can emulate types which are not known at compile-time.

    Classes in this file

    Constructs implementations of Message which can emulate types which are not known at compile-time.
    Helper for computing a sorted list of map entries via reflection.

    class DynamicMessageFactory: public MessageFactory

    #include <google/protobuf/dynamic_message.h>
    namespace google::protobuf

    Constructs implementations of Message which can emulate types which are not known at compile-time.

    Sometimes you want to be able to manipulate protocol types that you don't know about at compile time. It would be nice to be able to construct a Message object which implements the message type given by any arbitrary Descriptor. DynamicMessage provides this.

    +

    #include <google/protobuf/dynamic_message.h>
    namespace google::protobuf

    Defines an implementation of Message which can emulate types which are not known at compile-time.

    Classes in this file

    Constructs implementations of Message which can emulate types which are not known at compile-time.
    Helper for computing a sorted list of map entries via reflection.

    class DynamicMessageFactory: public MessageFactory

    #include <google/protobuf/dynamic_message.h>
    namespace google::protobuf

    Constructs implementations of Message which can emulate types which are not known at compile-time.

    Sometimes you want to be able to manipulate protocol types that you don't know about at compile time. It would be nice to be able to construct a Message object which implements the message type given by any arbitrary Descriptor. DynamicMessage provides this.

    As it turns out, a DynamicMessage needs to construct extra information about its type in order to operate. Most of this information can be shared between all DynamicMessages of the same type. But, caching this information in some sort of global map would be a bad idea, since the cached information for a particular descriptor could outlive the descriptor itself. To avoid this problem, DynamicMessageFactory encapsulates this "cache". All DynamicMessages of the same type created from the same factory will share the same support data. Any Descriptors used with a particular factory must outlive the factory.

    -

    Members

    DynamicMessageFactory()
    Construct a DynamicMessageFactory that will search for extensions in the DescriptorPool in which the extendee is defined.
    DynamicMessageFactory(const DescriptorPool * pool)
    Construct a DynamicMessageFactory that will search for extensions in the given DescriptorPool. more...
    ~DynamicMessageFactory()
    void
    SetDelegateToGeneratedFactory(bool enable)
    Call this to tell the DynamicMessageFactory that if it is given a Descriptor d for which: more...

    implements MessageFactory

    virtual const Message *
    GetPrototype(const Descriptor * type)
    Given a Descriptor, constructs the default (prototype) Message of that type. more...

    DynamicMessageFactory::DynamicMessageFactory(
            const DescriptorPool * pool)

    Construct a DynamicMessageFactory that will search for extensions in the given DescriptorPool.

    DEPRECATED: Use CodedInputStream::SetExtensionRegistry() to tell the parser to look for extensions in an alternate pool. However, note that this is almost never what you want to do. Almost all users should use the zero-arg constructor.

    -

    void DynamicMessageFactory::SetDelegateToGeneratedFactory(
            bool enable)

    Call this to tell the DynamicMessageFactory that if it is given a Descriptor d for which:

    d->file()->pool() == DescriptorPool::generated_pool(),
    -

    then it should delegate to MessageFactory::generated_factory() instead of constructing a dynamic implementation of the message. In theory there is no down side to doing this, so it may become the default in the future.

    -

    virtual const Message * DynamicMessageFactory::GetPrototype(
            const Descriptor * type)

    Given a Descriptor, constructs the default (prototype) Message of that type.

    You can then call that message's New() method to construct a mutable message of that type.

    -

    Calling this method twice with the same Descriptor returns the same object. The returned object remains property of the factory and will be destroyed when the factory is destroyed. Also, any objects created by calling the prototype's New() method share some data with the prototype, so these must be destroyed before the DynamicMessageFactory is destroyed.

    +

    Members

    DynamicMessageFactory()
    Construct a DynamicMessageFactory that will search for extensions in the DescriptorPool in which the extendee is defined.
    DynamicMessageFactory(const DescriptorPool * pool)
    Construct a DynamicMessageFactory that will search for extensions in the given DescriptorPool. more...
    ~DynamicMessageFactory()
    void
    SetDelegateToGeneratedFactory(bool enable)
    Call this to tell the DynamicMessageFactory that if it is given a Descriptor d for which: more...

    implements MessageFactory

    virtual const Message *
    GetPrototype(const Descriptor * type)
    Given a Descriptor, constructs the default (prototype) Message of that type. more...

    DynamicMessageFactory::DynamicMessageFactory(
            const DescriptorPool * pool)

    Construct a DynamicMessageFactory that will search for extensions in the given DescriptorPool.

    DEPRECATED: Use CodedInputStream::SetExtensionRegistry() to tell the parser to look for extensions in an alternate pool. However, note that this is almost never what you want to do. Almost all users should use the zero-arg constructor.

    +

    void DynamicMessageFactory::SetDelegateToGeneratedFactory(
            bool enable)

    Call this to tell the DynamicMessageFactory that if it is given a Descriptor d for which:

    d->file()->pool() == DescriptorPool::generated_pool(),
    +

    then it should delegate to MessageFactory::generated_factory() instead of constructing a dynamic implementation of the message. In theory there is no down side to doing this, so it may become the default in the future.

    +

    virtual const Message * DynamicMessageFactory::GetPrototype(
            const Descriptor * type)

    Given a Descriptor, constructs the default (prototype) Message of that type.

    You can then call that message's New() method to construct a mutable message of that type.

    +

    Calling this method twice with the same Descriptor returns the same object. The returned object remains property of the factory and will be destroyed when the factory is destroyed. Also, any objects created by calling the prototype's New() method share some data with the prototype, so these must be destroyed before the DynamicMessageFactory is destroyed.

    The given descriptor must outlive the returned message, and hence must outlive the DynamicMessageFactory.

    The method is thread-safe.

    -

    class DynamicMapSorter

    #include <google/protobuf/dynamic_message.h>
    namespace google::protobuf

    Helper for computing a sorted list of map entries via reflection.

    Members

    static std::vector< const Message * >
    Sort(const Message & message, int map_size, const Reflection * reflection, const FieldDescriptor * field)
    +

    class DynamicMapSorter

    #include <google/protobuf/dynamic_message.h>
    namespace google::protobuf

    Helper for computing a sorted list of map entries via reflection.

    Members

    static std::vector< const Message * >
    Sort(const Message & message, int map_size, const Reflection * reflection, const FieldDescriptor * field)
    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 c1bfca93..d2d83fa1 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 @@ -6,7 +6,7 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/io/coded_stream.h>
    namespace google::protobuf::io

    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.

    In particular, these implement the varint encoding for integers, a simple variable-length encoding in which smaller numbers take fewer bytes.

    +

    #include <google/protobuf/io/coded_stream.h>
    namespace google::protobuf::io

    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.

    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 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.

    @@ -68,17 +68,17 @@ delete [] text;

    In theory, varint could be used to encode integers of any length. However, for practicality we set a limit at 64 bits. The maximum encoded length of a number is thus 10 bytes.

    -

    Classes in this file

    Class which reads and decodes binary data which is composed of varint- encoded integers and fixed-width pieces.
    EpsCopyOutputStream wraps a ZeroCopyOutputStream and exposes a new stream, which has the property you can write kSlopBytes (16 bytes) from the current position without bounds checks.
    Class which encodes and writes binary data which is composed of varint- encoded integers and fixed-width pieces.
    Compile-time equivalent of VarintSize32().

    class CodedInputStream

    #include <google/protobuf/io/coded_stream.h>
    namespace google::protobuf::io

    Class which reads and decodes binary data which is composed of varint- encoded integers and fixed-width pieces.

    Wraps a ZeroCopyInputStream. Most users will not need to deal with CodedInputStream.

    +

    Classes in this file

    Class which reads and decodes binary data which is composed of varint- encoded integers and fixed-width pieces.
    EpsCopyOutputStream wraps a ZeroCopyOutputStream and exposes a new stream, which has the property you can write kSlopBytes (16 bytes) from the current position without bounds checks.
    Class which encodes and writes binary data which is composed of varint- encoded integers and fixed-width pieces.
    Compile-time equivalent of VarintSize32().

    class CodedInputStream

    #include <google/protobuf/io/coded_stream.h>
    namespace google::protobuf::io

    Class which reads and decodes binary data which is composed of varint- encoded integers and fixed-width pieces.

    Wraps a ZeroCopyInputStream. Most users will not need to deal with CodedInputStream.

    Most methods of CodedInputStream that return a bool return false if an underlying I/O error occurs or if the data is malformed. Once such a failure occurs, the CodedInputStream is broken and is no longer useful. After a failure, callers also should assume writes to "out" args may have occurred, though nothing useful can be determined from those writes.

    -

    Members

    explicit
    CodedInputStream(ZeroCopyInputStream * input)
    Create a CodedInputStream that reads from the given ZeroCopyInputStream.
    explicit
    CodedInputStream(const uint8 * buffer, int size)
    Create a CodedInputStream that reads from the given flat array. more...
    ~CodedInputStream()
    Destroy the CodedInputStream and position the underlying ZeroCopyInputStream at the first unread byte. more...
    bool
    IsFlat() const
    Return true if this CodedInputStream reads from a flat array instead of a ZeroCopyInputStream.
    bool
    Skip(int count)
    Skips a number of bytes. more...
    bool
    GetDirectBufferPointer(const void ** data, int * size)
    Sets *data to point directly at the unread part of the CodedInputStream's underlying buffer, and *size to the size of that buffer, but does not advance the stream's current position. more...
    void
    GetDirectBufferPointerInline(const void ** data, int * size)
    Like GetDirectBufferPointer, but this method is inlined, and does not attempt to Refresh() if the buffer is currently empty.
    bool
    ReadRaw(void * buffer, int size)
    Read raw bytes, copying them into the given buffer.
    bool
    ReadString(std::string * buffer, int size)
    Like ReadRaw, but reads into a string.
    bool
    ReadLittleEndian32(uint32 * value)
    Read a 32-bit little-endian integer.
    bool
    ReadLittleEndian64(uint64 * value)
    Read a 64-bit little-endian integer.
    bool
    ReadVarint32(uint32 * value)
    Read an unsigned integer with Varint encoding, truncating to 32 bits. more...
    bool
    ReadVarint64(uint64 * value)
    Read an unsigned integer with Varint encoding.
    bool
    ReadVarintSizeAsInt(int * value)
    Reads a varint off the wire into an "int". more...
    uint32
    ReadTag()
    Read a tag. more...
    uint32
    ReadTagNoLastTag()
    std::pair< uint32, bool >
    ReadTagWithCutoff(uint32 cutoff)
    This usually a faster alternative to ReadTag() when cutoff is a manifest constant. more...
    std::pair< uint32, bool >
    ReadTagWithCutoffNoLastTag(uint32 cutoff)
    bool
    ExpectTag(uint32 expected)
    Usually returns true if calling ReadVarint32() now would produce the given value. more...
    bool
    ExpectAtEnd()
    Usually returns true if no more bytes can be read. more...
    bool
    LastTagWas(uint32 expected)
    If the last call to ReadTag() or ReadTagWithCutoff() returned the given value, returns true. more...
    void
    SetLastTag(uint32 tag)
    bool
    ConsumedEntireMessage()
    When parsing message (but NOT a group), this method must be called immediately after MergeFromCodedStream() returns (if it returns true) to further verify that the message ended in a legitimate way. more...
    void
    SetConsumed()
    static const uint8 *
    ReadLittleEndian32FromArray(const uint8 * buffer, uint32 * value)
    These methods read from an externally provided buffer. more...
    static const uint8 *
    ReadLittleEndian64FromArray(const uint8 * buffer, uint64 * value)
    Read a 64-bit little-endian integer. more...
    static const uint8 *
    ExpectTagFromArray(const uint8 * buffer, uint32 expected)
    Like above, except this reads from the specified buffer. more...

    Limits

    Limits are used when parsing length-delimited embedded messages. After the message's length is read, PushLimit() is used to prevent the CodedInputStream from reading beyond that length. Once the embedded message has been parsed, PopLimit() is called to undo the limit.
    typedef
    int Limit
    Opaque type used with PushLimit() and PopLimit(). more...
    Limit
    PushLimit(int byte_limit)
    Places a limit on the number of bytes that the stream may read, starting from the current position. more...
    void
    PopLimit(Limit limit)
    Pops the last limit pushed by PushLimit(). more...
    int
    BytesUntilLimit() const
    Returns the number of bytes left until the nearest limit on the stack is hit, or -1 if no limits are in place.
    int
    CurrentPosition() const
    Returns current position relative to the beginning of the input stream.

    Total Bytes Limit

    To prevent malicious users from sending excessively large messages and causing memory exhaustion, CodedInputStream imposes a hard limit on the total number of bytes it will read.
    int = { +

    Members

    explicit
    CodedInputStream(ZeroCopyInputStream * input)
    Create a CodedInputStream that reads from the given ZeroCopyInputStream.
    explicit
    CodedInputStream(const uint8 * buffer, int size)
    Create a CodedInputStream that reads from the given flat array. more...
    ~CodedInputStream()
    Destroy the CodedInputStream and position the underlying ZeroCopyInputStream at the first unread byte. more...
    bool
    IsFlat() const
    Return true if this CodedInputStream reads from a flat array instead of a ZeroCopyInputStream.
    bool
    Skip(int count)
    Skips a number of bytes. more...
    bool
    GetDirectBufferPointer(const void ** data, int * size)
    Sets *data to point directly at the unread part of the CodedInputStream's underlying buffer, and *size to the size of that buffer, but does not advance the stream's current position. more...
    void
    GetDirectBufferPointerInline(const void ** data, int * size)
    Like GetDirectBufferPointer, but this method is inlined, and does not attempt to Refresh() if the buffer is currently empty.
    bool
    ReadRaw(void * buffer, int size)
    Read raw bytes, copying them into the given buffer.
    bool
    ReadString(std::string * buffer, int size)
    Like ReadRaw, but reads into a string.
    bool
    ReadLittleEndian32(uint32 * value)
    Read a 32-bit little-endian integer.
    bool
    ReadLittleEndian64(uint64 * value)
    Read a 64-bit little-endian integer.
    bool
    ReadVarint32(uint32 * value)
    Read an unsigned integer with Varint encoding, truncating to 32 bits. more...
    bool
    ReadVarint64(uint64 * value)
    Read an unsigned integer with Varint encoding.
    bool
    ReadVarintSizeAsInt(int * value)
    Reads a varint off the wire into an "int". more...
    uint32
    ReadTag()
    Read a tag. more...
    uint32
    ReadTagNoLastTag()
    std::pair< uint32, bool >
    ReadTagWithCutoff(uint32 cutoff)
    This usually a faster alternative to ReadTag() when cutoff is a manifest constant. more...
    std::pair< uint32, bool >
    ReadTagWithCutoffNoLastTag(uint32 cutoff)
    bool
    ExpectTag(uint32 expected)
    Usually returns true if calling ReadVarint32() now would produce the given value. more...
    bool
    ExpectAtEnd()
    Usually returns true if no more bytes can be read. more...
    bool
    LastTagWas(uint32 expected)
    If the last call to ReadTag() or ReadTagWithCutoff() returned the given value, returns true. more...
    void
    SetLastTag(uint32 tag)
    bool
    ConsumedEntireMessage()
    When parsing message (but NOT a group), this method must be called immediately after MergeFromCodedStream() returns (if it returns true) to further verify that the message ended in a legitimate way. more...
    void
    SetConsumed()
    static const uint8 *
    ReadLittleEndian32FromArray(const uint8 * buffer, uint32 * value)
    These methods read from an externally provided buffer. more...
    static const uint8 *
    ReadLittleEndian64FromArray(const uint8 * buffer, uint64 * value)
    Read a 64-bit little-endian integer. more...
    static const uint8 *
    ExpectTagFromArray(const uint8 * buffer, uint32 expected)
    Like above, except this reads from the specified buffer. more...

    Limits

    Limits are used when parsing length-delimited embedded messages. After the message's length is read, PushLimit() is used to prevent the CodedInputStream from reading beyond that length. Once the embedded message has been parsed, PopLimit() is called to undo the limit.
    typedef
    int Limit
    Opaque type used with PushLimit() and PopLimit(). more...
    Limit
    PushLimit(int byte_limit)
    Places a limit on the number of bytes that the stream may read, starting from the current position. more...
    void
    PopLimit(Limit limit)
    Pops the last limit pushed by PushLimit(). more...
    int
    BytesUntilLimit() const
    Returns the number of bytes left until the nearest limit on the stack is hit, or -1 if no limits are in place.
    int
    CurrentPosition() const
    Returns current position relative to the beginning of the input stream.

    Total Bytes Limit

    To prevent malicious users from sending excessively large messages and causing memory exhaustion, CodedInputStream imposes a hard limit on the total number of bytes it will read.
    int = { SetTotalBytesLimit(total_bytes_limit)
    void
    SetTotalBytesLimit(int total_bytes_limit)
    Sets the maximum number of bytes that this CodedInputStream will read before refusing to continue. more...
    PROTOBUF_DEPRECATED_MSG("Please use the single parameter version of SetTotalBytesLimit(). The " "second parameter is ignored." )
    int
    BytesUntilTotalBytesLimit() const
    The Total Bytes Limit minus the Current Position, or -1 if the total bytes limit is INT_MAX.

    Recursion Limit

    To prevent corrupt or malicious messages from causing stack overflows, we must keep track of the depth of recursion when parsing embedded messages and groups.

    CodedInputStream keeps track of this because it is the only object that is passed down the stack during parsing.

    void
    SetRecursionLimit(int limit)
    Sets the maximum recursion depth. The default is 100.
    int
    RecursionBudget()
    bool
    IncrementRecursionDepth()
    Increments the current recursion depth. more...
    void
    DecrementRecursionDepth()
    Decrements the recursion depth if possible.
    void
    UnsafeDecrementRecursionDepth()
    Decrements the recursion depth blindly. more...
    std::pair< CodedInputStream::Limit, int >
    IncrementRecursionDepthAndPushLimit(int byte_limit)
    Shorthand for make_pair(PushLimit(byte_limit), –recursion_budget_). more...
    Limit
    ReadLengthAndPushLimit()
    Shorthand for PushLimit(ReadVarint32(&length) ? length : 0).
    bool
    DecrementRecursionDepthAndPopLimit(Limit limit)
    Helper that is equivalent to: { bool result = ConsumedEntireMessage(); PopLimit(limit); UnsafeDecrementRecursionDepth(); return result; } Using this can reduce code size and complexity in some cases. more...
    bool
    CheckEntireMessageConsumedAndPopLimit(Limit limit)
    Helper that is equivalent to: { bool result = ConsumedEntireMessage(); PopLimit(limit); return result; } Using this can reduce code size and complexity in some cases.
    static int
    GetDefaultRecursionLimit()

    Extension Registry

    ADVANCED USAGE: 99.9% of people can ignore this section.

    -

    By default, when parsing extensions, the parser looks for extension definitions in the pool which owns the outer message's Descriptor. However, you may call SetExtensionRegistry() to provide an alternative pool instead. This makes it possible, for example, to parse a message using a generated class, but represent some extensions using DynamicMessage.

    -
    void
    SetExtensionRegistry(const DescriptorPool * pool, MessageFactory * factory)
    Set the pool used to look up extensions. more...
    const DescriptorPool *
    GetExtensionPool()
    Get the DescriptorPool set via SetExtensionRegistry(), or NULL if no pool has been provided.
    MessageFactory *
    GetExtensionFactory()
    Get the MessageFactory set via SetExtensionRegistry(), or NULL if no factory has been provided.

    explicit CodedInputStream::CodedInputStream(
            const uint8 * buffer,
            int size)

    Create a CodedInputStream that reads from the given flat array.

    This is faster than using an ArrayInputStream. PushLimit(size) is implied by this constructor.

    -

    CodedInputStream::~CodedInputStream()

    Destroy the CodedInputStream and position the underlying ZeroCopyInputStream at the first unread byte.

    If an error occurred while reading (causing a method to return false), then the exact position of the input stream may be anywhere between the last value that was read successfully and the stream's byte limit.

    +

    By default, when parsing extensions, the parser looks for extension definitions in the pool which owns the outer message's Descriptor. However, you may call SetExtensionRegistry() to provide an alternative pool instead. This makes it possible, for example, to parse a message using a generated class, but represent some extensions using DynamicMessage.

    +
    void
    SetExtensionRegistry(const DescriptorPool * pool, MessageFactory * factory)
    Set the pool used to look up extensions. more...
    const DescriptorPool *
    GetExtensionPool()
    Get the DescriptorPool set via SetExtensionRegistry(), or NULL if no pool has been provided.
    MessageFactory *
    GetExtensionFactory()
    Get the MessageFactory set via SetExtensionRegistry(), or NULL if no factory has been provided.

    explicit CodedInputStream::CodedInputStream(
            const uint8 * buffer,
            int size)

    Create a CodedInputStream that reads from the given flat array.

    This is faster than using an ArrayInputStream. PushLimit(size) is implied by this constructor.

    +

    CodedInputStream::~CodedInputStream()

    Destroy the CodedInputStream and position the underlying ZeroCopyInputStream at the first unread byte.

    If an error occurred while reading (causing a method to return false), then the exact position of the input stream may be anywhere between the last value that was read successfully and the stream's byte limit.


    bool CodedInputStream::Skip(
            int count)

    Skips a number of bytes.

    Returns false if an underlying read error occurs.


    bool CodedInputStream::GetDirectBufferPointer(
            const void ** data,
            int * size)

    Sets *data to point directly at the unread part of the CodedInputStream's underlying buffer, and *size to the size of that buffer, but does not advance the stream's current position.

    This will always either produce a non-empty buffer or return false. If the caller consumes any of this data, it should then call Skip() to skip over the consumed bytes. This may be useful for implementing external fast parsing routines for types of data not covered by the CodedInputStream interface.


    bool CodedInputStream::ReadVarint32(
            uint32 * value)

    Read an unsigned integer with Varint encoding, truncating to 32 bits.

    Reading a 32-bit value is equivalent to reading a 64-bit one and casting it to uint32, but may be more efficient.

    @@ -109,32 +109,32 @@ delete [] text;

    void CodedInputStream::UnsafeDecrementRecursionDepth()

    Decrements the recursion depth blindly.

    This is faster than DecrementRecursionDepth(). It should be used only if all previous increments to recursion depth were successful.


    std::pair< CodedInputStream::Limit, int >
        CodedInputStream::IncrementRecursionDepthAndPushLimit(
            int byte_limit)

    Shorthand for make_pair(PushLimit(byte_limit), –recursion_budget_).

    Using this can reduce code size and complexity in some cases. The caller is expected to check that the second part of the result is non-negative (to bail out if the depth of recursion is too high) and, if all is well, to later pass the first part of the result to PopLimit() or similar.


    bool CodedInputStream::DecrementRecursionDepthAndPopLimit(
            Limit limit)

    Helper that is equivalent to: { bool result = ConsumedEntireMessage(); PopLimit(limit); UnsafeDecrementRecursionDepth(); return result; } Using this can reduce code size and complexity in some cases.

    Do not use unless the current recursion depth is greater than zero.

    -

    void CodedInputStream::SetExtensionRegistry(
            const DescriptorPool * pool,
            MessageFactory * factory)

    Set the pool used to look up extensions.

    Most users do not need to call this as the correct pool will be chosen automatically.

    +

    void CodedInputStream::SetExtensionRegistry(
            const DescriptorPool * pool,
            MessageFactory * factory)

    Set the pool used to look up extensions.

    Most users do not need to call this as the correct pool will be chosen automatically.

    WARNING: It is very easy to misuse this. Carefully read the requirements below. Do not use this unless you are sure you need it. Almost no one does.

    Let's say you are parsing a message into message object m, and you want to take advantage of SetExtensionRegistry(). You must follow these requirements:

    -

    The given DescriptorPool must contain m->GetDescriptor(). It is not sufficient for it to simply contain a descriptor that has the same name and content – it must be the exact object. In other words:

    +

    The given DescriptorPool must contain m->GetDescriptor(). It is not sufficient for it to simply contain a descriptor that has the same name and content – it must be the exact object. In other words:

    assert(pool->FindMessageTypeByName(m->GetDescriptor()->full_name()) ==
            m->GetDescriptor());

    There are two ways to satisfy this requirement: 1) Use m->GetDescriptor()->pool() as the pool. This is generally useless

    because this is the pool that would be used anyway if you didn't call
     SetExtensionRegistry() at all.
    -

    2) Use a DescriptorPool which has m->GetDescriptor()->pool() as an

    +

    2) Use a DescriptorPool which has m->GetDescriptor()->pool() as an

    "underlay".  Read the documentation for DescriptorPool for more
     information about underlays.
    -

    You must also provide a MessageFactory. This factory will be used to construct Message objects representing extensions. The factory's GetPrototype() MUST return non-NULL for any Descriptor which can be found through the provided pool.

    -

    If the provided factory might return instances of protocol-compiler- generated (i.e. compiled-in) types, or if the outer message object m is a generated type, then the given factory MUST have this property: If GetPrototype() is given a Descriptor which resides in DescriptorPool::generated_pool(), the factory MUST return the same prototype which MessageFactory::generated_factory() would return. That is, given a descriptor for a generated type, the factory must return an instance of the generated class (NOT DynamicMessage). However, when given a descriptor for a type that is NOT in generated_pool, the factory is free to return any implementation.

    +

    You must also provide a MessageFactory. This factory will be used to construct Message objects representing extensions. The factory's GetPrototype() MUST return non-NULL for any Descriptor which can be found through the provided pool.

    +

    If the provided factory might return instances of protocol-compiler- generated (i.e. compiled-in) types, or if the outer message object m is a generated type, then the given factory MUST have this property: If GetPrototype() is given a Descriptor which resides in DescriptorPool::generated_pool(), the factory MUST return the same prototype which MessageFactory::generated_factory() would return. That is, given a descriptor for a generated type, the factory must return an instance of the generated class (NOT DynamicMessage). However, when given a descriptor for a type that is NOT in generated_pool, the factory is free to return any implementation.

    The reason for this requirement is that generated sub-objects may be accessed via the standard (non-reflection) extension accessor methods, and these methods will down-cast the object to the generated class type. If the object is not actually of that type, the results would be undefined. On the other hand, if an extension is not compiled in, then there is no way the code could end up accessing it via the standard accessors – the only way to access the extension is via reflection. When using reflection, DynamicMessage and generated messages are indistinguishable, so it's fine if these objects are represented using DynamicMessage.

    -

    Using DynamicMessageFactory on which you have called SetDelegateToGeneratedFactory(true) should be sufficient to satisfy the above requirement.

    +

    Using DynamicMessageFactory on which you have called SetDelegateToGeneratedFactory(true) should be sufficient to satisfy the above requirement.

    If either pool or factory is NULL, both must be NULL.

    Note that this feature is ignored when parsing "lite" messages as they do not have descriptors.

    -

    class EpsCopyOutputStream

    #include <google/protobuf/io/coded_stream.h>
    namespace google::protobuf::io

    EpsCopyOutputStream wraps a ZeroCopyOutputStream and exposes a new stream, which has the property you can write kSlopBytes (16 bytes) from the current position without bounds checks.

    The cursor into the stream is managed by the user of the class and is an explicit parameter in the methods. Careful use of this class, ie. keep ptr a local variable, eliminates the need to for the compiler to sync the ptr value between register and memory.

    -

    Members

    enum
    @33
    EpsCopyOutputStream(ZeroCopyOutputStream * stream, bool deterministic, uint8 ** pp)
    Initialize from a stream.
    EpsCopyOutputStream(void * data, int size, bool deterministic)
    Only for array serialization. more...
    EpsCopyOutputStream(void * data, int size, ZeroCopyOutputStream * stream, bool deterministic, uint8 ** pp)
    Initialize from stream but with the first buffer already given (eager).
    uint8 *
    Trim(uint8 * ptr)
    Flush everything that's written into the underlying ZeroCopyOutputStream and trims the underlying stream to the location of ptr.
    PROTOBUF_MUST_USE_RESULT uint8 *
    EnsureSpace(uint8 * ptr)
    After this it's guaranteed you can safely write kSlopBytes to ptr. more...
    uint8 *
    WriteRaw(const void * data, int size, uint8 * ptr)
    uint8 *
    WriteRawMaybeAliased(const void * data, int size, uint8 * ptr)
    Writes the buffer specified by data, size to the stream. more...
    uint8 *
    WriteStringMaybeAliased(uint32 num, const std::string & s, uint8 * ptr)
    uint8 *
    WriteBytesMaybeAliased(uint32 num, const std::string & s, uint8 * ptr)
    template uint8 *
    WriteString(uint32 num, const T & s, uint8 * ptr)
    template uint8 *
    WriteBytes(uint32 num, const T & s, uint8 * ptr)
    template uint8 *
    WriteInt32Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteUInt32Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteSInt32Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteInt64Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteUInt64Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteSInt64Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteEnumPacked(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteFixedPacked(int num, const T & r, uint8 * ptr)
    bool
    HadError() const
    Returns true if there was an underlying I/O error since this object was created.
    void
    EnableAliasing(bool enabled)
    Instructs the EpsCopyOutputStream to allow the underlying ZeroCopyOutputStream to hold pointers to the original structure instead of copying, if it supports it (i.e. more...
    void
    SetSerializationDeterministic(bool value)
    bool
    IsSerializationDeterministic() const
    int64
    ByteCount(uint8 * ptr) const
    The number of bytes written to the stream at position ptr, relative to the stream's overall position.
    uint8 *
    SetInitialBuffer(void * data, int size)
    These methods are for CodedOutputStream. more...

    enum EpsCopyOutputStream::@33 {
      kSlopBytes = = 16
    }

    kSlopBytes

    EpsCopyOutputStream::EpsCopyOutputStream(
            void * data,
            int size,
            bool deterministic)

    Only for array serialization.

    No overflow protection, end_ will be the pointed to the end of the array. When using this the total size is already known, so no need to maintain the slop region.

    +

    class EpsCopyOutputStream

    #include <google/protobuf/io/coded_stream.h>
    namespace google::protobuf::io

    EpsCopyOutputStream wraps a ZeroCopyOutputStream and exposes a new stream, which has the property you can write kSlopBytes (16 bytes) from the current position without bounds checks.

    The cursor into the stream is managed by the user of the class and is an explicit parameter in the methods. Careful use of this class, ie. keep ptr a local variable, eliminates the need to for the compiler to sync the ptr value between register and memory.

    +

    Members

    enum
    @33
    EpsCopyOutputStream(ZeroCopyOutputStream * stream, bool deterministic, uint8 ** pp)
    Initialize from a stream.
    EpsCopyOutputStream(void * data, int size, bool deterministic)
    Only for array serialization. more...
    EpsCopyOutputStream(void * data, int size, ZeroCopyOutputStream * stream, bool deterministic, uint8 ** pp)
    Initialize from stream but with the first buffer already given (eager).
    uint8 *
    Trim(uint8 * ptr)
    Flush everything that's written into the underlying ZeroCopyOutputStream and trims the underlying stream to the location of ptr.
    PROTOBUF_MUST_USE_RESULT uint8 *
    EnsureSpace(uint8 * ptr)
    After this it's guaranteed you can safely write kSlopBytes to ptr. more...
    uint8 *
    WriteRaw(const void * data, int size, uint8 * ptr)
    uint8 *
    WriteRawMaybeAliased(const void * data, int size, uint8 * ptr)
    Writes the buffer specified by data, size to the stream. more...
    uint8 *
    WriteStringMaybeAliased(uint32 num, const std::string & s, uint8 * ptr)
    uint8 *
    WriteBytesMaybeAliased(uint32 num, const std::string & s, uint8 * ptr)
    template uint8 *
    WriteString(uint32 num, const T & s, uint8 * ptr)
    template uint8 *
    WriteBytes(uint32 num, const T & s, uint8 * ptr)
    template uint8 *
    WriteInt32Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteUInt32Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteSInt32Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteInt64Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteUInt64Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteSInt64Packed(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteEnumPacked(int num, const T & r, int size, uint8 * ptr)
    template uint8 *
    WriteFixedPacked(int num, const T & r, uint8 * ptr)
    bool
    HadError() const
    Returns true if there was an underlying I/O error since this object was created.
    void
    EnableAliasing(bool enabled)
    Instructs the EpsCopyOutputStream to allow the underlying ZeroCopyOutputStream to hold pointers to the original structure instead of copying, if it supports it (i.e. more...
    void
    SetSerializationDeterministic(bool value)
    bool
    IsSerializationDeterministic() const
    int64
    ByteCount(uint8 * ptr) const
    The number of bytes written to the stream at position ptr, relative to the stream's overall position.
    uint8 *
    SetInitialBuffer(void * data, int size)
    These methods are for CodedOutputStream. more...

    enum EpsCopyOutputStream::@33 {
      kSlopBytes = = 16
    }

    kSlopBytes

    EpsCopyOutputStream::EpsCopyOutputStream(
            void * data,
            int size,
            bool deterministic)

    Only for array serialization.

    No overflow protection, end_ will be the pointed to the end of the array. When using this the total size is already known, so no need to maintain the slop region.


    PROTOBUF_MUST_USE_RESULT uint8 *
        EpsCopyOutputStream::EnsureSpace(
            uint8 * ptr)

    After this it's guaranteed you can safely write kSlopBytes to ptr.

    This will never fail! The underlying stream can produce an error. Use HadError to check for errors.

    -

    uint8 * EpsCopyOutputStream::WriteRawMaybeAliased(
            const void * data,
            int size,
            uint8 * ptr)

    Writes the buffer specified by data, size to the stream.

    Possibly by aliasing the buffer (ie. not copying the data). The caller is responsible to make sure the buffer is alive for the duration of the ZeroCopyOutputStream.

    -

    void EpsCopyOutputStream::EnableAliasing(
            bool enabled)

    Instructs the EpsCopyOutputStream 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().

    +

    uint8 * EpsCopyOutputStream::WriteRawMaybeAliased(
            const void * data,
            int size,
            uint8 * ptr)

    Writes the buffer specified by data, size to the stream.

    Possibly by aliasing the buffer (ie. not copying the data). The caller is responsible to make sure the buffer is alive for the duration of the ZeroCopyOutputStream.

    +

    void EpsCopyOutputStream::EnableAliasing(
            bool enabled)

    Instructs the EpsCopyOutputStream 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.


    uint8 * EpsCopyOutputStream::SetInitialBuffer(
            void * data,
            int size)

    These methods are for CodedOutputStream.

    Ideally they should be private but to match current behavior of CodedOutputStream as close as possible we allow it some functionality.

    -

    class CodedOutputStream

    #include <google/protobuf/io/coded_stream.h>
    namespace google::protobuf::io

    Class which encodes and writes binary data which is composed of varint- encoded integers and fixed-width pieces.

    Wraps a ZeroCopyOutputStream. Most users will not need to deal with CodedOutputStream.

    +

    class CodedOutputStream

    #include <google/protobuf/io/coded_stream.h>
    namespace google::protobuf::io

    Class which encodes and writes binary data which is composed of varint- encoded integers and fixed-width pieces.

    Wraps a ZeroCopyOutputStream. Most users will not need to deal with CodedOutputStream.

    Most methods of CodedOutputStream which return a bool return false if an underlying I/O error occurs. Once such a failure occurs, the CodedOutputStream is broken and is no longer useful. The Write* methods do not return the stream status, but will invalidate the stream if an error occurs. The client can probe HadError() to determine the status.

    Note that every method of CodedOutputStream which writes some data has a corresponding static "ToArray" version. These versions write directly to the provided buffer, returning a pointer past the last written byte. They require that the buffer has sufficient capacity for the encoded data. This allows an optimization where we check if an output stream has enough space for an entire message before we start writing and, if there is, we call only the ToArray methods to avoid doing bound checks for each individual value. i.e., in the example above:

    CodedOutputStream* coded_output = new CodedOutputStream(raw_output);
    @@ -163,24 +163,24 @@ if (buffer != nullptr) {
     }
     
     delete coded_output;
    -

    Members

    explicit
    CodedOutputStream(ZeroCopyOutputStream * stream)
    Create an CodedOutputStream that writes to the given ZeroCopyOutputStream.
    CodedOutputStream(ZeroCopyOutputStream * stream, bool do_eager_refresh)
    ~CodedOutputStream()
    Destroy the CodedOutputStream and position the underlying ZeroCopyOutputStream immediately after the last byte written.
    bool
    HadError()
    Returns true if there was an underlying I/O error since this object was created. more...
    void
    Trim()
    Trims any unused space in the underlying buffer so that its size matches the number of bytes written by this stream. more...
    bool
    Skip(int count)
    Skips a number of bytes, leaving the bytes unmodified in the underlying buffer. more...
    bool
    GetDirectBufferPointer(void ** data, int * size)
    Sets *data to point directly at the unwritten part of the CodedOutputStream's underlying buffer, and *size to the size of that buffer, but does not advance the stream's current position. more...
    uint8 *
    GetDirectBufferForNBytesAndAdvance(int size)
    If there are at least "size" bytes available in the current buffer, returns a pointer directly into the buffer and advances over these bytes. more...
    void
    WriteRaw(const void * buffer, int size)
    Write raw bytes, copying them from the given buffer.
    void
    WriteRawMaybeAliased(const void * data, int size)
    Like WriteRaw() but will try to write aliased data if aliasing is turned on.
    void
    WriteString(const std::string & str)
    Equivalent to WriteRaw(str.data(), str.size()).
    void
    WriteLittleEndian32(uint32 value)
    Write a 32-bit little-endian integer.
    void
    WriteLittleEndian64(uint64 value)
    Write a 64-bit little-endian integer.
    void
    WriteVarint32(uint32 value)
    Write an unsigned integer with Varint encoding. more...
    void
    WriteVarint64(uint64 value)
    Write an unsigned integer with Varint encoding.
    void
    WriteVarint32SignExtended(int32 value)
    Equivalent to WriteVarint32() except when the value is negative, in which case it must be sign-extended to a full 10 bytes.
    void
    WriteTag(uint32 value)
    This is identical to WriteVarint32(), but optimized for writing tags. more...
    int
    ByteCount() const
    Returns the total number of bytes written since this object was created.
    void
    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. more...
    void
    SetSerializationDeterministic(bool value)
    Indicate to the serializer whether the user wants derministic serialization. more...
    bool
    IsSerializationDeterministic() const
    Return whether the user wants deterministic serialization. See above.
    template void
    Serialize(const Func & func)
    uint8 *
    Cur() const
    void
    SetCur(uint8 * ptr)
    EpsCopyOutputStream *
    EpsCopy()
    static uint8 *
    WriteRawToArray(const void * buffer, int size, uint8 * target)
    Like WriteRaw() but writing directly to the target array. more...
    static uint8 *
    WriteStringToArray(const std::string & str, uint8 * target)
    Like WriteString() but writing directly to the target array.
    static uint8 *
    WriteStringWithSizeToArray(const std::string & str, uint8 * target)
    Write the varint-encoded size of str followed by str.
    static uint8 *
    WriteLittleEndian32ToArray(uint32 value, uint8 * target)
    Like WriteLittleEndian32() but writing directly to the target array.
    static uint8 *
    WriteLittleEndian64ToArray(uint64 value, uint8 * target)
    Like WriteLittleEndian64() but writing directly to the target array.
    static uint8 *
    WriteVarint32ToArray(uint32 value, uint8 * target)
    Like WriteVarint32() but writing directly to the target array.
    static uint8 *
    WriteVarint32ToArrayOutOfLine(uint32 value, uint8 * target)
    Like WriteVarint32() but writing directly to the target array, and with the less common-case paths being out of line rather than inlined.
    static uint8 *
    WriteVarint64ToArray(uint64 value, uint8 * target)
    Like WriteVarint64() but writing directly to the target array.
    static uint8 *
    WriteVarint32SignExtendedToArray(int32 value, uint8 * target)
    Like WriteVarint32SignExtended() but writing directly to the target array.
    static uint8 *
    WriteTagToArray(uint32 value, uint8 * target)
    Like WriteTag() but writing directly to the target array.
    static size_t
    VarintSize32(uint32 value)
    Returns the number of bytes needed to encode the given value as a varint.
    static size_t
    VarintSize64(uint64 value)
    Returns the number of bytes needed to encode the given value as a varint.
    static size_t
    VarintSize32SignExtended(int32 value)
    If negative, 10 bytes. Otherwise, same as VarintSize32().
    static bool
    IsDefaultSerializationDeterministic()

    bool CodedOutputStream::HadError()

    Returns true if there was an underlying I/O error since this object was created.

    On should call Trim before this function in order to catch all errors.

    +

    Members

    explicit
    CodedOutputStream(ZeroCopyOutputStream * stream)
    Create an CodedOutputStream that writes to the given ZeroCopyOutputStream.
    CodedOutputStream(ZeroCopyOutputStream * stream, bool do_eager_refresh)
    ~CodedOutputStream()
    Destroy the CodedOutputStream and position the underlying ZeroCopyOutputStream immediately after the last byte written.
    bool
    HadError()
    Returns true if there was an underlying I/O error since this object was created. more...
    void
    Trim()
    Trims any unused space in the underlying buffer so that its size matches the number of bytes written by this stream. more...
    bool
    Skip(int count)
    Skips a number of bytes, leaving the bytes unmodified in the underlying buffer. more...
    bool
    GetDirectBufferPointer(void ** data, int * size)
    Sets *data to point directly at the unwritten part of the CodedOutputStream's underlying buffer, and *size to the size of that buffer, but does not advance the stream's current position. more...
    uint8 *
    GetDirectBufferForNBytesAndAdvance(int size)
    If there are at least "size" bytes available in the current buffer, returns a pointer directly into the buffer and advances over these bytes. more...
    void
    WriteRaw(const void * buffer, int size)
    Write raw bytes, copying them from the given buffer.
    void
    WriteRawMaybeAliased(const void * data, int size)
    Like WriteRaw() but will try to write aliased data if aliasing is turned on.
    void
    WriteString(const std::string & str)
    Equivalent to WriteRaw(str.data(), str.size()).
    void
    WriteLittleEndian32(uint32 value)
    Write a 32-bit little-endian integer.
    void
    WriteLittleEndian64(uint64 value)
    Write a 64-bit little-endian integer.
    void
    WriteVarint32(uint32 value)
    Write an unsigned integer with Varint encoding. more...
    void
    WriteVarint64(uint64 value)
    Write an unsigned integer with Varint encoding.
    void
    WriteVarint32SignExtended(int32 value)
    Equivalent to WriteVarint32() except when the value is negative, in which case it must be sign-extended to a full 10 bytes.
    void
    WriteTag(uint32 value)
    This is identical to WriteVarint32(), but optimized for writing tags. more...
    int
    ByteCount() const
    Returns the total number of bytes written since this object was created.
    void
    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. more...
    void
    SetSerializationDeterministic(bool value)
    Indicate to the serializer whether the user wants derministic serialization. more...
    bool
    IsSerializationDeterministic() const
    Return whether the user wants deterministic serialization. See above.
    template void
    Serialize(const Func & func)
    uint8 *
    Cur() const
    void
    SetCur(uint8 * ptr)
    EpsCopyOutputStream *
    EpsCopy()
    static uint8 *
    WriteRawToArray(const void * buffer, int size, uint8 * target)
    Like WriteRaw() but writing directly to the target array. more...
    static uint8 *
    WriteStringToArray(const std::string & str, uint8 * target)
    Like WriteString() but writing directly to the target array.
    static uint8 *
    WriteStringWithSizeToArray(const std::string & str, uint8 * target)
    Write the varint-encoded size of str followed by str.
    static uint8 *
    WriteLittleEndian32ToArray(uint32 value, uint8 * target)
    Like WriteLittleEndian32() but writing directly to the target array.
    static uint8 *
    WriteLittleEndian64ToArray(uint64 value, uint8 * target)
    Like WriteLittleEndian64() but writing directly to the target array.
    static uint8 *
    WriteVarint32ToArray(uint32 value, uint8 * target)
    Like WriteVarint32() but writing directly to the target array.
    static uint8 *
    WriteVarint32ToArrayOutOfLine(uint32 value, uint8 * target)
    Like WriteVarint32() but writing directly to the target array, and with the less common-case paths being out of line rather than inlined.
    static uint8 *
    WriteVarint64ToArray(uint64 value, uint8 * target)
    Like WriteVarint64() but writing directly to the target array.
    static uint8 *
    WriteVarint32SignExtendedToArray(int32 value, uint8 * target)
    Like WriteVarint32SignExtended() but writing directly to the target array.
    static uint8 *
    WriteTagToArray(uint32 value, uint8 * target)
    Like WriteTag() but writing directly to the target array.
    static size_t
    VarintSize32(uint32 value)
    Returns the number of bytes needed to encode the given value as a varint.
    static size_t
    VarintSize64(uint64 value)
    Returns the number of bytes needed to encode the given value as a varint.
    static size_t
    VarintSize32SignExtended(int32 value)
    If negative, 10 bytes. Otherwise, same as VarintSize32().
    static bool
    IsDefaultSerializationDeterministic()

    bool CodedOutputStream::HadError()

    Returns true if there was an underlying I/O error since this object was created.

    On should call Trim before this function in order to catch all errors.


    void CodedOutputStream::Trim()

    Trims any unused space in the underlying buffer so that its size matches the number of bytes written by this stream.

    The underlying buffer will automatically be trimmed when this stream is destroyed; this call is only necessary if the underlying buffer is accessed before the stream is destroyed.


    bool CodedOutputStream::Skip(
            int count)

    Skips a number of bytes, leaving the bytes unmodified in the underlying buffer.

    Returns false if an underlying write error occurs. This is mainly useful with GetDirectBufferPointer(). Note of caution, the skipped bytes may contain uninitialized data. The caller must make sure that the skipped bytes are properly initialized, otherwise you might leak bytes from your heap.


    bool CodedOutputStream::GetDirectBufferPointer(
            void ** data,
            int * size)

    Sets *data to point directly at the unwritten part of the CodedOutputStream's underlying buffer, and *size to the size of that buffer, but does not advance the stream's current position.

    This will always either produce a non-empty buffer or return false. If the caller writes any data to this buffer, it should then call Skip() to skip over the consumed bytes. This may be useful for implementing external fast serialization routines for types of data not covered by the CodedOutputStream interface.


    uint8 * CodedOutputStream::GetDirectBufferForNBytesAndAdvance(
            int size)

    If there are at least "size" bytes available in the current buffer, returns a pointer directly into the buffer and advances over these bytes.

    The caller may then write directly into this buffer (e.g. using the *ToArray static methods) rather than go through CodedOutputStream. If there are not enough bytes available, returns NULL. The return pointer is invalidated as soon as any other non-const method of CodedOutputStream is called.


    void CodedOutputStream::WriteVarint32(
            uint32 value)

    Write an unsigned integer with Varint encoding.

    Writing a 32-bit value is equivalent to casting it to uint64 and writing it as a 64-bit value, but may be more efficient.


    void CodedOutputStream::WriteTag(
            uint32 value)

    This is identical to WriteVarint32(), but optimized for writing tags.

    In particular, if the input is a compile-time constant, this method compiles down to a couple instructions. Always inline because otherwise the aforementioned optimization can't work, but GCC by default doesn't want to inline this.

    -

    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().

    +

    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 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:

    +

    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
     machines) will serialize equal messages to the same bytes.

    Note that this is not canonical across languages. It is also unstable across different builds with intervening message definition changes, due to unknown fields. Users who need canonical serialization (e.g. persistent storage in a canonical form, fingerprinting) should define their own canonicalization specification and implement the serializer using reflection APIs rather than relying on this API.


    static uint8 * CodedOutputStream::WriteRawToArray(
            const void * buffer,
            int size,
            uint8 * target)

    Like WriteRaw() but writing directly to the target array.

    This is not inlined, as the compiler often optimizes memcpy into inline copy loops. Since this gets called by every field with string or bytes type, inlining may lead to a significant amount of code bloat, with only a minor performance gain.

    -

    template struct CodedOutputStream::StaticVarintSize32

    #include <google/protobuf/io/coded_stream.h>
    namespace google::protobuf::io

    template <typename Value>

    Compile-time equivalent of VarintSize32().

    Members

    const size_t
    value = = (Value < (1 << 7)) ? 1 +

    template struct CodedOutputStream::StaticVarintSize32

    #include <google/protobuf/io/coded_stream.h>
    namespace google::protobuf::io

    template <typename Value>

    Compile-time equivalent of VarintSize32().

    Members

    const size_t
    value = = (Value < (1 << 7)) ? 1 : (Value < (1 << 14)) ? 2 : (Value < (1 << 21)) ? 3 : (Value < (1 << 28)) ? 4 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 1c87a23c..1d8209c0 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 @@ -6,11 +6,11 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/io/gzip_stream.h>
    namespace google::protobuf::io

    This file contains the definition for classes GzipInputStream and GzipOutputStream.

    GzipInputStream decompresses data from an underlying ZeroCopyInputStream and provides the decompressed data as a ZeroCopyInputStream.

    +

    #include <google/protobuf/io/gzip_stream.h>
    namespace google::protobuf::io

    This file contains the definition for classes GzipInputStream and GzipOutputStream.

    GzipInputStream decompresses data from an underlying ZeroCopyInputStream and provides the decompressed data as a ZeroCopyInputStream.

    -

    GzipOutputStream is an ZeroCopyOutputStream that compresses data to an underlying ZeroCopyOutputStream.

    +

    GzipOutputStream is an ZeroCopyOutputStream that compresses data to an underlying ZeroCopyOutputStream.

    -

    Classes in this file

    A ZeroCopyInputStream that reads compressed data through zlib.

    class GzipInputStream: public ZeroCopyInputStream

    #include <google/protobuf/io/gzip_stream.h>
    namespace google::protobuf::io

    A ZeroCopyInputStream that reads compressed data through zlib.

    Members

    enum
    Format
    Format key for constructor. more...
    explicit
    GzipInputStream(ZeroCopyInputStream * sub_stream, Format format = AUTO, int buffer_size = -1)
    buffer_size and format may be -1 for default of 64kB and GZIP format
    virtual
    ~GzipInputStream()
    const char *
    ZlibErrorMessage() const
    Return last error message or NULL if no error.
    int
    ZlibErrorCode() const

    implements ZeroCopyInputStream

    virtual bool
    Next(const void ** data, int * size)
    Obtains a chunk of data from the stream. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64
    ByteCount() const
    Returns the total number of bytes read since this object was created.

    enum GzipInputStream::Format {
      AUTO = = 0,
      GZIP = = 1,
      ZLIB = = 2
    }

    Format key for constructor.

    AUTOzlib will autodetect gzip header or deflate stream
    GZIPGZIP streams have some extra header data for file attributes.
    ZLIBSimpler zlib stream format.

    virtual bool GzipInputStream::Next(
            const void ** data,
            int * size)

    Obtains a chunk of data from the stream.

    Preconditions:

    +

    Classes in this file

    A ZeroCopyInputStream that reads compressed data through zlib.

    class GzipInputStream: public ZeroCopyInputStream

    #include <google/protobuf/io/gzip_stream.h>
    namespace google::protobuf::io

    A ZeroCopyInputStream that reads compressed data through zlib.

    Members

    enum
    Format
    Format key for constructor. more...
    explicit
    GzipInputStream(ZeroCopyInputStream * sub_stream, Format format = AUTO, int buffer_size = -1)
    buffer_size and format may be -1 for default of 64kB and GZIP format
    virtual
    ~GzipInputStream()
    const char *
    ZlibErrorMessage() const
    Return last error message or NULL if no error.
    int
    ZlibErrorCode() const

    implements ZeroCopyInputStream

    virtual bool
    Next(const void ** data, int * size)
    Obtains a chunk of data from the stream. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64
    ByteCount() const
    Returns the total number of bytes read since this object was created.

    enum GzipInputStream::Format {
      AUTO = = 0,
      GZIP = = 1,
      ZLIB = = 2
    }

    Format key for constructor.

    AUTOzlib will autodetect gzip header or deflate stream
    GZIPGZIP streams have some extra header data for file attributes.
    ZLIBSimpler zlib stream format.

    virtual bool GzipInputStream::Next(
            const void ** data,
            int * size)

    Obtains a chunk of data from the stream.

    Preconditions:

    • "size" and "data" are not NULL.
    @@ -32,7 +32,7 @@ type = "docs"
  • The last "count" bytes of the last buffer returned by Next() will be pushed back into the stream. Subsequent calls to Next() will return the same data again before producing new data.

  • virtual bool GzipInputStream::Skip(
            int count)

    Skips a number of bytes.

    Returns false if the end of the stream is reached or some input error occurred. In the end-of-stream case, the stream is advanced to the end of the stream (so ByteCount() will return the total size of the stream).

    -

    class GzipOutputStream: public ZeroCopyOutputStream

    #include <google/protobuf/io/gzip_stream.h>
    namespace google::protobuf::io

    Members

    enum
    Format
    Format key for constructor. more...
    explicit
    GzipOutputStream(ZeroCopyOutputStream * sub_stream)
    Create a GzipOutputStream with default options.
    GzipOutputStream(ZeroCopyOutputStream * sub_stream, const Options & options)
    Create a GzipOutputStream with the given options.
    virtual
    ~GzipOutputStream()
    const char *
    ZlibErrorMessage() const
    Return last error message or NULL if no error.
    int
    ZlibErrorCode() const
    bool
    Flush()
    Flushes data written so far to zipped data in the underlying stream. more...
    bool
    Close()
    Writes out all data and closes the gzip stream. more...

    implements ZeroCopyOutputStream

    virtual bool
    Next(void ** data, int * size)
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64
    ByteCount() const
    Returns the total number of bytes written since this object was created.

    enum GzipOutputStream::Format {
      GZIP = = 1,
      ZLIB = = 2
    }

    Format key for constructor.

    GZIPGZIP streams have some extra header data for file attributes.
    ZLIBSimpler zlib stream format.

    bool GzipOutputStream::Flush()

    Flushes data written so far to zipped data in the underlying stream.

    It is the caller's responsibility to flush the underlying stream if necessary. Compression may be less efficient stopping and starting around flushes. Returns true if no error.

    +

    class GzipOutputStream: public ZeroCopyOutputStream

    #include <google/protobuf/io/gzip_stream.h>
    namespace google::protobuf::io

    Members

    enum
    Format
    Format key for constructor. more...
    explicit
    GzipOutputStream(ZeroCopyOutputStream * sub_stream)
    Create a GzipOutputStream with default options.
    GzipOutputStream(ZeroCopyOutputStream * sub_stream, const Options & options)
    Create a GzipOutputStream with the given options.
    virtual
    ~GzipOutputStream()
    const char *
    ZlibErrorMessage() const
    Return last error message or NULL if no error.
    int
    ZlibErrorCode() const
    bool
    Flush()
    Flushes data written so far to zipped data in the underlying stream. more...
    bool
    Close()
    Writes out all data and closes the gzip stream. more...

    implements ZeroCopyOutputStream

    virtual bool
    Next(void ** data, int * size)
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64
    ByteCount() const
    Returns the total number of bytes written since this object was created.

    enum GzipOutputStream::Format {
      GZIP = = 1,
      ZLIB = = 2
    }

    Format key for constructor.

    GZIPGZIP streams have some extra header data for file attributes.
    ZLIBSimpler zlib stream format.

    bool GzipOutputStream::Flush()

    Flushes data written so far to zipped data in the underlying stream.

    It is the caller's responsibility to flush the underlying stream if necessary. Compression may be less efficient stopping and starting around flushes. Returns true if no error.

    Please ensure that block size is > 6. Here is an excerpt from the zlib doc that explains why:

    In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that avail_out is greater than six to avoid repeated flush markers due to avail_out == 0 on return.


    bool GzipOutputStream::Close()

    Writes out all data and closes the gzip stream.

    It is the caller's responsibility to close the underlying stream if necessary. Returns true if no error.

    @@ -60,6 +60,6 @@ type = "docs"
    • The last "count" bytes of the last buffer returned by Next() will be ignored.
    -

    struct GzipOutputStream::Options

    #include <google/protobuf/io/gzip_stream.h>
    namespace google::protobuf::io

    Members

    Format
    format
    Defaults to GZIP.
    int
    buffer_size
    What size buffer to use internally. Defaults to 64kB.
    int
    compression_level
    A number between 0 and 9, where 0 is no compression and 9 is best compression. more...
    int
    compression_strategy
    Defaults to Z_DEFAULT_STRATEGY. more...
    Options()
    Initializes with default values.

    intOptions::compression_level

    A number between 0 and 9, where 0 is no compression and 9 is best compression.

    Defaults to Z_DEFAULT_COMPRESSION (see zlib.h).

    +

    struct GzipOutputStream::Options

    #include <google/protobuf/io/gzip_stream.h>
    namespace google::protobuf::io

    Members

    Format
    format
    Defaults to GZIP.
    int
    buffer_size
    What size buffer to use internally. Defaults to 64kB.
    int
    compression_level
    A number between 0 and 9, where 0 is no compression and 9 is best compression. more...
    int
    compression_strategy
    Defaults to Z_DEFAULT_STRATEGY. more...
    Options()
    Initializes with default values.

    intOptions::compression_level

    A number between 0 and 9, where 0 is no compression and 9 is best compression.

    Defaults to Z_DEFAULT_COMPRESSION (see zlib.h).


    intOptions::compression_strategy

    Defaults to Z_DEFAULT_STRATEGY.

    Can also be set to Z_FILTERED, Z_HUFFMAN_ONLY, or Z_RLE. See the documentation for deflateInit2 in zlib.h for definitions of these constants.

    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 1623248a..ae164a2a 100644 --- a/content/reference/cpp/api-docs/google.protobuf.io.printer.md +++ b/content/reference/cpp/api-docs/google.protobuf.io.printer.md @@ -6,11 +6,11 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #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.

    class AnnotationCollector

    #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 > Annotation
    Annotation 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) = 0
    Records 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.

    class AnnotationCollector

    #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 > Annotation
    Annotation 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) = 0
    Records 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.

    -

    template class AnnotationProtoCollector: public AnnotationCollector

    #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)
    virtual void
    AddAnnotationNew(Annotation & a)

    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.

    -

    class Printer

    #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() const
    True 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 class AnnotationProtoCollector: public AnnotationCollector

    #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)
    virtual void
    AddAnnotationNew(Annotation & a)

    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.

    +

    class Printer

    #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() const
    True 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.


    void Printer::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.

    The range begins at begin_varname's value and ends after the last character of the value substituted for end_varname.


    void Printer::Print(
            const std::map< std::string, std::string > & variables,
            const char * text)

    Print some text after applying variable substitutions.

    If a particular variable in the text is not defined, this will crash. Variables to be substituted are identified by their names surrounded by delimiter characters (as given to the constructor). The variable bindings are defined by the given map.

    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 3845f9d7..857dfad2 100644 --- a/content/reference/cpp/api-docs/google.protobuf.io.tokenizer.md +++ b/content/reference/cpp/api-docs/google.protobuf.io.tokenizer.md @@ -6,18 +6,18 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/io/tokenizer.h>
    namespace google::protobuf::io

    Class for parsing tokenized text from a ZeroCopyInputStream.

    Classes in this file

    Abstract interface for an object which collects the errors that occur during parsing.
    This class converts a stream of raw text into a stream of tokens for the protocol definition parser to parse.
    Structure representing a token read from the token stream.

    File Members

    These definitions are not part of any class.
    typedef
    int ColumnNumber
    By "column number", the proto compiler refers to a count of the number of bytes before a given byte, except that a tab character advances to the next multiple of 8 bytes. more...

    typedef io::ColumnNumber

    By "column number", the proto compiler refers to a count of the number of bytes before a given byte, except that a tab character advances to the next multiple of 8 bytes.

    Note in particular that column numbers are zero-based, while many user interfaces use one-based column numbers.

    -

    class ErrorCollector

    #include <google/protobuf/io/tokenizer.h>
    namespace google::protobuf::io

    Abstract interface for an object which collects the errors that occur during parsing.

    A typical implementation might simply print the errors to stdout.

    +

    #include <google/protobuf/io/tokenizer.h>
    namespace google::protobuf::io

    Class for parsing tokenized text from a ZeroCopyInputStream.

    Classes in this file

    Abstract interface for an object which collects the errors that occur during parsing.
    This class converts a stream of raw text into a stream of tokens for the protocol definition parser to parse.
    Structure representing a token read from the token stream.

    File Members

    These definitions are not part of any class.
    typedef
    int ColumnNumber
    By "column number", the proto compiler refers to a count of the number of bytes before a given byte, except that a tab character advances to the next multiple of 8 bytes. more...

    typedef io::ColumnNumber

    By "column number", the proto compiler refers to a count of the number of bytes before a given byte, except that a tab character advances to the next multiple of 8 bytes.

    Note in particular that column numbers are zero-based, while many user interfaces use one-based column numbers.

    +

    class ErrorCollector

    #include <google/protobuf/io/tokenizer.h>
    namespace google::protobuf::io

    Abstract interface for an object which collects the errors that occur during parsing.

    A typical implementation might simply print the errors to stdout.

    Members

    ErrorCollector()
    virtual
    ~ErrorCollector()
    virtual void
    AddError(int line, ColumnNumber column, const std::string & message) = 0
    Indicates that there was an error in the input at the given line and column numbers. more...
    virtual void
    AddWarning(int , ColumnNumber , const std::string & )
    Indicates that there was a warning in the input at the given line and column numbers. more...

    virtual void ErrorCollector::AddError(
            int line,
            ColumnNumber column,
            const std::string & message) = 0

    Indicates that there was an error in the input at the given line and column numbers.

    The numbers are zero-based, so you may want to add 1 to each before printing them.


    virtual void ErrorCollector::AddWarning(
            int ,
            ColumnNumber ,
            const std::string & )

    Indicates that there was a warning in the input at the given line and column numbers.

    The numbers are zero-based, so you may want to add 1 to each before printing them.

    -

    class Tokenizer

    #include <google/protobuf/io/tokenizer.h>
    namespace google::protobuf::io

    This class converts a stream of raw text into a stream of tokens for the protocol definition parser to parse.

    The tokens recognized are similar to those that make up the C language; see the TokenType enum for precise descriptions. Whitespace and comments are skipped. By default, C- and C++-style comments are recognized, but other styles can be used by calling set_comment_style().

    -

    Members

    enum
    TokenType
    Tokenizer(ZeroCopyInputStream * input, ErrorCollector * error_collector)
    Construct a Tokenizer that reads and tokenizes text from the given input stream and writes errors to the given error_collector. more...
    ~Tokenizer()
    const Token &
    current()
    Get the current token. more...
    const Token &
    previous()
    Return the previous token – i.e. more...
    bool
    Next()
    Advance to the next token. more...
    bool
    NextWithComments(std::string * prev_trailing_comments, std::vector< std::string > * detached_comments, std::string * next_leading_comments)
    Like Next(), but also collects comments which appear between the previous and next tokens. more...

    Options

    enum
    CommentStyle
    Valid values for set_comment_style(). more...
    void
    set_allow_f_after_float(bool value)
    Set true to allow floats to be suffixed with the letter 'f'. more...
    void
    set_comment_style(CommentStyle style)
    Sets the comment style.
    void
    set_require_space_after_number(bool require)
    Whether to require whitespace between a number and a field name. more...
    void
    set_allow_multiline_strings(bool allow)
    Whether to allow string literals to span multiple lines. more...
    static bool
    IsIdentifier(const std::string & text)
    External helper: validate an identifier.

    Parse helpers

    static double
    ParseFloat(const std::string & text)
    Parses a TYPE_FLOAT token. more...
    static void
    ParseString(const std::string & text, std::string * output)
    Parses a TYPE_STRING token. more...
    static void
    ParseStringAppend(const std::string & text, std::string * output)
    Identical to ParseString, but appends to output.
    static bool
    ParseInteger(const std::string & text, uint64 max_value, uint64 * output)
    Parses a TYPE_INTEGER token. more...

    enum Tokenizer::TokenType {
      TYPE_START,
      TYPE_END,
      TYPE_IDENTIFIER,
      TYPE_INTEGER,
      TYPE_FLOAT,
      TYPE_STRING,
      TYPE_SYMBOL
    }

    TYPE_STARTNext() has not yet been called.
    TYPE_ENDEnd of input reached. "text" is empty.
    TYPE_IDENTIFIER

    A sequence of letters, digits, and underscores, not starting with a digit.

    It is an error for a number to be followed by an identifier with no space in between.

    +

    class Tokenizer

    #include <google/protobuf/io/tokenizer.h>
    namespace google::protobuf::io

    This class converts a stream of raw text into a stream of tokens for the protocol definition parser to parse.

    The tokens recognized are similar to those that make up the C language; see the TokenType enum for precise descriptions. Whitespace and comments are skipped. By default, C- and C++-style comments are recognized, but other styles can be used by calling set_comment_style().

    +

    Members

    enum
    TokenType
    Tokenizer(ZeroCopyInputStream * input, ErrorCollector * error_collector)
    Construct a Tokenizer that reads and tokenizes text from the given input stream and writes errors to the given error_collector. more...
    ~Tokenizer()
    const Token &
    current()
    Get the current token. more...
    const Token &
    previous()
    Return the previous token – i.e. more...
    bool
    Next()
    Advance to the next token. more...
    bool
    NextWithComments(std::string * prev_trailing_comments, std::vector< std::string > * detached_comments, std::string * next_leading_comments)
    Like Next(), but also collects comments which appear between the previous and next tokens. more...

    Options

    enum
    CommentStyle
    Valid values for set_comment_style(). more...
    void
    set_allow_f_after_float(bool value)
    Set true to allow floats to be suffixed with the letter 'f'. more...
    void
    set_comment_style(CommentStyle style)
    Sets the comment style.
    void
    set_require_space_after_number(bool require)
    Whether to require whitespace between a number and a field name. more...
    void
    set_allow_multiline_strings(bool allow)
    Whether to allow string literals to span multiple lines. more...
    static bool
    IsIdentifier(const std::string & text)
    External helper: validate an identifier.

    Parse helpers

    static double
    ParseFloat(const std::string & text)
    Parses a TYPE_FLOAT token. more...
    static void
    ParseString(const std::string & text, std::string * output)
    Parses a TYPE_STRING token. more...
    static void
    ParseStringAppend(const std::string & text, std::string * output)
    Identical to ParseString, but appends to output.
    static bool
    ParseInteger(const std::string & text, uint64 max_value, uint64 * output)
    Parses a TYPE_INTEGER token. more...

    enum Tokenizer::TokenType {
      TYPE_START,
      TYPE_END,
      TYPE_IDENTIFIER,
      TYPE_INTEGER,
      TYPE_FLOAT,
      TYPE_STRING,
      TYPE_SYMBOL
    }

    TYPE_STARTNext() has not yet been called.
    TYPE_ENDEnd of input reached. "text" is empty.
    TYPE_IDENTIFIER

    A sequence of letters, digits, and underscores, not starting with a digit.

    It is an error for a number to be followed by an identifier with no space in between.

    TYPE_INTEGER

    A sequence of digits representing an integer.

    Normally the digits are decimal, but a prefix of "0x" indicates a hex number and a leading zero indicates octal, just like with C numeric literals. A leading negative sign is NOT included in the token; it's up to the parser to interpret the unary minus operator on its own.

    TYPE_FLOAT

    A floating point literal, with a fractional part and/or an exponent.

    Always in decimal. Again, never negative.

    TYPE_STRING

    A quoted sequence of escaped characters.

    Either single or double quotes can be used, but they must match. A string literal cannot cross a line break.

    TYPE_SYMBOL

    Any other printable character, like '!' or '+'.

    Symbols are always a single character, so "!+$%" is four tokens.

    -

    Tokenizer::Tokenizer(
            ZeroCopyInputStream * input,
            ErrorCollector * error_collector)

    Construct a Tokenizer that reads and tokenizes text from the given input stream and writes errors to the given error_collector.

    The caller keeps ownership of input and error_collector.

    +

    Tokenizer::Tokenizer(
            ZeroCopyInputStream * input,
            ErrorCollector * error_collector)

    Construct a Tokenizer that reads and tokenizes text from the given input stream and writes errors to the given error_collector.

    The caller keeps ownership of input and error_collector.


    const Token & Tokenizer::current()

    Get the current token.

    This is updated when Next() is called. Before the first call to Next(), current() has type TYPE_START and no contents.


    const Token & Tokenizer::previous()

    Return the previous token – i.e.

    what current() returned before the previous call to Next().


    bool Tokenizer::Next()

    Advance to the next token.

    Returns false if the end of the input is reached.

    @@ -55,6 +55,6 @@ optional int32 grault = 6;

    static double Tokenizer::ParseFloat(
            const std::string & text)

    Parses a TYPE_FLOAT token.

    This never fails, so long as the text actually comes from a TYPE_FLOAT token parsed by Tokenizer. If it doesn't, the result is undefined (possibly an assert failure).


    static void Tokenizer::ParseString(
            const std::string & text,
            std::string * output)

    Parses a TYPE_STRING token.

    This never fails, so long as the text actually comes from a TYPE_STRING token parsed by Tokenizer. If it doesn't, the result is undefined (possibly an assert failure).


    static bool Tokenizer::ParseInteger(
            const std::string & text,
            uint64 max_value,
            uint64 * output)

    Parses a TYPE_INTEGER token.

    Returns false if the result would be greater than max_value. Otherwise, returns true and sets *output to the result. If the text is not from a Token of type TYPE_INTEGER originally parsed by a Tokenizer, the result is undefined (possibly an assert failure).

    -

    struct Tokenizer::Token

    #include <google/protobuf/io/tokenizer.h>
    namespace google::protobuf::io

    Structure representing a token read from the token stream.

    Members

    TokenType
    type
    std::string
    text
    The exact text of the token as it appeared in the input. more...
    int
    line
    "line" and "column" specify the position of the first character of the token within the input stream. more...
    ColumnNumber
    column
    ColumnNumber
    end_column

    std::string Token::text

    The exact text of the token as it appeared in the input.

    e.g. tokens of TYPE_STRING will still be escaped and in quotes.

    +

    struct Tokenizer::Token

    #include <google/protobuf/io/tokenizer.h>
    namespace google::protobuf::io

    Structure representing a token read from the token stream.

    Members

    TokenType
    type
    std::string
    text
    The exact text of the token as it appeared in the input. more...
    int
    line
    "line" and "column" specify the position of the first character of the token within the input stream. more...
    ColumnNumber
    column
    ColumnNumber
    end_column

    std::string Token::text

    The exact text of the token as it appeared in the input.

    e.g. tokens of TYPE_STRING will still be escaped and in quotes.


    int Token::line

    "line" and "column" specify the position of the first character of the token within the input stream.

    They are zero-based.

    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 0151e5ab..2f26a551 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 @@ -6,7 +6,7 @@ description = "This section contains reference documentation for working with Pr 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 Protobuf messages 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.

    @@ -25,7 +25,7 @@ DoSomething(buffer, size);

    Here, no copy is performed. The input stream returns a pointer directly into the backing array, and the caller ends up reading directly from it.

    -

    If you want to be able to read the old-fashion way, you can create a CodedInputStream or CodedOutputStream wrapping these objects and use their ReadRaw()/WriteRaw() methods. These will, of course, add a copy step, but Coded*Stream will handle buffering so at least it will be reasonably efficient.

    +

    If you want to be able to read the old-fashion way, you can create a CodedInputStream or CodedOutputStream wrapping these objects and use their ReadRaw()/WriteRaw() methods. These will, of course, add a copy step, but Coded*Stream will handle buffering so at least it will be reasonably efficient.

    ZeroCopyInputStream example:

    @@ -65,7 +65,7 @@ delete output; close(infd); close(outfd); -

    Classes in this file

    Abstract interface similar to an input stream but designed to minimize copying.
    Abstract interface similar to an output stream but designed to minimize copying.

    class ZeroCopyInputStream

    #include <google/protobuf/io/zero_copy_stream.h>
    namespace google::protobuf::io

    Abstract interface similar to an input stream but designed to minimize copying.

    Known subclasses:

    Members

    ZeroCopyInputStream()
    virtual
    ~ZeroCopyInputStream()
    virtual bool
    Next(const void ** data, int * size) = 0
    Obtains a chunk of data from the stream. more...
    virtual void
    BackUp(int count) = 0
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count) = 0
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const = 0
    Returns the total number of bytes read since this object was created.

    virtual bool ZeroCopyInputStream::Next(
            const void ** data,
            int * size) = 0

    Obtains a chunk of data from the stream.

    Preconditions:

    +

    Classes in this file

    Abstract interface similar to an input stream but designed to minimize copying.
    Abstract interface similar to an output stream but designed to minimize copying.

    class ZeroCopyInputStream

    #include <google/protobuf/io/zero_copy_stream.h>
    namespace google::protobuf::io

    Abstract interface similar to an input stream but designed to minimize copying.

    Known subclasses:

    Members

    ZeroCopyInputStream()
    virtual
    ~ZeroCopyInputStream()
    virtual bool
    Next(const void ** data, int * size) = 0
    Obtains a chunk of data from the stream. more...
    virtual void
    BackUp(int count) = 0
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count) = 0
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const = 0
    Returns the total number of bytes read since this object was created.

    virtual bool ZeroCopyInputStream::Next(
            const void ** data,
            int * size) = 0

    Obtains a chunk of data from the stream.

    Preconditions:

    • "size" and "data" are not NULL.
    @@ -87,7 +87,7 @@ close(outfd);
  • The last "count" bytes of the last buffer returned by Next() will be pushed back into the stream. Subsequent calls to Next() will return the same data again before producing new data.

  • virtual bool ZeroCopyInputStream::Skip(
            int count) = 0

    Skips a number of bytes.

    Returns false if the end of the stream is reached or some input error occurred. In the end-of-stream case, the stream is advanced to the end of the stream (so ByteCount() will return the total size of the stream).

    -

    class ZeroCopyOutputStream

    #include <google/protobuf/io/zero_copy_stream.h>
    namespace google::protobuf::io

    Abstract interface similar to an output stream but designed to minimize copying.

    Known subclasses:

    Members

    ZeroCopyOutputStream()
    virtual
    ~ZeroCopyOutputStream()
    virtual bool
    Next(void ** data, int * size) = 0
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count) = 0
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64_t
    ByteCount() const = 0
    Returns the total number of bytes written since this object was created.
    virtual bool
    WriteAliasedRaw(const void * data, int size)
    Write a given chunk of data to the output. more...
    virtual bool
    AllowsAliasing() const

    virtual bool ZeroCopyOutputStream::Next(
            void ** data,
            int * size) = 0

    Obtains a buffer into which data can be written.

    Any data written into this buffer will eventually (maybe instantly, maybe later on) be written to the output.

    +

    class ZeroCopyOutputStream

    #include <google/protobuf/io/zero_copy_stream.h>
    namespace google::protobuf::io

    Abstract interface similar to an output stream but designed to minimize copying.

    Known subclasses:

    Members

    ZeroCopyOutputStream()
    virtual
    ~ZeroCopyOutputStream()
    virtual bool
    Next(void ** data, int * size) = 0
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count) = 0
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64_t
    ByteCount() const = 0
    Returns the total number of bytes written since this object was created.
    virtual bool
    WriteAliasedRaw(const void * data, int size)
    Write a given chunk of data to the output. more...
    virtual bool
    AllowsAliasing() const

    virtual bool ZeroCopyOutputStream::Next(
            void ** data,
            int * size) = 0

    Obtains a buffer into which data can be written.

    Any data written into this buffer will eventually (maybe instantly, maybe later on) be written to the output.

    Preconditions:

    • "size" and "data" are not NULL.
    • 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 f14a8f57..ea50db20 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 @@ -6,10 +6,10 @@ description = "This section contains reference documentation for working with Pr 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.

      class FileInputStream: public ZeroCopyInputStream

      #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() const
      If 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)
      Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
      virtual bool
      Skip(int count)
      Skips a number of bytes. more...
      virtual int64_t
      ByteCount() const
      Returns 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.

      +

      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.

      class FileInputStream: public ZeroCopyInputStream

      #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() const
      If 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)
      Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
      virtual bool
      Skip(int count)
      Skips a number of bytes. more...
      virtual int64_t
      ByteCount() const
      Returns 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.


      bool FileInputStream::Close()

      Flushes any buffers and closes the underlying file.

      Returns false if an error occurs during the process; use GetErrno() to examine the error. Even if an error occurs, the file descriptor is closed when this returns.


      void FileInputStream::SetCloseOnDelete(
              bool value)

      By default, the file descriptor is not closed when the stream is destroyed.

      Call SetCloseOnDelete(true) to change that. WARNING: This leaves no way for the caller to detect if close() fails. If detecting close() errors is important to you, you should arrange to close the descriptor yourself.


      int FileInputStream::GetErrno() const

      If an I/O error has occurred on this file descriptor, this is the errno from that error.

      Otherwise, this is zero. Once an error occurs, the stream is broken and all subsequent operations will fail.

      @@ -35,13 +35,13 @@ type = "docs"
    • The last "count" bytes of the last buffer returned by Next() will be pushed back into the stream. Subsequent calls to Next() will return the same data again before producing new data.

    virtual bool FileInputStream::Skip(
            int count)

    Skips a number of bytes.

    Returns false if the end of the stream is reached or some input error occurred. In the end-of-stream case, the stream is advanced to the end of the stream (so ByteCount() will return the total size of the stream).

    -

    class FileOutputStream: public CopyingOutputStreamAdaptor

    #include <google/protobuf/io/zero_copy_stream_impl.h>
    namespace google::protobuf::io

    A ZeroCopyOutputStream which writes to a file descriptor.

    FileOutputStream is preferred over using an ofstream with OstreamOutputStream. The latter will introduce an extra layer of buffering, harming performance. Also, it's conceivable that FileOutputStream could someday be enhanced to use zero-copy file descriptors on OSs which support them.

    -

    Members

    explicit
    FileOutputStream(int file_descriptor, int block_size = -1)
    Creates a stream that writes to the given Unix file descriptor. more...
    ~FileOutputStream()
    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() const
    If an I/O error has occurred on this file descriptor, this is the errno from that error. more...

    explicit FileOutputStream::FileOutputStream(
            int file_descriptor,
            int block_size = -1)

    Creates a stream that writes to the given Unix file descriptor.

    If a block_size is given, it specifies the size of the buffers that should be returned by Next(). Otherwise, a reasonable default is used.

    +

    class FileOutputStream: public CopyingOutputStreamAdaptor

    #include <google/protobuf/io/zero_copy_stream_impl.h>
    namespace google::protobuf::io

    A ZeroCopyOutputStream which writes to a file descriptor.

    FileOutputStream is preferred over using an ofstream with OstreamOutputStream. The latter will introduce an extra layer of buffering, harming performance. Also, it's conceivable that FileOutputStream could someday be enhanced to use zero-copy file descriptors on OSs which support them.

    +

    Members

    explicit
    FileOutputStream(int file_descriptor, int block_size = -1)
    Creates a stream that writes to the given Unix file descriptor. more...
    ~FileOutputStream()
    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() const
    If an I/O error has occurred on this file descriptor, this is the errno from that error. more...

    explicit FileOutputStream::FileOutputStream(
            int file_descriptor,
            int block_size = -1)

    Creates a stream that writes to the given Unix file descriptor.

    If a block_size is given, it specifies the size of the buffers that should be returned by Next(). Otherwise, a reasonable default is used.


    bool FileOutputStream::Close()

    Flushes any buffers and closes the underlying file.

    Returns false if an error occurs during the process; use GetErrno() to examine the error. Even if an error occurs, the file descriptor is closed when this returns.


    void FileOutputStream::SetCloseOnDelete(
            bool value)

    By default, the file descriptor is not closed when the stream is destroyed.

    Call SetCloseOnDelete(true) to change that. WARNING: This leaves no way for the caller to detect if close() fails. If detecting close() errors is important to you, you should arrange to close the descriptor yourself.


    int FileOutputStream::GetErrno() const

    If an I/O error has occurred on this file descriptor, this is the errno from that error.

    Otherwise, this is zero. Once an error occurs, the stream is broken and all subsequent operations will fail.

    -

    class IstreamInputStream: public ZeroCopyInputStream

    #include <google/protobuf/io/zero_copy_stream_impl.h>
    namespace google::protobuf::io

    A ZeroCopyInputStream which reads from a C++ istream.

    Note that for reading files (or anything represented by a file descriptor), FileInputStream is more efficient.

    -

    Members

    explicit
    IstreamInputStream(std::istream * stream, int block_size = -1)
    Creates a stream that reads from the given C++ istream. 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)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes read since this object was created.

    explicit IstreamInputStream::IstreamInputStream(
            std::istream * stream,
            int block_size = -1)

    Creates a stream that reads from the given C++ istream.

    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.

    +

    class IstreamInputStream: public ZeroCopyInputStream

    #include <google/protobuf/io/zero_copy_stream_impl.h>
    namespace google::protobuf::io

    A ZeroCopyInputStream which reads from a C++ istream.

    Note that for reading files (or anything represented by a file descriptor), FileInputStream is more efficient.

    +

    Members

    explicit
    IstreamInputStream(std::istream * stream, int block_size = -1)
    Creates a stream that reads from the given C++ istream. 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)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes read since this object was created.

    explicit IstreamInputStream::IstreamInputStream(
            std::istream * stream,
            int block_size = -1)

    Creates a stream that reads from the given C++ istream.

    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.


    virtual bool IstreamInputStream::Next(
            const void ** data,
            int * size)

    Obtains a chunk of data from the stream.

    Preconditions:

    • "size" and "data" are not NULL.
    • @@ -64,8 +64,8 @@ type = "docs"
    • The last "count" bytes of the last buffer returned by Next() will be pushed back into the stream. Subsequent calls to Next() will return the same data again before producing new data.

    virtual bool IstreamInputStream::Skip(
            int count)

    Skips a number of bytes.

    Returns false if the end of the stream is reached or some input error occurred. In the end-of-stream case, the stream is advanced to the end of the stream (so ByteCount() will return the total size of the stream).

    -

    class OstreamOutputStream: public ZeroCopyOutputStream

    #include <google/protobuf/io/zero_copy_stream_impl.h>
    namespace google::protobuf::io

    A ZeroCopyOutputStream which writes to a C++ ostream.

    Note that for writing files (or anything represented by a file descriptor), FileOutputStream is more efficient.

    -

    Members

    explicit
    OstreamOutputStream(std::ostream * stream, int block_size = -1)
    Creates a stream that writes to the given C++ ostream. more...
    ~OstreamOutputStream()

    implements ZeroCopyOutputStream

    virtual bool
    Next(void ** data, int * size)
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes written since this object was created.

    explicit OstreamOutputStream::OstreamOutputStream(
            std::ostream * stream,
            int block_size = -1)

    Creates a stream that writes to the given C++ ostream.

    If a block_size is given, it specifies the size of the buffers that should be returned by Next(). Otherwise, a reasonable default is used.

    +

    class OstreamOutputStream: public ZeroCopyOutputStream

    #include <google/protobuf/io/zero_copy_stream_impl.h>
    namespace google::protobuf::io

    A ZeroCopyOutputStream which writes to a C++ ostream.

    Note that for writing files (or anything represented by a file descriptor), FileOutputStream is more efficient.

    +

    Members

    explicit
    OstreamOutputStream(std::ostream * stream, int block_size = -1)
    Creates a stream that writes to the given C++ ostream. more...
    ~OstreamOutputStream()

    implements ZeroCopyOutputStream

    virtual bool
    Next(void ** data, int * size)
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes written since this object was created.

    explicit OstreamOutputStream::OstreamOutputStream(
            std::ostream * stream,
            int block_size = -1)

    Creates a stream that writes to the given C++ ostream.

    If a block_size is given, it specifies the size of the buffers that should be returned by Next(). Otherwise, a reasonable default is used.


    virtual bool OstreamOutputStream::Next(
            void ** data,
            int * size)

    Obtains a buffer into which data can be written.

    Any data written into this buffer will eventually (maybe instantly, maybe later on) be written to the output.

    Preconditions:

      @@ -90,8 +90,8 @@ type = "docs"
      • The last "count" bytes of the last buffer returned by Next() will be ignored.
      -

    class ConcatenatingInputStream: public ZeroCopyInputStream

    #include <google/protobuf/io/zero_copy_stream_impl.h>
    namespace google::protobuf::io

    A ZeroCopyInputStream which reads from several other streams in sequence.

    ConcatenatingInputStream is unable to distinguish between end-of-stream and read errors in the underlying streams, so it assumes any errors mean end-of-stream. So, if the underlying streams fail for any other reason, ConcatenatingInputStream may do odd things. It is suggested that you do not use ConcatenatingInputStream on streams that might produce read errors other than end-of-stream.

    -

    Members

    ConcatenatingInputStream(ZeroCopyInputStream *const streams, int count)
    All streams passed in as well as the array itself must remain valid until the ConcatenatingInputStream is destroyed.
    ~ConcatenatingInputStream()

    implements ZeroCopyInputStream

    virtual bool
    Next(const void ** data, int * size)
    Obtains a chunk of data from the stream. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes read since this object was created.

    virtual bool ConcatenatingInputStream::Next(
            const void ** data,
            int * size)

    Obtains a chunk of data from the stream.

    Preconditions:

    +

    class ConcatenatingInputStream: public ZeroCopyInputStream

    #include <google/protobuf/io/zero_copy_stream_impl.h>
    namespace google::protobuf::io

    A ZeroCopyInputStream which reads from several other streams in sequence.

    ConcatenatingInputStream is unable to distinguish between end-of-stream and read errors in the underlying streams, so it assumes any errors mean end-of-stream. So, if the underlying streams fail for any other reason, ConcatenatingInputStream may do odd things. It is suggested that you do not use ConcatenatingInputStream on streams that might produce read errors other than end-of-stream.

    +

    Members

    ConcatenatingInputStream(ZeroCopyInputStream *const streams, int count)
    All streams passed in as well as the array itself must remain valid until the ConcatenatingInputStream is destroyed.
    ~ConcatenatingInputStream()

    implements ZeroCopyInputStream

    virtual bool
    Next(const void ** data, int * size)
    Obtains a chunk of data from the stream. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes read since this object was created.

    virtual bool ConcatenatingInputStream::Next(
            const void ** data,
            int * size)

    Obtains a chunk of data from the stream.

    Preconditions:

    • "size" and "data" are not NULL.
    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 9a773842..8e8e30a7 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 @@ -6,10 +6,10 @@ description = "This section contains reference documentation for working with Pr 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 generic traditional output stream interface.
    A ZeroCopyInputStream which wraps some other stream and limits it to a particular byte count.

    File Members

    These 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().

    -

    class ArrayInputStream: public ZeroCopyInputStream

    #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)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const
    Returns 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.

    +

    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 generic traditional output stream interface.
    A ZeroCopyInputStream which wraps some other stream and limits it to a particular byte count.

    File Members

    These 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().

    +

    class ArrayInputStream: public ZeroCopyInputStream

    #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)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const
    Returns 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.


    virtual bool ArrayInputStream::Next(
            const void ** data,
            int * size)

    Obtains a chunk of data from the stream.

    Preconditions:

    • "size" and "data" are not NULL.
    • @@ -32,7 +32,7 @@ type = "docs"
    • The last "count" bytes of the last buffer returned by Next() will be pushed back into the stream. Subsequent calls to Next() will return the same data again before producing new data.

    virtual bool ArrayInputStream::Skip(
            int count)

    Skips a number of bytes.

    Returns false if the end of the stream is reached or some input error occurred. In the end-of-stream case, the stream is advanced to the end of the stream (so ByteCount() will return the total size of the stream).

    -

    class ArrayOutputStream: public ZeroCopyOutputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A ZeroCopyOutputStream backed by an in-memory array of bytes.

    Members

    ArrayOutputStream(void * data, int size, int block_size = -1)
    Create an OutputStream that writes to the bytes pointed to by "data". more...
    ~ArrayOutputStream()

    implements ZeroCopyOutputStream

    virtual bool
    Next(void ** data, int * size)
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes written since this object was created.

    ArrayOutputStream::ArrayOutputStream(
            void * data,
            int size,
            int block_size = -1)

    Create an OutputStream that writes to 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.

    +

    class ArrayOutputStream: public ZeroCopyOutputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A ZeroCopyOutputStream backed by an in-memory array of bytes.

    Members

    ArrayOutputStream(void * data, int size, int block_size = -1)
    Create an OutputStream that writes to the bytes pointed to by "data". more...
    ~ArrayOutputStream()

    implements ZeroCopyOutputStream

    virtual bool
    Next(void ** data, int * size)
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes written since this object was created.

    ArrayOutputStream::ArrayOutputStream(
            void * data,
            int size,
            int block_size = -1)

    Create an OutputStream that writes to 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.


    virtual bool ArrayOutputStream::Next(
            void ** data,
            int * size)

    Obtains a buffer into which data can be written.

    Any data written into this buffer will eventually (maybe instantly, maybe later on) be written to the output.

    Preconditions:

      @@ -57,7 +57,7 @@ type = "docs"
      • The last "count" bytes of the last buffer returned by Next() will be ignored.
      -

    class StringOutputStream: public ZeroCopyOutputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A ZeroCopyOutputStream which appends bytes to a string.

    Members

    explicit
    StringOutputStream(std::string * target)
    Create a StringOutputStream which appends bytes to the given string. more...
    ~StringOutputStream()

    implements ZeroCopyOutputStream

    virtual bool
    Next(void ** data, int * size)
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes written since this object was created.

    explicit StringOutputStream::StringOutputStream(
            std::string * target)

    Create a StringOutputStream which appends bytes to the given string.

    The string remains property of the caller, but it is mutated in arbitrary ways and MUST NOT be accessed in any way until you're done with the stream. Either be sure there's no further usage, or (safest) destroy the stream before using the contents.

    +

    class StringOutputStream: public ZeroCopyOutputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A ZeroCopyOutputStream which appends bytes to a string.

    Members

    explicit
    StringOutputStream(std::string * target)
    Create a StringOutputStream which appends bytes to the given string. more...
    ~StringOutputStream()

    implements ZeroCopyOutputStream

    virtual bool
    Next(void ** data, int * size)
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes written since this object was created.

    explicit StringOutputStream::StringOutputStream(
            std::string * target)

    Create a StringOutputStream which appends bytes to the given string.

    The string remains property of the caller, but it is mutated in arbitrary ways and MUST NOT be accessed in any way until you're done with the stream. Either be sure there's no further usage, or (safest) destroy the stream before using the contents.

    Hint: If you call target->reserve(n) before creating the stream, the first call to Next() will return at least n bytes of buffer space.


    virtual bool StringOutputStream::Next(
            void ** data,
            int * size)

    Obtains a buffer into which data can be written.

    Any data written into this buffer will eventually (maybe instantly, maybe later on) be written to the output.

    Preconditions:

    @@ -83,14 +83,14 @@ type = "docs"
    • The last "count" bytes of the last buffer returned by Next() will be ignored.
    -

    class CopyingInputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A generic traditional input stream interface.

    Lots of traditional input streams (e.g. file descriptors, C stdio streams, and C++ iostreams) expose an interface where every read involves copying bytes into a buffer. If you want to take such an interface and make a ZeroCopyInputStream based on it, simply implement CopyingInputStream and then use CopyingInputStreamAdaptor.

    +

    class CopyingInputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A generic traditional input stream interface.

    Lots of traditional input streams (e.g. file descriptors, C stdio streams, and C++ iostreams) expose an interface where every read involves copying bytes into a buffer. If you want to take such an interface and make a ZeroCopyInputStream based on it, simply implement CopyingInputStream and then use CopyingInputStreamAdaptor.

    CopyingInputStream implementations should avoid buffering if possible. CopyingInputStreamAdaptor does its own buffering and will read data in large blocks.

    Members

    virtual
    ~CopyingInputStream()
    virtual int
    Read(void * buffer, int size) = 0
    Reads up to "size" bytes into the given buffer. more...
    virtual int
    Skip(int count)
    Skips the next "count" bytes of input. more...

    virtual int CopyingInputStream::Read(
            void * buffer,
            int size) = 0

    Reads up to "size" bytes into the given buffer.

    Returns the number of bytes read. Read() waits until at least one byte is available, or returns zero if no bytes will ever become available (EOF), or -1 if a permanent read error occurred.


    virtual int CopyingInputStream::Skip(
            int count)

    Skips the next "count" bytes of input.

    Returns the number of bytes actually skipped. This will always be exactly equal to "count" unless EOF was reached or a permanent read error occurred.

    The default implementation just repeatedly calls Read() into a scratch buffer.

    -

    class CopyingInputStreamAdaptor: public ZeroCopyInputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A ZeroCopyInputStream which reads from a CopyingInputStream.

    This is useful for implementing ZeroCopyInputStreams that read from traditional streams. Note that this class is not really zero-copy.

    -

    If you want to read from file descriptors or C++ istreams, this is already implemented for you: use FileInputStream or IstreamInputStream respectively.

    -

    Members

    explicit
    CopyingInputStreamAdaptor(CopyingInputStream * copying_stream, int block_size = -1)
    Creates a stream that reads from the given CopyingInputStream. more...
    ~CopyingInputStreamAdaptor()
    void
    SetOwnsCopyingStream(bool value)
    Call SetOwnsCopyingStream(true) to tell the CopyingInputStreamAdaptor to delete the underlying CopyingInputStream when it is destroyed.

    implements ZeroCopyInputStream

    virtual bool
    Next(const void ** data, int * size)
    Obtains a chunk of data from the stream. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes read since this object was created.

    explicit CopyingInputStreamAdaptor::CopyingInputStreamAdaptor(
            CopyingInputStream * copying_stream,
            int block_size = -1)

    Creates a stream that reads from the given CopyingInputStream.

    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. The caller retains ownership of copying_stream unless SetOwnsCopyingStream(true) is called.

    +

    class CopyingInputStreamAdaptor: public ZeroCopyInputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A ZeroCopyInputStream which reads from a CopyingInputStream.

    This is useful for implementing ZeroCopyInputStreams that read from traditional streams. Note that this class is not really zero-copy.

    +

    If you want to read from file descriptors or C++ istreams, this is already implemented for you: use FileInputStream or IstreamInputStream respectively.

    +

    Members

    explicit
    CopyingInputStreamAdaptor(CopyingInputStream * copying_stream, int block_size = -1)
    Creates a stream that reads from the given CopyingInputStream. more...
    ~CopyingInputStreamAdaptor()
    void
    SetOwnsCopyingStream(bool value)
    Call SetOwnsCopyingStream(true) to tell the CopyingInputStreamAdaptor to delete the underlying CopyingInputStream when it is destroyed.

    implements ZeroCopyInputStream

    virtual bool
    Next(const void ** data, int * size)
    Obtains a chunk of data from the stream. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes read since this object was created.

    explicit CopyingInputStreamAdaptor::CopyingInputStreamAdaptor(
            CopyingInputStream * copying_stream,
            int block_size = -1)

    Creates a stream that reads from the given CopyingInputStream.

    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. The caller retains ownership of copying_stream unless SetOwnsCopyingStream(true) is called.


    virtual bool CopyingInputStreamAdaptor::Next(
            const void ** data,
            int * size)

    Obtains a chunk of data from the stream.

    Preconditions:

    • "size" and "data" are not NULL.
    • @@ -113,12 +113,12 @@ type = "docs"
    • The last "count" bytes of the last buffer returned by Next() will be pushed back into the stream. Subsequent calls to Next() will return the same data again before producing new data.

    virtual bool CopyingInputStreamAdaptor::Skip(
            int count)

    Skips a number of bytes.

    Returns false if the end of the stream is reached or some input error occurred. In the end-of-stream case, the stream is advanced to the end of the stream (so ByteCount() will return the total size of the stream).

    -

    class CopyingOutputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A generic traditional output stream interface.

    Lots of traditional output streams (e.g. file descriptors, C stdio streams, and C++ iostreams) expose an interface where every write involves copying bytes from a buffer. If you want to take such an interface and make a ZeroCopyOutputStream based on it, simply implement CopyingOutputStream and then use CopyingOutputStreamAdaptor.

    +

    class CopyingOutputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A generic traditional output stream interface.

    Lots of traditional output streams (e.g. file descriptors, C stdio streams, and C++ iostreams) expose an interface where every write involves copying bytes from a buffer. If you want to take such an interface and make a ZeroCopyOutputStream based on it, simply implement CopyingOutputStream and then use CopyingOutputStreamAdaptor.

    CopyingOutputStream implementations should avoid buffering if possible. CopyingOutputStreamAdaptor does its own buffering and will write data in large blocks.

    Members

    virtual
    ~CopyingOutputStream()
    virtual bool
    Write(const void * buffer, int size) = 0
    Writes "size" bytes from the given buffer to the output. more...

    virtual bool CopyingOutputStream::Write(
            const void * buffer,
            int size) = 0

    Writes "size" bytes from the given buffer to the output.

    Returns true if successful, false on a write error.

    -

    class CopyingOutputStreamAdaptor: public ZeroCopyOutputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A ZeroCopyOutputStream which writes to a CopyingOutputStream.

    This is useful for implementing ZeroCopyOutputStreams that write to traditional streams. Note that this class is not really zero-copy.

    -

    If you want to write to file descriptors or C++ ostreams, this is already implemented for you: use FileOutputStream or OstreamOutputStream respectively.

    -

    Known subclasses:

    Members

    explicit
    CopyingOutputStreamAdaptor(CopyingOutputStream * copying_stream, int block_size = -1)
    Creates a stream that writes to the given Unix file descriptor. more...
    ~CopyingOutputStreamAdaptor()
    bool
    Flush()
    Writes all pending data to the underlying stream. more...
    void
    SetOwnsCopyingStream(bool value)
    Call SetOwnsCopyingStream(true) to tell the CopyingOutputStreamAdaptor to delete the underlying CopyingOutputStream when it is destroyed.

    implements ZeroCopyOutputStream

    virtual bool
    Next(void ** data, int * size)
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes written since this object was created.
    virtual bool
    WriteAliasedRaw(const void * data, int size)
    Write a given chunk of data to the output. more...
    virtual bool
    AllowsAliasing() const

    explicit CopyingOutputStreamAdaptor::CopyingOutputStreamAdaptor(
            CopyingOutputStream * copying_stream,
            int block_size = -1)

    Creates a stream that writes to the given Unix file descriptor.

    If a block_size is given, it specifies the size of the buffers that should be returned by Next(). Otherwise, a reasonable default is used.

    +

    class CopyingOutputStreamAdaptor: public ZeroCopyOutputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A ZeroCopyOutputStream which writes to a CopyingOutputStream.

    This is useful for implementing ZeroCopyOutputStreams that write to traditional streams. Note that this class is not really zero-copy.

    +

    If you want to write to file descriptors or C++ ostreams, this is already implemented for you: use FileOutputStream or OstreamOutputStream respectively.

    +

    Known subclasses:

    Members

    explicit
    CopyingOutputStreamAdaptor(CopyingOutputStream * copying_stream, int block_size = -1)
    Creates a stream that writes to the given Unix file descriptor. more...
    ~CopyingOutputStreamAdaptor()
    bool
    Flush()
    Writes all pending data to the underlying stream. more...
    void
    SetOwnsCopyingStream(bool value)
    Call SetOwnsCopyingStream(true) to tell the CopyingOutputStreamAdaptor to delete the underlying CopyingOutputStream when it is destroyed.

    implements ZeroCopyOutputStream

    virtual bool
    Next(void ** data, int * size)
    Obtains a buffer into which data can be written. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the end of the last buffer returned by Next() is not actually written. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes written since this object was created.
    virtual bool
    WriteAliasedRaw(const void * data, int size)
    Write a given chunk of data to the output. more...
    virtual bool
    AllowsAliasing() const

    explicit CopyingOutputStreamAdaptor::CopyingOutputStreamAdaptor(
            CopyingOutputStream * copying_stream,
            int block_size = -1)

    Creates a stream that writes to the given Unix file descriptor.

    If a block_size is given, it specifies the size of the buffers that should be returned by Next(). Otherwise, a reasonable default is used.


    bool CopyingOutputStreamAdaptor::Flush()

    Writes all pending data to the underlying stream.

    Returns false if a write error occurred on the underlying stream. (The underlying stream itself is not necessarily flushed.)


    virtual bool CopyingOutputStreamAdaptor::Next(
            void ** data,
            int * size)

    Obtains a buffer into which data can be written.

    Any data written into this buffer will eventually (maybe instantly, maybe later on) be written to the output.

    Preconditions:

    @@ -146,7 +146,7 @@ type = "docs"

    virtual bool CopyingOutputStreamAdaptor::WriteAliasedRaw(
            const void * data,
            int size)

    Write a given chunk of data to the output.

    Some output streams may implement this in a way that avoids copying. Check AllowsAliasing() before calling WriteAliasedRaw(). It will GOOGLE_CHECK fail if WriteAliasedRaw() is called on a stream that does not allow aliasing.

    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.

    -

    class LimitingInputStream: public ZeroCopyInputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A ZeroCopyInputStream which wraps some other stream and limits it to a particular byte count.

    Members

    LimitingInputStream(ZeroCopyInputStream * input, int64 limit)
    ~LimitingInputStream()

    implements ZeroCopyInputStream

    virtual bool
    Next(const void ** data, int * size)
    Obtains a chunk of data from the stream. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes read since this object was created.

    virtual bool LimitingInputStream::Next(
            const void ** data,
            int * size)

    Obtains a chunk of data from the stream.

    Preconditions:

    +

    class LimitingInputStream: public ZeroCopyInputStream

    #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
    namespace google::protobuf::io

    A ZeroCopyInputStream which wraps some other stream and limits it to a particular byte count.

    Members

    LimitingInputStream(ZeroCopyInputStream * input, int64 limit)
    ~LimitingInputStream()

    implements ZeroCopyInputStream

    virtual bool
    Next(const void ** data, int * size)
    Obtains a chunk of data from the stream. more...
    virtual void
    BackUp(int count)
    Backs up a number of bytes, so that the next call to Next() returns data again that was already returned by the last call to Next(). more...
    virtual bool
    Skip(int count)
    Skips a number of bytes. more...
    virtual int64_t
    ByteCount() const
    Returns the total number of bytes read since this object was created.

    virtual bool LimitingInputStream::Next(
            const void ** data,
            int * size)

    Obtains a chunk of data from the stream.

    Preconditions:

    • "size" and "data" are not NULL.
    diff --git a/content/reference/cpp/api-docs/google.protobuf.map.md b/content/reference/cpp/api-docs/google.protobuf.map.md index bc0dc12d..b8b9823b 100644 --- a/content/reference/cpp/api-docs/google.protobuf.map.md +++ b/content/reference/cpp/api-docs/google.protobuf.map.md @@ -8,10 +8,10 @@ description = "This section contains reference documentation for working with Pr 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.

    template alias MapPair

    #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.

    -

    template class Map

    #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.

    template alias MapPair

    #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.

    +

    template class Map

    #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() const
    Capacity.
    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) const
    Lookup.
    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
    erase(iterator first, iterator last)
    void
    clear()
    Map &
    operator=(const Map & other)
    Assign.
    void
    swap(Map & other)
    void
    InternalSwap(Map & other)
    hasher
    hash_function() const
    Access to hasher. more...
    size_t
    SpaceUsedExcludingSelfLong() const

    hasher Map::hash_function() const

    Access to hasher.

    Currently this returns a copy, but it may be modified to return a const reference in the future.

    -

    class Map::const_iterator

    #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 )

    class Map::iterator

    #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() const
    Allow implicit conversion to const_iterator.
    +

    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() const
    Capacity.
    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) const
    Lookup.
    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
    erase(iterator first, iterator last)
    void
    clear()
    Map &
    operator=(const Map & other)
    Assign.
    void
    swap(Map & other)
    void
    InternalSwap(Map & other)
    hasher
    hash_function() const
    Access to hasher. more...
    size_t
    SpaceUsedExcludingSelfLong() const

    hasher Map::hash_function() const

    Access to hasher.

    Currently this returns a copy, but it may be modified to return a const reference in the future.

    +

    class Map::const_iterator

    #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 )

    class Map::iterator

    #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() const
    Allow implicit conversion to const_iterator.
    diff --git a/content/reference/cpp/api-docs/google.protobuf.message.md b/content/reference/cpp/api-docs/google.protobuf.message.md index d6b930db..3027b0d6 100644 --- a/content/reference/cpp/api-docs/google.protobuf.message.md +++ b/content/reference/cpp/api-docs/google.protobuf.message.md @@ -6,7 +6,7 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/message.h>
    namespace google::protobuf

    Defines Message, the abstract interface implemented by non-lite protocol message objects.

    Although it's possible to implement this interface manually, most users will use the protocol compiler to generate implementations.

    +

    #include <google/protobuf/message.h>
    namespace google::protobuf

    Defines Message, the abstract interface implemented by non-lite protocol message objects.

    Although it's possible to implement this interface manually, most users will use the protocol compiler to generate implementations.

    Example usage:

    @@ -77,69 +77,69 @@ type = "docs" delete foo; } -

    Classes in this file

    A container to hold message metadata.
    Abstract interface for protocol messages.
    This interface contains methods that can be used to dynamically access and modify the fields of a protocol message.
    Abstract interface for a factory for message objects.

    File Members

    These definitions are not part of any class.
    template const T *
    DynamicCastToGenerated(const Message * from)
    Tries to downcast this message to a generated message type. more...
    template T *
    DynamicCastToGenerated(Message * from)
    template void
    LinkMessageReflection()
    Call this function to ensure that this message's reflection is linked into the binary: more...
    const RepeatedPtrField< std::string > &
    Reflection::GetRepeatedPtrFieldInternal< std::string >(const Message & message, const FieldDescriptor * field) const
    RepeatedPtrField< std::string > *
    Reflection::MutableRepeatedPtrFieldInternal< std::string >(Message * message, const FieldDescriptor * field) const

    template const T * protobuf::DynamicCastToGenerated(
            const Message * from)

    Tries to downcast this message to a generated message type.

    Returns nullptr if this class is not an instance of T. This works even if RTTI is disabled.

    -

    This also has the effect of creating a strong reference to T that will prevent the linker from stripping it out at link time. This can be important if you are using a DynamicMessageFactory that delegates to the generated factory.

    +

    Classes in this file

    A container to hold message metadata.
    Abstract interface for protocol messages.
    This interface contains methods that can be used to dynamically access and modify the fields of a protocol message.
    Abstract interface for a factory for message objects.

    File Members

    These definitions are not part of any class.
    template const T *
    DynamicCastToGenerated(const Message * from)
    Tries to downcast this message to a generated message type. more...
    template T *
    DynamicCastToGenerated(Message * from)
    template void
    LinkMessageReflection()
    Call this function to ensure that this message's reflection is linked into the binary: more...
    const RepeatedPtrField< std::string > &
    Reflection::GetRepeatedPtrFieldInternal< std::string >(const Message & message, const FieldDescriptor * field) const
    RepeatedPtrField< std::string > *
    Reflection::MutableRepeatedPtrFieldInternal< std::string >(Message * message, const FieldDescriptor * field) const

    template const T * protobuf::DynamicCastToGenerated(
            const Message * from)

    Tries to downcast this message to a generated message type.

    Returns nullptr if this class is not an instance of T. This works even if RTTI is disabled.

    +

    This also has the effect of creating a strong reference to T that will prevent the linker from stripping it out at link time. This can be important if you are using a DynamicMessageFactory that delegates to the generated factory.


    template void protobuf::LinkMessageReflection()

    Call this function to ensure that this message's reflection is linked into the binary:

    google::protobuf::LinkMessageReflection<FooMessage>();

    This will ensure that the following lookup will succeed:

    DescriptorPool::generated_pool()->FindMessageTypeByName("FooMessage");

    As a side-effect, it will also guarantee that anything else from the same .proto file will also be available for lookup in the generated pool.

    This function does not actually register the message, so it does not need to be called before the lookup. However it does need to occur in a function that cannot be stripped from the binary (ie. it must be reachable from main).

    Best practice is to call this function as close as possible to where the reflection is actually needed. This function is very cheap to call, so you should not need to worry about its runtime overhead except in the tightest of loops (on x86-64 it compiles into two "mov" instructions).

    -

    struct Metadata

    #include <google/protobuf/message.h>
    namespace google::protobuf

    A container to hold message metadata.

    Members

    const Descriptor *
    descriptor
    const Reflection *
    reflection

    class Message: public MessageLite

    #include <google/protobuf/message.h>
    namespace google::protobuf

    Abstract interface for protocol messages.

    See also MessageLite, which contains most every-day operations. Message adds descriptors and reflection on top of that.

    +

    struct Metadata

    #include <google/protobuf/message.h>
    namespace google::protobuf

    A container to hold message metadata.

    Members

    const Descriptor *
    descriptor
    const Reflection *
    reflection

    class Message: public MessageLite

    #include <google/protobuf/message.h>
    namespace google::protobuf

    Abstract interface for protocol messages.

    See also MessageLite, which contains most every-day operations. Message adds descriptors and reflection on top of that.

    The methods of this class that are virtual but not pure-virtual have default implementations based on reflection. Message classes which are optimized for speed will want to override these with faster implementations, but classes optimized for code size may be happy with keeping them. See the optimize_for option in descriptor.proto.

    Users must not derive from this class. Only the protocol compiler and the internal library are allowed to create subclasses.

    -

    Members

    constexpr
    Message()
    protected virtual Metadata
    GetMetadata() const = 0
    Get a struct containing the metadata for the Message, which is used in turn to implement GetDescriptor() and GetReflection() above.
    protected explicit
    Message(Arena * arena)
    protected static uint64
    GetInvariantPerBuild(uint64 salt)

    Basic Operations

    virtual Message *
    New() const = 0
    Construct a new instance of the same type. more...
    virtual Message *
    New(Arena * arena) const
    Construct a new instance on the arena. more...
    virtual void
    CopyFrom(const Message & from)
    Make this message into a copy of the given message. more...
    virtual void
    MergeFrom(const Message & from)
    Merge the fields from the given message into this message. more...
    void
    CheckInitialized() const
    Verifies that IsInitialized() returns true. more...
    void
    FindInitializationErrors(std::vector< std::string > * errors) const
    Slowly build a list of all required fields that are not set. more...
    virtual std::string
    InitializationErrorString() const
    Like FindInitializationErrors, but joins all the strings, delimited by commas, and returns them.
    virtual void
    DiscardUnknownFields()
    Clears all unknown fields from this message and all embedded messages. more...
    virtual size_t
    SpaceUsedLong() const
    Computes (an estimate of) the total number of bytes currently used for storing the message in memory. more...
    int
    SpaceUsed() const

    Debugging & Testing

    std::string
    DebugString() const
    Generates a human readable form of this message, useful for debugging and other purposes.
    std::string
    ShortDebugString() const
    Like DebugString(), but with less whitespace.
    std::string
    Utf8DebugString() const
    Like DebugString(), but do not escape UTF-8 byte sequences.
    void
    PrintDebugString() const
    Convenience function useful in GDB. Prints DebugString() to stdout.

    Reflection-based methods

    These methods are pure-virtual in MessageLite, but Message provides reflection-based default implementations.
    virtual std::string
    GetTypeName() const
    Get the name of this message type, e.g. "foo.bar.BazProto".
    virtual void
    Clear()
    Clear all fields of the message and set them to their default values. more...
    virtual bool
    IsInitialized() const
    Returns whether all required fields have been set. more...
    virtual void
    CheckTypeAndMergeFrom(const MessageLite & other)
    If |other| is the exact same class as this, calls MergeFrom(). more...
    virtual const char *
    _InternalParse(const char * ptr, internal::ParseContext * ctx)
    Reflective parser.
    virtual size_t
    ByteSizeLong() const
    Computes the serialized size of the message. more...
    virtual uint8 *
    _InternalSerialize(uint8 * ptr, io::EpsCopyOutputStream * stream) const
    Fast path when conditions match (ie. more...

    Introspection

    const Descriptor *
    GetDescriptor() const
    Get a non-owning pointer to a Descriptor for this message's type. more...
    const Reflection *
    GetReflection() const
    Get a non-owning pointer to the Reflection interface for this Message, which can be used to read and modify the fields of the Message dynamically (in other words, without knowing the message type at compile time). more...

    virtual Message * Message::New() const = 0

    Construct a new instance of the same type.

    Ownership is passed to the caller. (This is also defined in MessageLite, but is defined again here for return-type covariance.)

    -

    virtual Message * Message::New(
            Arena * arena) const

    Construct a new instance on the arena.

    Ownership is passed to the caller if arena is a nullptr. Default implementation allows for API compatibility during the Arena transition.

    +

    Members

    constexpr
    Message()
    protected virtual Metadata
    GetMetadata() const = 0
    Get a struct containing the metadata for the Message, which is used in turn to implement GetDescriptor() and GetReflection() above.
    protected explicit
    Message(Arena * arena)
    protected static uint64
    GetInvariantPerBuild(uint64 salt)

    Basic Operations

    virtual Message *
    New() const = 0
    Construct a new instance of the same type. more...
    virtual Message *
    New(Arena * arena) const
    Construct a new instance on the arena. more...
    virtual void
    CopyFrom(const Message & from)
    Make this message into a copy of the given message. more...
    virtual void
    MergeFrom(const Message & from)
    Merge the fields from the given message into this message. more...
    void
    CheckInitialized() const
    Verifies that IsInitialized() returns true. more...
    void
    FindInitializationErrors(std::vector< std::string > * errors) const
    Slowly build a list of all required fields that are not set. more...
    virtual std::string
    InitializationErrorString() const
    Like FindInitializationErrors, but joins all the strings, delimited by commas, and returns them.
    virtual void
    DiscardUnknownFields()
    Clears all unknown fields from this message and all embedded messages. more...
    virtual size_t
    SpaceUsedLong() const
    Computes (an estimate of) the total number of bytes currently used for storing the message in memory. more...
    int
    SpaceUsed() const

    Debugging & Testing

    std::string
    DebugString() const
    Generates a human readable form of this message, useful for debugging and other purposes.
    std::string
    ShortDebugString() const
    Like DebugString(), but with less whitespace.
    std::string
    Utf8DebugString() const
    Like DebugString(), but do not escape UTF-8 byte sequences.
    void
    PrintDebugString() const
    Convenience function useful in GDB. Prints DebugString() to stdout.

    Reflection-based methods

    These methods are pure-virtual in MessageLite, but Message provides reflection-based default implementations.
    virtual std::string
    GetTypeName() const
    Get the name of this message type, e.g. "foo.bar.BazProto".
    virtual void
    Clear()
    Clear all fields of the message and set them to their default values. more...
    virtual bool
    IsInitialized() const
    Returns whether all required fields have been set. more...
    virtual void
    CheckTypeAndMergeFrom(const MessageLite & other)
    If |other| is the exact same class as this, calls MergeFrom(). more...
    virtual const char *
    _InternalParse(const char * ptr, internal::ParseContext * ctx)
    Reflective parser.
    virtual size_t
    ByteSizeLong() const
    Computes the serialized size of the message. more...
    virtual uint8 *
    _InternalSerialize(uint8 * ptr, io::EpsCopyOutputStream * stream) const
    Fast path when conditions match (ie. more...

    Introspection

    const Descriptor *
    GetDescriptor() const
    Get a non-owning pointer to a Descriptor for this message's type. more...
    const Reflection *
    GetReflection() const
    Get a non-owning pointer to the Reflection interface for this Message, which can be used to read and modify the fields of the Message dynamically (in other words, without knowing the message type at compile time). more...

    virtual Message * Message::New() const = 0

    Construct a new instance of the same type.

    Ownership is passed to the caller. (This is also defined in MessageLite, but is defined again here for return-type covariance.)

    +

    virtual Message * Message::New(
            Arena * arena) const

    Construct a new instance on the arena.

    Ownership is passed to the caller if arena is a nullptr. Default implementation allows for API compatibility during the Arena transition.


    virtual void Message::CopyFrom(
            const Message & from)

    Make this message into a copy of the given message.

    The given message must have the same descriptor, but need not necessarily be the same class. By default this is just implemented as "Clear(); MergeFrom(from);".


    virtual void Message::MergeFrom(
            const Message & from)

    Merge the fields from the given message into this message.

    Singular fields will be overwritten, if specified in from, except for embedded messages which will be merged. Repeated fields will be concatenated. The given message must be of the same type as this message (i.e. the exact same class).


    void Message::CheckInitialized() const

    Verifies that IsInitialized() returns true.

    GOOGLE_CHECK-fails otherwise, with a nice error message.


    void Message::FindInitializationErrors(
            std::vector< std::string > * errors) const

    Slowly build a list of all required fields that are not set.

    This is much, much slower than IsInitialized() as it is implemented purely via reflection. Generally, you should not call this unless you have already determined that an error exists by calling IsInitialized().

    -

    virtual void Message::DiscardUnknownFields()

    Clears all unknown fields from this message and all embedded messages.

    Normally, if unknown tag numbers are encountered when parsing a message, the tag and value are stored in the message's UnknownFieldSet and then written back out when the message is serialized. This allows servers which simply route messages to other servers to pass through messages that have new field definitions which they don't yet know about. However, this behavior can have security implications. To avoid it, call this method after parsing.

    +

    virtual void Message::DiscardUnknownFields()

    Clears all unknown fields from this message and all embedded messages.

    Normally, if unknown tag numbers are encountered when parsing a message, the tag and value are stored in the message's UnknownFieldSet and then written back out when the message is serialized. This allows servers which simply route messages to other servers to pass through messages that have new field definitions which they don't yet know about. However, this behavior can have security implications. To avoid it, call this method after parsing.

    See Reflection::GetUnknownFields() for more on unknown fields.


    virtual size_t Message::SpaceUsedLong() const

    Computes (an estimate of) the total number of bytes currently used for storing the message in memory.

    The default implementation calls the Reflection object's SpaceUsed() method.

    -

    SpaceUsed() is noticeably slower than ByteSize(), as it is implemented using reflection (rather than the generated code implementation for ByteSize()). Like ByteSize(), its CPU time is linear in the number of fields defined for the proto.

    +

    SpaceUsed() is noticeably slower than ByteSize(), as it is implemented using reflection (rather than the generated code implementation for ByteSize()). Like ByteSize(), its CPU time is linear in the number of fields defined for the proto.


    virtual void Message::Clear()

    Clear all fields of the message and set them to their default values.

    Clear() avoids freeing memory, assuming that any memory allocated to hold parts of the message will be needed again to hold the next message. If you actually want to free the memory used by a Message, you must delete it.


    virtual bool Message::IsInitialized() const

    Returns whether all required fields have been set.

    Note that required fields no longer exist starting in proto3.

    -

    virtual void Message::CheckTypeAndMergeFrom(
            const MessageLite & other)

    If |other| is the exact same class as this, calls MergeFrom().

    Otherwise, results are undefined (probably crash).

    +

    virtual void Message::CheckTypeAndMergeFrom(
            const MessageLite & other)

    If |other| is the exact same class as this, calls MergeFrom().

    Otherwise, results are undefined (probably crash).


    virtual size_t Message::ByteSizeLong() const

    Computes the serialized size of the message.

    This recursively calls ByteSizeLong() on all embedded messages.

    ByteSizeLong() is generally linear in the number of fields defined for the proto.

    -

    virtual uint8 * Message::_InternalSerialize(
            uint8 * ptr,
            io::EpsCopyOutputStream * stream) const

    Fast path when conditions match (ie.

    non-deterministic) uint8* _InternalSerialize(uint8* ptr) const;

    -

    const Descriptor *
        Message::GetDescriptor() const

    Get a non-owning pointer to a Descriptor for this message's type.

    This describes what fields the message contains, the types of those fields, etc. This object remains property of the Message.

    +

    virtual uint8 * Message::_InternalSerialize(
            uint8 * ptr,
            io::EpsCopyOutputStream * stream) const

    Fast path when conditions match (ie.

    non-deterministic) uint8* _InternalSerialize(uint8* ptr) const;

    +

    const Descriptor *
        Message::GetDescriptor() const

    Get a non-owning pointer to a Descriptor for this message's type.

    This describes what fields the message contains, the types of those fields, etc. This object remains property of the Message.


    const Reflection *
        Message::GetReflection() const

    Get a non-owning pointer to the Reflection interface for this Message, which can be used to read and modify the fields of the Message dynamically (in other words, without knowing the message type at compile time).

    This object remains property of the Message.

    -

    class Reflection

    #include <google/protobuf/message.h>
    namespace google::protobuf

    This interface contains methods that can be used to dynamically access and modify the fields of a protocol message.

    Their semantics are similar to the accessors the protocol compiler generates.

    +

    class Reflection

    #include <google/protobuf/message.h>
    namespace google::protobuf

    This interface contains methods that can be used to dynamically access and modify the fields of a protocol message.

    Their semantics are similar to the accessors the protocol compiler generates.

    To get the Reflection for a given Message, call Message::GetReflection().

    This interface is separate from Message only for efficiency reasons; the vast majority of implementations of Message will share the same implementation of Reflection (GeneratedMessageReflection, defined in generated_message.h), and all Messages of a particular class should share the same Reflection object (though you should not rely on the latter fact).

    There are several ways that these methods can be used incorrectly. For example, any of the following conditions will lead to undefined results (probably assertion failures):

      -
    • The FieldDescriptor is not a field of this message type.
    • +
    • The FieldDescriptor is not a field of this message type.
    • The method called is not appropriate for the field's type. For each field type in FieldDescriptor::TYPE_*, there is only one Get*() method, one Set*() method, and one Add*() method that is valid for that type. It should be obvious which (except maybe for TYPE_BYTES, which are represented using strings in C++).
    • A Get*() or Set*() method for singular fields is called on a repeated field.
    • GetRepeated*(), SetRepeated*(), or Add*() is called on a non-repeated field.
    • The Message object passed to any method is not of the right type for this Reflection object (i.e. message.GetReflection() != reflection).

    You might wonder why there is not any abstract representation for a field of arbitrary type. E.g., why isn't there just a "GetField()" method that returns "const Field&", where "Field" is some class with accessors like "GetInt32Value()". The problem is that someone would have to deal with allocating these Field objects. For generated message classes, having to allocate space for an additional object to wrap every field would at least double the message's memory footprint, probably worse. Allocating the objects on-demand, on the other hand, would be expensive and prone to memory leaks. So, instead we ended up with this flat interface.

    -

    Members

    const UnknownFieldSet &
    GetUnknownFields(const Message & message) const
    Get the UnknownFieldSet for the message. more...
    UnknownFieldSet *
    MutableUnknownFields(Message * message) const
    Get a mutable pointer to the UnknownFieldSet for the message. more...
    size_t
    SpaceUsedLong(const Message & message) const
    Estimate the amount of memory used by the message object.
    int
    SpaceUsed(const Message & message) const
    bool
    HasField(const Message & message, const FieldDescriptor * field) const
    Check if the given non-repeated field is set.
    int
    FieldSize(const Message & message, const FieldDescriptor * field) const
    Get the number of elements of a repeated field.
    void
    ClearField(Message * message, const FieldDescriptor * field) const
    Clear the value of a field, so that HasField() returns false or FieldSize() returns zero.
    bool
    HasOneof(const Message & message, const OneofDescriptor * oneof_descriptor) const
    Check if the oneof is set. more...
    void
    ClearOneof(Message * message, const OneofDescriptor * oneof_descriptor) const
    const FieldDescriptor *
    GetOneofFieldDescriptor(const Message & message, const OneofDescriptor * oneof_descriptor) const
    Returns the field descriptor if the oneof is set. nullptr otherwise.
    void
    RemoveLast(Message * message, const FieldDescriptor * field) const
    Removes the last element of a repeated field. more...
    PROTOBUF_FUTURE_MUST_USE_RESULT Message *
    ReleaseLast(Message * message, const FieldDescriptor * field) const
    Removes the last element of a repeated message field, and returns the pointer to the caller. more...
    void
    Swap(Message * message1, Message * message2) const
    Swap the complete contents of two messages.
    void
    SwapFields(Message * message1, Message * message2, const std::vector< const FieldDescriptor * > & fields) const
    Swap fields listed in fields vector of two messages.
    void
    SwapElements(Message * message, const FieldDescriptor * field, int index1, int index2) const
    Swap two elements of a repeated field.
    void
    ListFields(const Message & message, std::vector< const FieldDescriptor * > * output) const
    List all fields of the message which are currently set, except for unknown fields, but including extension known to the parser (i.e. more...
    const RepeatedPtrField< Message > &
    GetRepeatedPtrFieldInternal(const Message & message, const FieldDescriptor * field) const
    RepeatedPtrField< Message > *
    MutableRepeatedPtrFieldInternal(Message * message, const FieldDescriptor * field) const

    Singular field getters

    These get the value of a non-repeated field. They return the default value for fields that aren't set.
    int32
    GetInt32(const Message & message, const FieldDescriptor * field) const
    int64
    GetInt64(const Message & message, const FieldDescriptor * field) const
    uint32
    GetUInt32(const Message & message, const FieldDescriptor * field) const
    uint64
    GetUInt64(const Message & message, const FieldDescriptor * field) const
    float
    GetFloat(const Message & message, const FieldDescriptor * field) const
    double
    GetDouble(const Message & message, const FieldDescriptor * field) const
    bool
    GetBool(const Message & message, const FieldDescriptor * field) const
    std::string
    GetString(const Message & message, const FieldDescriptor * field) const
    const EnumValueDescriptor *
    GetEnum(const Message & message, const FieldDescriptor * field) const
    int
    GetEnumValue(const Message & message, const FieldDescriptor * field) const
    GetEnumValue() returns an enum field's value as an integer rather than an EnumValueDescriptor*. more...
    const Message &
    GetMessage(const Message & message, const FieldDescriptor * field, MessageFactory * factory = nullptr) const
    See MutableMessage() for the meaning of the "factory" parameter.
    const std::string &
    GetStringReference(const Message & message, const FieldDescriptor * field, std::string * scratch) const
    Get a string value without copying, if possible. more...

    Singular field mutators

    These mutate the value of a non-repeated field.
    void
    SetInt32(Message * message, const FieldDescriptor * field, int32 value) const
    void
    SetInt64(Message * message, const FieldDescriptor * field, int64 value) const
    void
    SetUInt32(Message * message, const FieldDescriptor * field, uint32 value) const
    void
    SetUInt64(Message * message, const FieldDescriptor * field, uint64 value) const
    void
    SetFloat(Message * message, const FieldDescriptor * field, float value) const
    void
    SetDouble(Message * message, const FieldDescriptor * field, double value) const
    void
    SetBool(Message * message, const FieldDescriptor * field, bool value) const
    void
    SetString(Message * message, const FieldDescriptor * field, std::string value) const
    void
    SetEnum(Message * message, const FieldDescriptor * field, const EnumValueDescriptor * value) const
    void
    SetEnumValue(Message * message, const FieldDescriptor * field, int value) const
    Set an enum field's value with an integer rather than EnumValueDescriptor. more...
    Message *
    MutableMessage(Message * message, const FieldDescriptor * field, MessageFactory * factory = nullptr) const
    Get a mutable pointer to a field with a message type. more...
    void
    SetAllocatedMessage(Message * message, Message * sub_message, const FieldDescriptor * field) const
    Replaces the message specified by 'field' with the already-allocated object sub_message, passing ownership to the message. more...
    void
    UnsafeArenaSetAllocatedMessage(Message * message, Message * sub_message, const FieldDescriptor * field) const
    Similar to SetAllocatedMessage, but omits all internal safety and ownership checks. more...
    PROTOBUF_FUTURE_MUST_USE_RESULT Message *
    ReleaseMessage(Message * message, const FieldDescriptor * field, MessageFactory * factory = nullptr) const
    Releases the message specified by 'field' and returns the pointer, ReleaseMessage() will return the message the message object if it exists. more...
    Message *
    UnsafeArenaReleaseMessage(Message * message, const FieldDescriptor * field, MessageFactory * factory = nullptr) const
    Similar to ReleaseMessage, but omits all internal safety and ownership checks. more...

    Repeated field getters

    These get the value of one element of a repeated field.
    int32
    GetRepeatedInt32(const Message & message, const FieldDescriptor * field, int index) const
    int64
    GetRepeatedInt64(const Message & message, const FieldDescriptor * field, int index) const
    uint32
    GetRepeatedUInt32(const Message & message, const FieldDescriptor * field, int index) const
    uint64
    GetRepeatedUInt64(const Message & message, const FieldDescriptor * field, int index) const
    float
    GetRepeatedFloat(const Message & message, const FieldDescriptor * field, int index) const
    double
    GetRepeatedDouble(const Message & message, const FieldDescriptor * field, int index) const
    bool
    GetRepeatedBool(const Message & message, const FieldDescriptor * field, int index) const
    std::string
    GetRepeatedString(const Message & message, const FieldDescriptor * field, int index) const
    const EnumValueDescriptor *
    GetRepeatedEnum(const Message & message, const FieldDescriptor * field, int index) const
    int
    GetRepeatedEnumValue(const Message & message, const FieldDescriptor * field, int index) const
    GetRepeatedEnumValue() returns an enum field's value as an integer rather than an EnumValueDescriptor*. more...
    const Message &
    GetRepeatedMessage(const Message & message, const FieldDescriptor * field, int index) const
    const std::string &
    GetRepeatedStringReference(const Message & message, const FieldDescriptor * field, int index, std::string * scratch) const

    Repeated field mutators

    These mutate the value of one element of a repeated field.
    void
    SetRepeatedInt32(Message * message, const FieldDescriptor * field, int index, int32 value) const
    void
    SetRepeatedInt64(Message * message, const FieldDescriptor * field, int index, int64 value) const
    void
    SetRepeatedUInt32(Message * message, const FieldDescriptor * field, int index, uint32 value) const
    void
    SetRepeatedUInt64(Message * message, const FieldDescriptor * field, int index, uint64 value) const
    void
    SetRepeatedFloat(Message * message, const FieldDescriptor * field, int index, float value) const
    void
    SetRepeatedDouble(Message * message, const FieldDescriptor * field, int index, double value) const
    void
    SetRepeatedBool(Message * message, const FieldDescriptor * field, int index, bool value) const
    void
    SetRepeatedString(Message * message, const FieldDescriptor * field, int index, std::string value) const
    void
    SetRepeatedEnum(Message * message, const FieldDescriptor * field, int index, const EnumValueDescriptor * value) const
    void
    SetRepeatedEnumValue(Message * message, const FieldDescriptor * field, int index, int value) const
    Set an enum field's value with an integer rather than EnumValueDescriptor. more...
    Message *
    MutableRepeatedMessage(Message * message, const FieldDescriptor * field, int index) const
    Get a mutable pointer to an element of a repeated field with a message type.

    Repeated field adders

    These add an element to a repeated field.
    void
    AddInt32(Message * message, const FieldDescriptor * field, int32 value) const
    void
    AddInt64(Message * message, const FieldDescriptor * field, int64 value) const
    void
    AddUInt32(Message * message, const FieldDescriptor * field, uint32 value) const
    void
    AddUInt64(Message * message, const FieldDescriptor * field, uint64 value) const
    void
    AddFloat(Message * message, const FieldDescriptor * field, float value) const
    void
    AddDouble(Message * message, const FieldDescriptor * field, double value) const
    void
    AddBool(Message * message, const FieldDescriptor * field, bool value) const
    void
    AddString(Message * message, const FieldDescriptor * field, std::string value) const
    void
    AddEnum(Message * message, const FieldDescriptor * field, const EnumValueDescriptor * value) const
    void
    AddEnumValue(Message * message, const FieldDescriptor * field, int value) const
    Add an integer value to a repeated enum field rather than EnumValueDescriptor. more...
    Message *
    AddMessage(Message * message, const FieldDescriptor * field, MessageFactory * factory = nullptr) const
    See MutableMessage() for comments on the "factory" parameter.
    void
    AddAllocatedMessage(Message * message, const FieldDescriptor * field, Message * new_entry) const
    Appends an already-allocated object 'new_entry' to the repeated field specified by 'field' passing ownership to the message.
    template RepeatedFieldRef< T >
    GetRepeatedFieldRef(const Message & message, const FieldDescriptor * field) const
    Get a RepeatedFieldRef object that can be used to read the underlying repeated field. more...
    template MutableRepeatedFieldRef< T >
    GetMutableRepeatedFieldRef(Message * message, const FieldDescriptor * field) const
    Like GetRepeatedFieldRef() but return an object that can also be used manipulate the underlying repeated field.
    template const RepeatedField< T > &
    GetRepeatedField(const Message & msg, const FieldDescriptor * d) const
    DEPRECATED. more...
    template RepeatedField< T > *
    MutableRepeatedField(Message * msg, const FieldDescriptor * d) const
    DEPRECATED. more...
    template const RepeatedPtrField< T > &
    GetRepeatedPtrField(const Message & msg, const FieldDescriptor * d) const
    DEPRECATED. more...
    template RepeatedPtrField< T > *
    MutableRepeatedPtrField(Message * msg, const FieldDescriptor * d) const
    DEPRECATED. more...

    Extensions

    const FieldDescriptor *
    FindKnownExtensionByName(const std::string & name) const
    Try to find an extension of this message type by fully-qualified field name. more...
    const FieldDescriptor *
    FindKnownExtensionByNumber(int number) const
    Try to find an extension of this message type by field number. more...

    Feature Flags

    bool
    SupportsUnknownEnumValues() const
    Does this message support storing arbitrary integer values in enum fields? If |true|, GetEnumValue/SetEnumValue and associated repeated-field versions take arbitrary integer values, and the legacy GetEnum() getter will dynamically create an EnumValueDescriptor for any integer value without one. more...
    MessageFactory *
    GetMessageFactory() const
    Returns the MessageFactory associated with this message. more...

    const UnknownFieldSet &
        Reflection::GetUnknownFields(
            const Message & message) const

    Get the UnknownFieldSet for the message.

    This contains fields which were seen when the Message was parsed but were not recognized according to the Message's definition.

    -

    UnknownFieldSet *
        Reflection::MutableUnknownFields(
            Message * message) const

    Get a mutable pointer to the UnknownFieldSet for the message.

    This contains fields which were seen when the Message was parsed but were not recognized according to the Message's definition.

    -

    bool Reflection::HasOneof(
            const Message & message,
            const OneofDescriptor * oneof_descriptor) const

    Check if the oneof is set.

    Returns true if any field in oneof is set, false otherwise.

    -

    void Reflection::RemoveLast(
            Message * message,
            const FieldDescriptor * field) const

    Removes the last element of a repeated field.

    We don't provide a way to remove any element other than the last because it invites inefficient use, such as O(n^2) filtering loops that should have been O(n). If you want to remove an element other than the last, the best way to do it is to re-arrange the elements (using Swap()) so that the one you want removed is at the end, then call RemoveLast().

    -

    PROTOBUF_FUTURE_MUST_USE_RESULT Message *
        Reflection::ReleaseLast(
            Message * message,
            const FieldDescriptor * field) const

    Removes the last element of a repeated message field, and returns the pointer to the caller.

    Caller takes ownership of the returned pointer.

    -

    void Reflection::ListFields(
            const Message & message,
            std::vector< const FieldDescriptor * > * output) const

    List all fields of the message which are currently set, except for unknown fields, but including extension known to the parser (i.e.

    compiled in). Singular fields will only be listed if HasField(field) would return true and repeated fields will only be listed if FieldSize(field) would return non-zero. Fields (both normal fields and extension fields) will be listed ordered by field number. Use Reflection::GetUnknownFields() or message.unknown_fields() to also get access to fields/extensions unknown to the parser.

    -

    int Reflection::GetEnumValue(
            const Message & message,
            const FieldDescriptor * field) const

    GetEnumValue() returns an enum field's value as an integer rather than an EnumValueDescriptor*.

    If the integer value does not correspond to a known value descriptor, a new value descriptor is created. (Such a value will only be present when the new unknown-enum-value semantics are enabled for a message.)

    -

    const std::string &
        Reflection::GetStringReference(
            const Message & message,
            const FieldDescriptor * field,
            std::string * scratch) const

    Get a string value without copying, if possible.

    GetString() necessarily returns a copy of the string. This can be inefficient when the std::string is already stored in a std::string object in the underlying message. GetStringReference() will return a reference to the underlying std::string in this case. Otherwise, it will copy the string into *scratch and return that.

    +

    Members

    const UnknownFieldSet &
    GetUnknownFields(const Message & message) const
    Get the UnknownFieldSet for the message. more...
    UnknownFieldSet *
    MutableUnknownFields(Message * message) const
    Get a mutable pointer to the UnknownFieldSet for the message. more...
    size_t
    SpaceUsedLong(const Message & message) const
    Estimate the amount of memory used by the message object.
    int
    SpaceUsed(const Message & message) const
    bool
    HasField(const Message & message, const FieldDescriptor * field) const
    Check if the given non-repeated field is set.
    int
    FieldSize(const Message & message, const FieldDescriptor * field) const
    Get the number of elements of a repeated field.
    void
    ClearField(Message * message, const FieldDescriptor * field) const
    Clear the value of a field, so that HasField() returns false or FieldSize() returns zero.
    bool
    HasOneof(const Message & message, const OneofDescriptor * oneof_descriptor) const
    Check if the oneof is set. more...
    void
    ClearOneof(Message * message, const OneofDescriptor * oneof_descriptor) const
    const FieldDescriptor *
    GetOneofFieldDescriptor(const Message & message, const OneofDescriptor * oneof_descriptor) const
    Returns the field descriptor if the oneof is set. nullptr otherwise.
    void
    RemoveLast(Message * message, const FieldDescriptor * field) const
    Removes the last element of a repeated field. more...
    PROTOBUF_FUTURE_MUST_USE_RESULT Message *
    ReleaseLast(Message * message, const FieldDescriptor * field) const
    Removes the last element of a repeated message field, and returns the pointer to the caller. more...
    void
    Swap(Message * message1, Message * message2) const
    Swap the complete contents of two messages.
    void
    SwapFields(Message * message1, Message * message2, const std::vector< const FieldDescriptor * > & fields) const
    Swap fields listed in fields vector of two messages.
    void
    SwapElements(Message * message, const FieldDescriptor * field, int index1, int index2) const
    Swap two elements of a repeated field.
    void
    ListFields(const Message & message, std::vector< const FieldDescriptor * > * output) const
    List all fields of the message which are currently set, except for unknown fields, but including extension known to the parser (i.e. more...
    const RepeatedPtrField< Message > &
    GetRepeatedPtrFieldInternal(const Message & message, const FieldDescriptor * field) const
    RepeatedPtrField< Message > *
    MutableRepeatedPtrFieldInternal(Message * message, const FieldDescriptor * field) const

    Singular field getters

    These get the value of a non-repeated field. They return the default value for fields that aren't set.
    int32
    GetInt32(const Message & message, const FieldDescriptor * field) const
    int64
    GetInt64(const Message & message, const FieldDescriptor * field) const
    uint32
    GetUInt32(const Message & message, const FieldDescriptor * field) const
    uint64
    GetUInt64(const Message & message, const FieldDescriptor * field) const
    float
    GetFloat(const Message & message, const FieldDescriptor * field) const
    double
    GetDouble(const Message & message, const FieldDescriptor * field) const
    bool
    GetBool(const Message & message, const FieldDescriptor * field) const
    std::string
    GetString(const Message & message, const FieldDescriptor * field) const
    const EnumValueDescriptor *
    GetEnum(const Message & message, const FieldDescriptor * field) const
    int
    GetEnumValue(const Message & message, const FieldDescriptor * field) const
    GetEnumValue() returns an enum field's value as an integer rather than an EnumValueDescriptor*. more...
    const Message &
    GetMessage(const Message & message, const FieldDescriptor * field, MessageFactory * factory = nullptr) const
    See MutableMessage() for the meaning of the "factory" parameter.
    const std::string &
    GetStringReference(const Message & message, const FieldDescriptor * field, std::string * scratch) const
    Get a string value without copying, if possible. more...

    Singular field mutators

    These mutate the value of a non-repeated field.
    void
    SetInt32(Message * message, const FieldDescriptor * field, int32 value) const
    void
    SetInt64(Message * message, const FieldDescriptor * field, int64 value) const
    void
    SetUInt32(Message * message, const FieldDescriptor * field, uint32 value) const
    void
    SetUInt64(Message * message, const FieldDescriptor * field, uint64 value) const
    void
    SetFloat(Message * message, const FieldDescriptor * field, float value) const
    void
    SetDouble(Message * message, const FieldDescriptor * field, double value) const
    void
    SetBool(Message * message, const FieldDescriptor * field, bool value) const
    void
    SetString(Message * message, const FieldDescriptor * field, std::string value) const
    void
    SetEnum(Message * message, const FieldDescriptor * field, const EnumValueDescriptor * value) const
    void
    SetEnumValue(Message * message, const FieldDescriptor * field, int value) const
    Set an enum field's value with an integer rather than EnumValueDescriptor. more...
    Message *
    MutableMessage(Message * message, const FieldDescriptor * field, MessageFactory * factory = nullptr) const
    Get a mutable pointer to a field with a message type. more...
    void
    SetAllocatedMessage(Message * message, Message * sub_message, const FieldDescriptor * field) const
    Replaces the message specified by 'field' with the already-allocated object sub_message, passing ownership to the message. more...
    void
    UnsafeArenaSetAllocatedMessage(Message * message, Message * sub_message, const FieldDescriptor * field) const
    Similar to SetAllocatedMessage, but omits all internal safety and ownership checks. more...
    PROTOBUF_FUTURE_MUST_USE_RESULT Message *
    ReleaseMessage(Message * message, const FieldDescriptor * field, MessageFactory * factory = nullptr) const
    Releases the message specified by 'field' and returns the pointer, ReleaseMessage() will return the message the message object if it exists. more...
    Message *
    UnsafeArenaReleaseMessage(Message * message, const FieldDescriptor * field, MessageFactory * factory = nullptr) const
    Similar to ReleaseMessage, but omits all internal safety and ownership checks. more...

    Repeated field getters

    These get the value of one element of a repeated field.
    int32
    GetRepeatedInt32(const Message & message, const FieldDescriptor * field, int index) const
    int64
    GetRepeatedInt64(const Message & message, const FieldDescriptor * field, int index) const
    uint32
    GetRepeatedUInt32(const Message & message, const FieldDescriptor * field, int index) const
    uint64
    GetRepeatedUInt64(const Message & message, const FieldDescriptor * field, int index) const
    float
    GetRepeatedFloat(const Message & message, const FieldDescriptor * field, int index) const
    double
    GetRepeatedDouble(const Message & message, const FieldDescriptor * field, int index) const
    bool
    GetRepeatedBool(const Message & message, const FieldDescriptor * field, int index) const
    std::string
    GetRepeatedString(const Message & message, const FieldDescriptor * field, int index) const
    const EnumValueDescriptor *
    GetRepeatedEnum(const Message & message, const FieldDescriptor * field, int index) const
    int
    GetRepeatedEnumValue(const Message & message, const FieldDescriptor * field, int index) const
    GetRepeatedEnumValue() returns an enum field's value as an integer rather than an EnumValueDescriptor*. more...
    const Message &
    GetRepeatedMessage(const Message & message, const FieldDescriptor * field, int index) const
    const std::string &
    GetRepeatedStringReference(const Message & message, const FieldDescriptor * field, int index, std::string * scratch) const

    Repeated field mutators

    These mutate the value of one element of a repeated field.
    void
    SetRepeatedInt32(Message * message, const FieldDescriptor * field, int index, int32 value) const
    void
    SetRepeatedInt64(Message * message, const FieldDescriptor * field, int index, int64 value) const
    void
    SetRepeatedUInt32(Message * message, const FieldDescriptor * field, int index, uint32 value) const
    void
    SetRepeatedUInt64(Message * message, const FieldDescriptor * field, int index, uint64 value) const
    void
    SetRepeatedFloat(Message * message, const FieldDescriptor * field, int index, float value) const
    void
    SetRepeatedDouble(Message * message, const FieldDescriptor * field, int index, double value) const
    void
    SetRepeatedBool(Message * message, const FieldDescriptor * field, int index, bool value) const
    void
    SetRepeatedString(Message * message, const FieldDescriptor * field, int index, std::string value) const
    void
    SetRepeatedEnum(Message * message, const FieldDescriptor * field, int index, const EnumValueDescriptor * value) const
    void
    SetRepeatedEnumValue(Message * message, const FieldDescriptor * field, int index, int value) const
    Set an enum field's value with an integer rather than EnumValueDescriptor. more...
    Message *
    MutableRepeatedMessage(Message * message, const FieldDescriptor * field, int index) const
    Get a mutable pointer to an element of a repeated field with a message type.

    Repeated field adders

    These add an element to a repeated field.
    void
    AddInt32(Message * message, const FieldDescriptor * field, int32 value) const
    void
    AddInt64(Message * message, const FieldDescriptor * field, int64 value) const
    void
    AddUInt32(Message * message, const FieldDescriptor * field, uint32 value) const
    void
    AddUInt64(Message * message, const FieldDescriptor * field, uint64 value) const
    void
    AddFloat(Message * message, const FieldDescriptor * field, float value) const
    void
    AddDouble(Message * message, const FieldDescriptor * field, double value) const
    void
    AddBool(Message * message, const FieldDescriptor * field, bool value) const
    void
    AddString(Message * message, const FieldDescriptor * field, std::string value) const
    void
    AddEnum(Message * message, const FieldDescriptor * field, const EnumValueDescriptor * value) const
    void
    AddEnumValue(Message * message, const FieldDescriptor * field, int value) const
    Add an integer value to a repeated enum field rather than EnumValueDescriptor. more...
    Message *
    AddMessage(Message * message, const FieldDescriptor * field, MessageFactory * factory = nullptr) const
    See MutableMessage() for comments on the "factory" parameter.
    void
    AddAllocatedMessage(Message * message, const FieldDescriptor * field, Message * new_entry) const
    Appends an already-allocated object 'new_entry' to the repeated field specified by 'field' passing ownership to the message.
    template RepeatedFieldRef< T >
    GetRepeatedFieldRef(const Message & message, const FieldDescriptor * field) const
    Get a RepeatedFieldRef object that can be used to read the underlying repeated field. more...
    template MutableRepeatedFieldRef< T >
    GetMutableRepeatedFieldRef(Message * message, const FieldDescriptor * field) const
    Like GetRepeatedFieldRef() but return an object that can also be used manipulate the underlying repeated field.
    template const RepeatedField< T > &
    GetRepeatedField(const Message & msg, const FieldDescriptor * d) const
    DEPRECATED. more...
    template RepeatedField< T > *
    MutableRepeatedField(Message * msg, const FieldDescriptor * d) const
    DEPRECATED. more...
    template const RepeatedPtrField< T > &
    GetRepeatedPtrField(const Message & msg, const FieldDescriptor * d) const
    DEPRECATED. more...
    template RepeatedPtrField< T > *
    MutableRepeatedPtrField(Message * msg, const FieldDescriptor * d) const
    DEPRECATED. more...

    Extensions

    const FieldDescriptor *
    FindKnownExtensionByName(const std::string & name) const
    Try to find an extension of this message type by fully-qualified field name. more...
    const FieldDescriptor *
    FindKnownExtensionByNumber(int number) const
    Try to find an extension of this message type by field number. more...

    Feature Flags

    bool
    SupportsUnknownEnumValues() const
    Does this message support storing arbitrary integer values in enum fields? If |true|, GetEnumValue/SetEnumValue and associated repeated-field versions take arbitrary integer values, and the legacy GetEnum() getter will dynamically create an EnumValueDescriptor for any integer value without one. more...
    MessageFactory *
    GetMessageFactory() const
    Returns the MessageFactory associated with this message. more...

    const UnknownFieldSet &
        Reflection::GetUnknownFields(
            const Message & message) const

    Get the UnknownFieldSet for the message.

    This contains fields which were seen when the Message was parsed but were not recognized according to the Message's definition.

    +

    UnknownFieldSet *
        Reflection::MutableUnknownFields(
            Message * message) const

    Get a mutable pointer to the UnknownFieldSet for the message.

    This contains fields which were seen when the Message was parsed but were not recognized according to the Message's definition.

    +

    bool Reflection::HasOneof(
            const Message & message,
            const OneofDescriptor * oneof_descriptor) const

    Check if the oneof is set.

    Returns true if any field in oneof is set, false otherwise.

    +

    void Reflection::RemoveLast(
            Message * message,
            const FieldDescriptor * field) const

    Removes the last element of a repeated field.

    We don't provide a way to remove any element other than the last because it invites inefficient use, such as O(n^2) filtering loops that should have been O(n). If you want to remove an element other than the last, the best way to do it is to re-arrange the elements (using Swap()) so that the one you want removed is at the end, then call RemoveLast().

    +

    PROTOBUF_FUTURE_MUST_USE_RESULT Message *
        Reflection::ReleaseLast(
            Message * message,
            const FieldDescriptor * field) const

    Removes the last element of a repeated message field, and returns the pointer to the caller.

    Caller takes ownership of the returned pointer.

    +

    void Reflection::ListFields(
            const Message & message,
            std::vector< const FieldDescriptor * > * output) const

    List all fields of the message which are currently set, except for unknown fields, but including extension known to the parser (i.e.

    compiled in). Singular fields will only be listed if HasField(field) would return true and repeated fields will only be listed if FieldSize(field) would return non-zero. Fields (both normal fields and extension fields) will be listed ordered by field number. Use Reflection::GetUnknownFields() or message.unknown_fields() to also get access to fields/extensions unknown to the parser.

    +

    int Reflection::GetEnumValue(
            const Message & message,
            const FieldDescriptor * field) const

    GetEnumValue() returns an enum field's value as an integer rather than an EnumValueDescriptor*.

    If the integer value does not correspond to a known value descriptor, a new value descriptor is created. (Such a value will only be present when the new unknown-enum-value semantics are enabled for a message.)

    +

    const std::string &
        Reflection::GetStringReference(
            const Message & message,
            const FieldDescriptor * field,
            std::string * scratch) const

    Get a string value without copying, if possible.

    GetString() necessarily returns a copy of the string. This can be inefficient when the std::string is already stored in a std::string object in the underlying message. GetStringReference() will return a reference to the underlying std::string in this case. Otherwise, it will copy the string into *scratch and return that.

    Note: It is perfectly reasonable and useful to write code like:

    str = reflection->GetStringReference(message, field, &str);

    This line would ensure that only one copy of the string is made regardless of the field's underlying representation. When initializing a newly-constructed string, though, it's just as fast and more readable to use code like:

    std::string str = reflection->GetString(message, field);
    -

    void Reflection::SetEnumValue(
            Message * message,
            const FieldDescriptor * field,
            int value) const

    Set an enum field's value with an integer rather than EnumValueDescriptor.

    For proto3 this is just setting the enum field to the value specified, for proto2 it's more complicated. If value is a known enum value the field is set as usual. If the value is unknown then it is added to the unknown field set. Note this matches the behavior of parsing unknown enum values. If multiple calls with unknown values happen than they are all added to the unknown field set in order of the calls.

    -

    Message * Reflection::MutableMessage(
            Message * message,
            const FieldDescriptor * field,
            MessageFactory * factory = nullptr) const

    Get a mutable pointer to a field with a message type.

    If a MessageFactory is provided, it will be used to construct instances of the sub-message; otherwise, the default factory is used. If the field is an extension that does not live in the same pool as the containing message's descriptor (e.g. it lives in an overlay pool), then a MessageFactory must be provided. If you have no idea what that meant, then you probably don't need to worry about it (don't provide a MessageFactory). WARNING: If the FieldDescriptor is for a compiled-in extension, then factory->GetPrototype(field->message_type()) MUST return an instance of the compiled-in class for this type, NOT DynamicMessage.

    -

    void Reflection::SetAllocatedMessage(
            Message * message,
            Message * sub_message,
            const FieldDescriptor * field) const

    Replaces the message specified by 'field' with the already-allocated object sub_message, passing ownership to the message.

    If the field contained a message, that message is deleted. If sub_message is nullptr, the field is cleared.

    -

    void Reflection::UnsafeArenaSetAllocatedMessage(
            Message * message,
            Message * sub_message,
            const FieldDescriptor * field) const

    Similar to SetAllocatedMessage, but omits all internal safety and ownership checks.

    This method should only be used when the objects are on the same arena or paired with a call to UnsafeArenaReleaseMessage.

    -

    PROTOBUF_FUTURE_MUST_USE_RESULT Message *
        Reflection::ReleaseMessage(
            Message * message,
            const FieldDescriptor * field,
            MessageFactory * factory = nullptr) const

    Releases the message specified by 'field' and returns the pointer, ReleaseMessage() will return the message the message object if it exists.

    Otherwise, it may or may not return nullptr. In any case, if the return value is non-null, the caller takes ownership of the pointer. If the field existed (HasField() is true), then the returned pointer will be the same as the pointer returned by MutableMessage(). This function has the same effect as ClearField().

    -

    Message * Reflection::UnsafeArenaReleaseMessage(
            Message * message,
            const FieldDescriptor * field,
            MessageFactory * factory = nullptr) const

    Similar to ReleaseMessage, but omits all internal safety and ownership checks.

    This method should only be used when the objects are on the same arena or paired with a call to UnsafeArenaSetAllocatedMessage.

    -

    int Reflection::GetRepeatedEnumValue(
            const Message & message,
            const FieldDescriptor * field,
            int index) const

    GetRepeatedEnumValue() returns an enum field's value as an integer rather than an EnumValueDescriptor*.

    If the integer value does not correspond to a known value descriptor, a new value descriptor is created. (Such a value will only be present when the new unknown-enum-value semantics are enabled for a message.)

    -

    void Reflection::SetRepeatedEnumValue(
            Message * message,
            const FieldDescriptor * field,
            int index,
            int value) const

    Set an enum field's value with an integer rather than EnumValueDescriptor.

    For proto3 this is just setting the enum field to the value specified, for proto2 it's more complicated. If value is a known enum value the field is set as usual. If the value is unknown then it is added to the unknown field set. Note this matches the behavior of parsing unknown enum values. If multiple calls with unknown values happen than they are all added to the unknown field set in order of the calls.

    -

    void Reflection::AddEnumValue(
            Message * message,
            const FieldDescriptor * field,
            int value) const

    Add an integer value to a repeated enum field rather than EnumValueDescriptor.

    For proto3 this is just setting the enum field to the value specified, for proto2 it's more complicated. If value is a known enum value the field is set as usual. If the value is unknown then it is added to the unknown field set. Note this matches the behavior of parsing unknown enum values. If multiple calls with unknown values happen than they are all added to the unknown field set in order of the calls.

    -

    template RepeatedFieldRef< T >
        Reflection::GetRepeatedFieldRef(
            const Message & message,
            const FieldDescriptor * field) const

    Get a RepeatedFieldRef object that can be used to read the underlying repeated field.

    The type parameter T must be set according to the field's cpp type. The following table shows the mapping from cpp type to acceptable T.

    +

    void Reflection::SetEnumValue(
            Message * message,
            const FieldDescriptor * field,
            int value) const

    Set an enum field's value with an integer rather than EnumValueDescriptor.

    For proto3 this is just setting the enum field to the value specified, for proto2 it's more complicated. If value is a known enum value the field is set as usual. If the value is unknown then it is added to the unknown field set. Note this matches the behavior of parsing unknown enum values. If multiple calls with unknown values happen than they are all added to the unknown field set in order of the calls.

    +

    Message * Reflection::MutableMessage(
            Message * message,
            const FieldDescriptor * field,
            MessageFactory * factory = nullptr) const

    Get a mutable pointer to a field with a message type.

    If a MessageFactory is provided, it will be used to construct instances of the sub-message; otherwise, the default factory is used. If the field is an extension that does not live in the same pool as the containing message's descriptor (e.g. it lives in an overlay pool), then a MessageFactory must be provided. If you have no idea what that meant, then you probably don't need to worry about it (don't provide a MessageFactory). WARNING: If the FieldDescriptor is for a compiled-in extension, then factory->GetPrototype(field->message_type()) MUST return an instance of the compiled-in class for this type, NOT DynamicMessage.

    +

    void Reflection::SetAllocatedMessage(
            Message * message,
            Message * sub_message,
            const FieldDescriptor * field) const

    Replaces the message specified by 'field' with the already-allocated object sub_message, passing ownership to the message.

    If the field contained a message, that message is deleted. If sub_message is nullptr, the field is cleared.

    +

    void Reflection::UnsafeArenaSetAllocatedMessage(
            Message * message,
            Message * sub_message,
            const FieldDescriptor * field) const

    Similar to SetAllocatedMessage, but omits all internal safety and ownership checks.

    This method should only be used when the objects are on the same arena or paired with a call to UnsafeArenaReleaseMessage.

    +

    PROTOBUF_FUTURE_MUST_USE_RESULT Message *
        Reflection::ReleaseMessage(
            Message * message,
            const FieldDescriptor * field,
            MessageFactory * factory = nullptr) const

    Releases the message specified by 'field' and returns the pointer, ReleaseMessage() will return the message the message object if it exists.

    Otherwise, it may or may not return nullptr. In any case, if the return value is non-null, the caller takes ownership of the pointer. If the field existed (HasField() is true), then the returned pointer will be the same as the pointer returned by MutableMessage(). This function has the same effect as ClearField().

    +

    Message * Reflection::UnsafeArenaReleaseMessage(
            Message * message,
            const FieldDescriptor * field,
            MessageFactory * factory = nullptr) const

    Similar to ReleaseMessage, but omits all internal safety and ownership checks.

    This method should only be used when the objects are on the same arena or paired with a call to UnsafeArenaSetAllocatedMessage.

    +

    int Reflection::GetRepeatedEnumValue(
            const Message & message,
            const FieldDescriptor * field,
            int index) const

    GetRepeatedEnumValue() returns an enum field's value as an integer rather than an EnumValueDescriptor*.

    If the integer value does not correspond to a known value descriptor, a new value descriptor is created. (Such a value will only be present when the new unknown-enum-value semantics are enabled for a message.)

    +

    void Reflection::SetRepeatedEnumValue(
            Message * message,
            const FieldDescriptor * field,
            int index,
            int value) const

    Set an enum field's value with an integer rather than EnumValueDescriptor.

    For proto3 this is just setting the enum field to the value specified, for proto2 it's more complicated. If value is a known enum value the field is set as usual. If the value is unknown then it is added to the unknown field set. Note this matches the behavior of parsing unknown enum values. If multiple calls with unknown values happen than they are all added to the unknown field set in order of the calls.

    +

    void Reflection::AddEnumValue(
            Message * message,
            const FieldDescriptor * field,
            int value) const

    Add an integer value to a repeated enum field rather than EnumValueDescriptor.

    For proto3 this is just setting the enum field to the value specified, for proto2 it's more complicated. If value is a known enum value the field is set as usual. If the value is unknown then it is added to the unknown field set. Note this matches the behavior of parsing unknown enum values. If multiple calls with unknown values happen than they are all added to the unknown field set in order of the calls.

    +

    template RepeatedFieldRef< T >
        Reflection::GetRepeatedFieldRef(
            const Message & message,
            const FieldDescriptor * field) const

    Get a RepeatedFieldRef object that can be used to read the underlying repeated field.

    The type parameter T must be set according to the field's cpp type. The following table shows the mapping from cpp type to acceptable T.

    field->cpp_type()      T
     CPPTYPE_INT32        int32
     CPPTYPE_UINT32       uint32
    @@ -153,20 +153,20 @@ CPPTYPE_STRING       std::string
     CPPTYPE_MESSAGE      generated message type or google::protobuf::Message

    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) const

    DEPRECATED.

    Please use GetRepeatedFieldRef().

    +

    template const RepeatedField< T > &
        Reflection::GetRepeatedField(
            const Message & msg,
            const FieldDescriptor * d) const

    DEPRECATED.

    Please use GetRepeatedFieldRef().

    for T = Cord and all Protobuf scalar types except enums.

    -

    template RepeatedField< T > *
        Reflection::MutableRepeatedField(
            Message * msg,
            const FieldDescriptor * d) const

    DEPRECATED.

    Please use GetMutableRepeatedFieldRef().

    +

    template RepeatedField< T > *
        Reflection::MutableRepeatedField(
            Message * msg,
            const FieldDescriptor * d) const

    DEPRECATED.

    Please use GetMutableRepeatedFieldRef().

    for T = Cord and all Protobuf scalar types except enums.

    -

    template const RepeatedPtrField< T > &
        Reflection::GetRepeatedPtrField(
            const Message & msg,
            const FieldDescriptor * d) const

    DEPRECATED.

    Please use GetRepeatedFieldRef().

    +

    template const RepeatedPtrField< T > &
        Reflection::GetRepeatedPtrField(
            const Message & msg,
            const FieldDescriptor * d) const

    DEPRECATED.

    Please use GetRepeatedFieldRef().

    for T = std::string, google::protobuf::internal::StringPieceField

    google::protobuf::Message & descendants.
    -

    template RepeatedPtrField< T > *
        Reflection::MutableRepeatedPtrField(
            Message * msg,
            const FieldDescriptor * d) const

    DEPRECATED.

    Please use GetMutableRepeatedFieldRef().

    +

    template RepeatedPtrField< T > *
        Reflection::MutableRepeatedPtrField(
            Message * msg,
            const FieldDescriptor * d) const

    DEPRECATED.

    Please use GetMutableRepeatedFieldRef().

    for T = std::string, google::protobuf::internal::StringPieceField

    google::protobuf::Message & descendants.
    -

    const FieldDescriptor *
        Reflection::FindKnownExtensionByName(
            const std::string & name) const

    Try to find an extension of this message type by fully-qualified field name.

    Returns nullptr if no extension is known for this name or number.

    -

    const FieldDescriptor *
        Reflection::FindKnownExtensionByNumber(
            int number) const

    Try to find an extension of this message type by field number.

    Returns nullptr if no extension is known for this name or number.

    -

    bool Reflection::SupportsUnknownEnumValues() const

    Does this message support storing arbitrary integer values in enum fields? If |true|, GetEnumValue/SetEnumValue and associated repeated-field versions take arbitrary integer values, and the legacy GetEnum() getter will dynamically create an EnumValueDescriptor for any integer value without one.

    If |false|, setting an unknown enum value via the integer-based setters results in undefined behavior (in practice, GOOGLE_DCHECK-fails).

    -

    Generic code that uses reflection to handle messages with enum fields should check this flag before using the integer-based setter, and either downgrade to a compatible value or use the UnknownFieldSet if not. For example:

    +

    const FieldDescriptor *
        Reflection::FindKnownExtensionByName(
            const std::string & name) const

    Try to find an extension of this message type by fully-qualified field name.

    Returns nullptr if no extension is known for this name or number.

    +

    const FieldDescriptor *
        Reflection::FindKnownExtensionByNumber(
            int number) const

    Try to find an extension of this message type by field number.

    Returns nullptr if no extension is known for this name or number.

    +

    bool Reflection::SupportsUnknownEnumValues() const

    Does this message support storing arbitrary integer values in enum fields? If |true|, GetEnumValue/SetEnumValue and associated repeated-field versions take arbitrary integer values, and the legacy GetEnum() getter will dynamically create an EnumValueDescriptor for any integer value without one.

    If |false|, setting an unknown enum value via the integer-based setters results in undefined behavior (in practice, GOOGLE_DCHECK-fails).

    +

    Generic code that uses reflection to handle messages with enum fields should check this flag before using the integer-based setter, and either downgrade to a compatible value or use the UnknownFieldSet if not. For example:

    int new_value = GetValueFromApplicationLogic();
     if (reflection->SupportsUnknownEnumValues()) {
       reflection->SetEnumValue(message, field, new_value);
    @@ -189,17 +189,17 @@ if (reflection->SupportsUnknownEnumValues()) {
       // This is a generated message.
     }

    It can also be used to create more messages of this type, though Message::New() is an easier way to accomplish this.

    -

    class MessageFactory

    #include <google/protobuf/message.h>
    namespace google::protobuf

    Abstract interface for a factory for message objects.

    Known subclasses:

    Members

    MessageFactory()
    virtual
    ~MessageFactory()
    virtual const Message *
    GetPrototype(const Descriptor * type) = 0
    Given a Descriptor, gets or constructs the default (prototype) Message of that type. more...
    static MessageFactory *
    generated_factory()
    Gets a MessageFactory which supports all generated, compiled-in messages. more...
    static void
    InternalRegisterGeneratedFile(const google::protobuf::internal::DescriptorTable * table)
    For internal use only: Registers a .proto file at static initialization time, to be placed in generated_factory. more...
    static void
    InternalRegisterGeneratedMessage(const Descriptor * descriptor, const Message * prototype)
    For internal use only: Registers a message type. more...

    virtual const Message * MessageFactory::GetPrototype(
            const Descriptor * type) = 0

    Given a Descriptor, gets or constructs the default (prototype) Message of that type.

    You can then call that message's New() method to construct a mutable message of that type.

    -

    Calling this method twice with the same Descriptor returns the same object. The returned object remains property of the factory. Also, any objects created by calling the prototype's New() method share some data with the prototype, so these must be destroyed before the MessageFactory is destroyed.

    +

    class MessageFactory

    #include <google/protobuf/message.h>
    namespace google::protobuf

    Abstract interface for a factory for message objects.

    Known subclasses:

    Members

    MessageFactory()
    virtual
    ~MessageFactory()
    virtual const Message *
    GetPrototype(const Descriptor * type) = 0
    Given a Descriptor, gets or constructs the default (prototype) Message of that type. more...
    static MessageFactory *
    generated_factory()
    Gets a MessageFactory which supports all generated, compiled-in messages. more...
    static void
    InternalRegisterGeneratedFile(const google::protobuf::internal::DescriptorTable * table)
    For internal use only: Registers a .proto file at static initialization time, to be placed in generated_factory. more...
    static void
    InternalRegisterGeneratedMessage(const Descriptor * descriptor, const Message * prototype)
    For internal use only: Registers a message type. more...

    virtual const Message * MessageFactory::GetPrototype(
            const Descriptor * type) = 0

    Given a Descriptor, gets or constructs the default (prototype) Message of that type.

    You can then call that message's New() method to construct a mutable message of that type.

    +

    Calling this method twice with the same Descriptor returns the same object. The returned object remains property of the factory. Also, any objects created by calling the prototype's New() method share some data with the prototype, so these must be destroyed before the MessageFactory is destroyed.

    The given descriptor must outlive the returned message, and hence must outlive the MessageFactory.

    Some implementations do not support all types. GetPrototype() will return nullptr if the descriptor passed in is not supported.

    This method may or may not be thread-safe depending on the implementation. Each implementation should document its own degree thread-safety.


    static MessageFactory * MessageFactory::generated_factory()

    Gets a MessageFactory which supports all generated, compiled-in messages.

    In other words, for any compiled-in type FooMessage, the following is true:

    MessageFactory::generated_factory()->GetPrototype(
       FooMessage::descriptor()) == FooMessage::default_instance()
    -

    This factory supports all types which are found in DescriptorPool::generated_pool(). If given a descriptor from any other pool, GetPrototype() will return nullptr. (You can also check if a descriptor is for a generated message by checking if descriptor->file()->pool() == DescriptorPool::generated_pool().)

    +

    This factory supports all types which are found in DescriptorPool::generated_pool(). If given a descriptor from any other pool, GetPrototype() will return nullptr. (You can also check if a descriptor is for a generated message by checking if descriptor->file()->pool() == DescriptorPool::generated_pool().)

    This factory is 100% thread-safe; calling GetPrototype() does not modify any shared data.

    This factory is a singleton. The caller must not delete the object.


    static void MessageFactory::InternalRegisterGeneratedFile(
            const google::protobuf::internal::DescriptorTable * table)

    For internal use only: Registers a .proto file at static initialization time, to be placed in generated_factory.

    The first time GetPrototype() is called with a descriptor from this file, |register_messages| will be called, with the file name as the parameter. It must call InternalRegisterGeneratedMessage() (below) to register each message type in the file. This strange mechanism is necessary because descriptors are built lazily, so we can't register types by their descriptor until we know that the descriptor exists. |filename| must be a permanent string.

    -

    static void MessageFactory::InternalRegisterGeneratedMessage(
            const Descriptor * descriptor,
            const Message * prototype)

    For internal use only: Registers a message type.

    Called only by the functions which are registered with InternalRegisterGeneratedFile(), above.

    +

    static void MessageFactory::InternalRegisterGeneratedMessage(
            const Descriptor * descriptor,
            const Message * prototype)

    For internal use only: Registers a message type.

    Called only by the functions which are registered with InternalRegisterGeneratedFile(), above.

    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 ee01ba1f..657361c2 100644 --- a/content/reference/cpp/api-docs/google.protobuf.message_lite.md +++ b/content/reference/cpp/api-docs/google.protobuf.message_lite.md @@ -8,7 +8,7 @@ description = "This section contains reference documentation for working with Pr 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 Members

    These 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:

    +

    #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 Members

    These 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:

    • You use a draconian definition of "memory leak" in which you expect every single malloc() to have a corresponding free(), even for objects which live until program exit.
    • @@ -16,7 +16,7 @@ type = "docs"

    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.

    -

    class MessageLite

    #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:

    +

    class MessageLite

    #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;
    @@ -26,42 +26,42 @@ type = "docs"

    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 = 0
    Fast path when conditions match (ie. more...
    bool
    IsInitializedWithErrors() const
    Identical to IsInitialized() except that it logs an error message.
    protected template static T *
    CreateMaybeMessage(Arena * arena)
    protected explicit
    MessageLite(Arena * arena)
    protected Arena *
    GetOwningArena() const
    Returns 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() const
    Returns 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 = 0
    Get the name of this message type, e.g. "foo.bar.BazProto".
    virtual MessageLite *
    New() const = 0
    Construct a new instance of the same type. more...
    virtual MessageLite *
    New(Arena * arena) const
    Construct a new instance on the arena. more...
    Arena *
    GetArena() const
    Same as GetOwningArena.
    void *
    GetMaybeArenaPointer() const
    Get a pointer that may be equal to this message's arena, or may not be. more...
    virtual void
    Clear() = 0
    Clear all fields of the message and set them to their default values. more...
    virtual bool
    IsInitialized() const = 0
    Quickly check if all required fields have values set.
    virtual std::string
    InitializationErrorString() const
    This is not implemented for Lite messages – it just returns "(cannot +

    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 = 0
    Fast path when conditions match (ie. more...
    bool
    IsInitializedWithErrors() const
    Identical to IsInitialized() except that it logs an error message.
    protected template static T *
    CreateMaybeMessage(Arena * arena)
    protected explicit
    MessageLite(Arena * arena)
    protected Arena *
    GetOwningArena() const
    Returns 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() const
    Returns 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 = 0
    Get the name of this message type, e.g. "foo.bar.BazProto".
    virtual MessageLite *
    New() const = 0
    Construct a new instance of the same type. more...
    virtual MessageLite *
    New(Arena * arena) const
    Construct a new instance on the arena. more...
    Arena *
    GetArena() const
    Same as GetOwningArena.
    void *
    GetMaybeArenaPointer() const
    Get a pointer that may be equal to this message's arena, or may not be. more...
    virtual void
    Clear() = 0
    Clear all fields of the message and set them to their default values. more...
    virtual bool
    IsInitialized() const = 0
    Quickly check if all required fields have values set.
    virtual std::string
    InitializationErrorString() const
    This is not implemented for Lite messages – it just returns "(cannot determine missing fields for lite message)". more...
    virtual void
    CheckTypeAndMergeFrom(const MessageLite & other) = 0
    If |other| is the exact same class as this, calls MergeFrom(). more...
    std::string
    DebugString() const
    These methods return a human-readable summary of the message. more...
    std::string
    ShortDebugString() const
    std::string
    Utf8DebugString() const
    MessageLite::DebugString is already Utf8 Safe. more...

    Parsing

    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 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)
    Reads a Protobuf message from the stream and merges it into this Message. more...
    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

    +
    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)
    Reads a Protobuf message from the stream and merges it into this Message. more...
    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) const
    Write this Protobuf message to the given output. more...
    bool
    SerializePartialToCodedStream(io::CodedOutputStream * output) const
    Like SerializeToCodedStream(), but allows missing required fields.
    bool
    SerializeToZeroCopyStream(io::ZeroCopyOutputStream * output) const
    Write the message to the given zero-copy output stream. more...
    bool
    SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream * output) const
    Like SerializeToZeroCopyStream(), but allows missing required fields.
    bool
    SerializeToString(std::string * output) const
    Serialize the message and store it in the given string. more...
    bool
    SerializePartialToString(std::string * output) const
    Like SerializeToString(), but allows missing required fields.
    bool
    SerializeToArray(void * data, int size) const
    Serialize the message and store it in the given byte array. more...
    bool
    SerializePartialToArray(void * data, int size) const
    Like SerializeToArray(), but allows missing required fields.
    std::string
    SerializeAsString() const
    Make a string encoding the message. more...
    std::string
    SerializePartialAsString() const
    Like SerializeAsString(), but allows missing required fields.
    bool
    SerializeToFileDescriptor(int file_descriptor) const
    Serialize the message and write it to the given file descriptor. more...
    bool
    SerializePartialToFileDescriptor(int file_descriptor) const
    Like SerializeToFileDescriptor(), but allows missing required fields.
    bool
    SerializeToOstream(std::ostream * output) const
    Serialize the message and write it to the given C++ ostream. more...
    bool
    SerializePartialToOstream(std::ostream * output) const
    Like SerializeToOstream(), but allows missing required fields.
    bool
    AppendToString(std::string * output) const
    Like SerializeToString(), but appends to the data to the string's existing contents. more...
    bool
    AppendPartialToString(std::string * output) const
    Like AppendToString(), but allows missing required fields.
    virtual size_t
    ByteSizeLong() const = 0
    Computes the serialized size of the message. more...
    int
    ByteSize() const
    Legacy ByteSize() API.
    void
    SerializeWithCachedSizes(io::CodedOutputStream * output) const
    Serializes the message without recomputing the size. more...
    uint8 *
    SerializeWithCachedSizesToArray(uint8 * target) const
    Like SerializeWithCachedSizes, but writes directly to *target, returning a pointer to the byte immediately after the last byte written. more...
    virtual int
    GetCachedSize() const = 0
    Returns 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 = 0

    Fast path when conditions match (ie.

    non-deterministic) uint8* _InternalSerialize(uint8* ptr) const;

    -

    protected Arena * MessageLite::GetOwningArena() const

    Returns 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.

    +
    bool
    SerializeToCodedStream(io::CodedOutputStream * output) const
    Write this Protobuf message to the given output. more...
    bool
    SerializePartialToCodedStream(io::CodedOutputStream * output) const
    Like SerializeToCodedStream(), but allows missing required fields.
    bool
    SerializeToZeroCopyStream(io::ZeroCopyOutputStream * output) const
    Write the message to the given zero-copy output stream. more...
    bool
    SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream * output) const
    Like SerializeToZeroCopyStream(), but allows missing required fields.
    bool
    SerializeToString(std::string * output) const
    Serialize the message and store it in the given string. more...
    bool
    SerializePartialToString(std::string * output) const
    Like SerializeToString(), but allows missing required fields.
    bool
    SerializeToArray(void * data, int size) const
    Serialize the message and store it in the given byte array. more...
    bool
    SerializePartialToArray(void * data, int size) const
    Like SerializeToArray(), but allows missing required fields.
    std::string
    SerializeAsString() const
    Make a string encoding the message. more...
    std::string
    SerializePartialAsString() const
    Like SerializeAsString(), but allows missing required fields.
    bool
    SerializeToFileDescriptor(int file_descriptor) const
    Serialize the message and write it to the given file descriptor. more...
    bool
    SerializePartialToFileDescriptor(int file_descriptor) const
    Like SerializeToFileDescriptor(), but allows missing required fields.
    bool
    SerializeToOstream(std::ostream * output) const
    Serialize the message and write it to the given C++ ostream. more...
    bool
    SerializePartialToOstream(std::ostream * output) const
    Like SerializeToOstream(), but allows missing required fields.
    bool
    AppendToString(std::string * output) const
    Like SerializeToString(), but appends to the data to the string's existing contents. more...
    bool
    AppendPartialToString(std::string * output) const
    Like AppendToString(), but allows missing required fields.
    virtual size_t
    ByteSizeLong() const = 0
    Computes the serialized size of the message. more...
    int
    ByteSize() const
    Legacy ByteSize() API.
    void
    SerializeWithCachedSizes(io::CodedOutputStream * output) const
    Serializes the message without recomputing the size. more...
    uint8 *
    SerializeWithCachedSizesToArray(uint8 * target) const
    Like SerializeWithCachedSizes, but writes directly to *target, returning a pointer to the byte immediately after the last byte written. more...
    virtual int
    GetCachedSize() const = 0
    Returns 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 = 0

    Fast path when conditions match (ie.

    non-deterministic) uint8* _InternalSerialize(uint8* ptr) const;

    +

    protected Arena * MessageLite::GetOwningArena() const

    Returns 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 = 0

    Construct a new instance of the same type.

    Ownership is passed to the caller.

    -

    virtual MessageLite * MessageLite::New(
            Arena * arena) const

    Construct a new instance on the arena.

    Ownership is passed to the caller if arena is a NULL. Default implementation for backwards compatibility.

    +

    virtual MessageLite * MessageLite::New(
            Arena * arena) const

    Construct a new instance on the arena.

    Ownership is passed to the caller if arena is a NULL. Default implementation for backwards compatibility.


    void * MessageLite::GetMaybeArenaPointer() const

    Get a pointer that may be equal to this message's arena, or may not be.

    If the value returned by this method is equal to some arena pointer, then this message is on that arena; however, if this message is on some arena, this method may or may not return that arena's pointer. As a tradeoff, this method may be more efficient than GetArena(). The intent is to allow underlying representations that use e.g. tagged pointers to sometimes store the arena pointer directly, and sometimes in a more indirect way, and allow a fastpath comparison against the arena pointer when it's easy to obtain.

    -

    virtual void MessageLite::Clear() = 0

    Clear all fields of the message and set them to their default values.

    Clear() avoids freeing memory, assuming that any memory allocated to hold parts of the message will be needed again to hold the next message. If you actually want to free the memory used by a Message, you must delete it.

    +

    virtual void MessageLite::Clear() = 0

    Clear all fields of the message and set them to their default values.

    Clear() avoids freeing memory, assuming that any memory allocated to hold parts of the message will be needed again to hold the next message. If you actually want to free the memory used by a Message, you must delete it.


    virtual std::string MessageLite::InitializationErrorString() const

    This is not implemented for Lite messages – it just returns "(cannot -determine missing fields for lite message)".

    However, it is implemented for full messages. See message.h.

    +determine missing fields for lite message)".

    However, it is implemented for full messages. See message.h.


    virtual void MessageLite::CheckTypeAndMergeFrom(
            const MessageLite & other) = 0

    If |other| is the exact same class as this, calls MergeFrom().

    Otherwise, results are undefined (probably crash).

    -

    std::string MessageLite::DebugString() const

    These methods return a human-readable summary of the message.

    Note that since the MessageLite interface does not support reflection, there is very little information that these methods can provide. They are shadowed by methods of the same name on the Message interface which provide much more information. The methods here are intended primarily to facilitate code reuse for logic that needs to interoperate with both full and lite protos.

    +

    std::string MessageLite::DebugString() const

    These methods return a human-readable summary of the message.

    Note that since the MessageLite interface does not support reflection, there is very little information that these methods can provide. They are shadowed by methods of the same name on the Message interface which provide much more information. The methods here are intended primarily to facilitate code reuse for logic that needs to interoperate with both full and lite protos.

    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() const

    MessageLite::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 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.

    +

    std::string MessageLite::Utf8DebugString() const

    MessageLite::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 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.

    +

    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) const

    Write 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) const

    Write the message to the given zero-copy output stream.

    All required fields must be set.

    +

    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) const

    Write 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) const

    Write the message to the given zero-copy output stream.

    All required fields must be set.


    bool MessageLite::SerializeToString(
            std::string * output) const

    Serialize the message and store it in the given string.

    All required fields must be set.


    bool MessageLite::SerializeToArray(
            void * data,
            int size) const

    Serialize the message and store it in the given byte array.

    All required fields must be set.


    std::string MessageLite::SerializeAsString() const

    Make a string encoding the message.

    Is equivalent to calling SerializeToString() on a string and using that. Returns the empty string if SerializeToString() would have returned an error. Note: If you intend to generate many such strings, you may reduce heap fragmentation by instead re-using the same string object with calls to SerializeToString().

    @@ -71,7 +71,7 @@ determine missing fields for lite message)".

    However, it is implemented f


    virtual size_t MessageLite::ByteSizeLong() const = 0

    Computes the serialized size of the message.

    This recursively calls ByteSizeLong() on all embedded messages.

    ByteSizeLong() is generally linear in the number of fields defined for the proto.

    -

    void MessageLite::SerializeWithCachedSizes(
            io::CodedOutputStream * output) const

    Serializes the message without recomputing the size.

    The message must not have changed since the last call to ByteSize(), and the value returned by ByteSize must be non-negative. Otherwise the results are undefined.

    +

    void MessageLite::SerializeWithCachedSizes(
            io::CodedOutputStream * output) const

    Serializes the message without recomputing the size.

    The message must not have changed since the last call to ByteSize(), and the value returned by ByteSize must be non-negative. Otherwise the results are undefined.


    uint8 * MessageLite::SerializeWithCachedSizesToArray(
            uint8 * target) const

    Like SerializeWithCachedSizes, but writes directly to *target, returning a pointer to the byte immediately after the last byte written.

    "target" must point at a byte array of at least ByteSize() bytes. Whether to use deterministic serialization, e.g., maps in sorted order, is determined by CodedOutputStream::IsDefaultSerializationDeterministic().


    virtual int MessageLite::GetCachedSize() const = 0

    Returns the result of the last call to ByteSize().

    An embedded message's size is needed both to serialize it (because embedded messages are length-delimited) and to compute the outer message's size. Caching the size avoids computing it multiple times.

    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 62824ecd..9e06d97a 100644 --- a/content/reference/cpp/api-docs/google.protobuf.repeated_field.md +++ b/content/reference/cpp/api-docs/google.protobuf.repeated_field.md @@ -6,7 +6,7 @@ description = "This section contains reference documentation for working with Pr 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 Protobuf. 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.

    @@ -16,8 +16,8 @@ temp_field.AddAllocated(new T); ... // Do something with temp_field temp_field.ExtractSubrange(0, temp_field.size(), nullptr);

    If you put temp_field on the arena this fails, because the ownership transfers to the arena at the "AddAllocated" call and is not released anymore causing a double delete. Using UnsafeArenaAddAllocated prevents this.

    -

    template class RepeatedField

    #include <google/protobuf/repeated_field.h>
    namespace google::protobuf

    template <typename >

    RepeatedField is used to represent repeated fields of a primitive type (in other words, everything except strings and nested Messages).

    Most users will not ever use a RepeatedField directly; they will use the get-by-index, set-by-index, and add accessors that are generated for all repeated fields.

    -

    Members

    typedef
    Element * iterator
    STL-like iterator support.
    typedef
    const Element * const_iterator
    typedef
    Element value_type
    typedef
    value_type & reference
    typedef
    const value_type & const_reference
    typedef
    value_type * pointer
    typedef
    const value_type * const_pointer
    typedef
    int size_type
    typedef
    ptrdiff_t difference_type
    typedef
    std::reverse_iterator< const_iterator > const_reverse_iterator
    Reverse iterator support.
    typedef
    std::reverse_iterator< iterator > reverse_iterator
    constexpr
    RepeatedField()
    explicit
    RepeatedField(Arena * arena)
    RepeatedField(const RepeatedField & other)
    template
    RepeatedField(Iter begin, Iter end)
    ~RepeatedField()
    RepeatedField &
    operator=(const RepeatedField & other)
    RepeatedField(RepeatedField && other)
    RepeatedField &
    operator=(RepeatedField && other)
    bool
    empty() const
    int
    size() const
    const Element &
    Get(int index) const
    Element *
    Mutable(int index)
    const Element &
    operator[](int index) const
    Element &
    operator[](int index)
    const Element &
    at(int index) const
    Element &
    at(int index)
    void
    Set(int index, const Element & value)
    void
    Add(const Element & value)
    Element *
    Add()
    Appends a new element and return a pointer to it. more...
    template void
    Add(Iter begin, Iter end)
    Append elements in the range [begin, end) after reserving the appropriate number of elements.
    void
    RemoveLast()
    Remove the last element in the array.
    void
    ExtractSubrange(int start, int num, Element * elements)
    Extract elements with indices in "[start .. start+num-1]". more...
    void
    Clear()
    void
    MergeFrom(const RepeatedField & other)
    void
    CopyFrom(const RepeatedField & other)
    template void
    Assign(Iter begin, Iter end)
    Replaces the contents with RepeatedField(begin, end).
    void
    Reserve(int new_size)
    Reserve space to expand the field to at least the given size. more...
    void
    Truncate(int new_size)
    Resize the RepeatedField to a new, smaller size. This is O(1).
    void
    AddAlreadyReserved(const Element & value)
    Element *
    AddAlreadyReserved()
    Appends a new element and return a pointer to it. more...
    Element *
    AddNAlreadyReserved(int elements)
    int
    Capacity() const
    void
    Resize(int new_size, const Element & value)
    Like STL resize. more...
    Element *
    mutable_data()
    Gets the underlying array. more...
    const Element *
    data() const
    void
    Swap(RepeatedField * other)
    Swap entire contents with "other". more...
    void
    UnsafeArenaSwap(RepeatedField * other)
    Swap entire contents with "other". more...
    void
    SwapElements(int index1, int index2)
    Swap two elements.
    iterator
    begin()
    const_iterator
    begin() const
    const_iterator
    cbegin() const
    iterator
    end()
    const_iterator
    end() const
    const_iterator
    cend() const
    reverse_iterator
    rbegin()
    const_reverse_iterator
    rbegin() const
    reverse_iterator
    rend()
    const_reverse_iterator
    rend() const
    size_t
    SpaceUsedExcludingSelfLong() const
    Returns the number of bytes used by the repeated field, excluding sizeof(*this)
    int
    SpaceUsedExcludingSelf() const
    iterator
    erase(const_iterator position)
    Removes the element referenced by position. more...
    iterator
    erase(const_iterator first, const_iterator last)
    Removes the elements in the range [first, last). more...
    Arena *
    GetArena() const
    Get the Arena on which this RepeatedField stores its elements.
    void
    InternalSwap(RepeatedField * other)
    For internal use only. more...
    template
    RepeatedField(Iter begin, Iter end)

    Element * RepeatedField::Add()

    Appends a new element and return a pointer to it.

    The new element is uninitialized if |Element| is a POD type.

    +

    template class RepeatedField

    #include <google/protobuf/repeated_field.h>
    namespace google::protobuf

    template <typename >

    RepeatedField is used to represent repeated fields of a primitive type (in other words, everything except strings and nested Messages).

    Most users will not ever use a RepeatedField directly; they will use the get-by-index, set-by-index, and add accessors that are generated for all repeated fields.

    +

    Members

    typedef
    Element * iterator
    STL-like iterator support.
    typedef
    const Element * const_iterator
    typedef
    Element value_type
    typedef
    value_type & reference
    typedef
    const value_type & const_reference
    typedef
    value_type * pointer
    typedef
    const value_type * const_pointer
    typedef
    int size_type
    typedef
    ptrdiff_t difference_type
    typedef
    std::reverse_iterator< const_iterator > const_reverse_iterator
    Reverse iterator support.
    typedef
    std::reverse_iterator< iterator > reverse_iterator
    constexpr
    RepeatedField()
    explicit
    RepeatedField(Arena * arena)
    RepeatedField(const RepeatedField & other)
    template
    RepeatedField(Iter begin, Iter end)
    ~RepeatedField()
    RepeatedField &
    operator=(const RepeatedField & other)
    RepeatedField(RepeatedField && other)
    RepeatedField &
    operator=(RepeatedField && other)
    bool
    empty() const
    int
    size() const
    const Element &
    Get(int index) const
    Element *
    Mutable(int index)
    const Element &
    operator[](int index) const
    Element &
    operator[](int index)
    const Element &
    at(int index) const
    Element &
    at(int index)
    void
    Set(int index, const Element & value)
    void
    Add(const Element & value)
    Element *
    Add()
    Appends a new element and return a pointer to it. more...
    template void
    Add(Iter begin, Iter end)
    Append elements in the range [begin, end) after reserving the appropriate number of elements.
    void
    RemoveLast()
    Remove the last element in the array.
    void
    ExtractSubrange(int start, int num, Element * elements)
    Extract elements with indices in "[start .. start+num-1]". more...
    void
    Clear()
    void
    MergeFrom(const RepeatedField & other)
    void
    CopyFrom(const RepeatedField & other)
    template void
    Assign(Iter begin, Iter end)
    Replaces the contents with RepeatedField(begin, end).
    void
    Reserve(int new_size)
    Reserve space to expand the field to at least the given size. more...
    void
    Truncate(int new_size)
    Resize the RepeatedField to a new, smaller size. This is O(1).
    void
    AddAlreadyReserved(const Element & value)
    Element *
    AddAlreadyReserved()
    Appends a new element and return a pointer to it. more...
    Element *
    AddNAlreadyReserved(int elements)
    int
    Capacity() const
    void
    Resize(int new_size, const Element & value)
    Like STL resize. more...
    Element *
    mutable_data()
    Gets the underlying array. more...
    const Element *
    data() const
    void
    Swap(RepeatedField * other)
    Swap entire contents with "other". more...
    void
    UnsafeArenaSwap(RepeatedField * other)
    Swap entire contents with "other". more...
    void
    SwapElements(int index1, int index2)
    Swap two elements.
    iterator
    begin()
    const_iterator
    begin() const
    const_iterator
    cbegin() const
    iterator
    end()
    const_iterator
    end() const
    const_iterator
    cend() const
    reverse_iterator
    rbegin()
    const_reverse_iterator
    rbegin() const
    reverse_iterator
    rend()
    const_reverse_iterator
    rend() const
    size_t
    SpaceUsedExcludingSelfLong() const
    Returns the number of bytes used by the repeated field, excluding sizeof(*this)
    int
    SpaceUsedExcludingSelf() const
    iterator
    erase(const_iterator position)
    Removes the element referenced by position. more...
    iterator
    erase(const_iterator first, const_iterator last)
    Removes the elements in the range [first, last). more...
    Arena *
    GetArena() const
    Get the Arena on which this RepeatedField stores its elements.
    void
    InternalSwap(RepeatedField * other)
    For internal use only. more...
    template
    RepeatedField(Iter begin, Iter end)

    Element * RepeatedField::Add()

    Appends a new element and return a pointer to it.

    The new element is uninitialized if |Element| is a POD type.


    void RepeatedField::ExtractSubrange(
            int start,
            int num,
            Element * elements)

    Extract elements with indices in "[start .. start+num-1]".

    Copy them into "elements[0 .. num-1]" if "elements" is not NULL. Caution: implementation also moves elements with indices [start+num ..]. Calling this routine inside a loop can cause quadratic behavior.


    void RepeatedField::Reserve(
            int new_size)

    Reserve space to expand the field to at least the given size.

    Avoid inlining of Reserve(): new, copy, and delete[] lead to a significant amount of code bloat.

    If the array is grown, it will always be at least doubled in size.

    @@ -31,7 +31,7 @@ temp_field.ExtractSubrange(0, temp_field.size(), nullptr);

    iterator RepeatedField::erase(
            const_iterator first,
            const_iterator last)

    Removes the elements in the range [first, last).

    Returns an iterator to the element immediately following the removed range.

    Invalidates all iterators at or after the removed range, including end().


    void RepeatedField::InternalSwap(
            RepeatedField * other)

    For internal use only.

    This is public due to it being called by generated code.

    -

    template class RepeatedPtrField

    #include <google/protobuf/repeated_field.h>
    namespace google::protobuf

    template <typename >

    RepeatedPtrField is like RepeatedField, but used for repeated strings or Messages.

    Members

    typedef
    internal::RepeatedPtrIterator< Element > iterator
    STL-like iterator support.
    typedef
    internal::RepeatedPtrIterator< const Element > const_iterator
    typedef
    Element value_type
    typedef
    value_type & reference
    typedef
    const value_type & const_reference
    typedef
    value_type * pointer
    typedef
    const value_type * const_pointer
    typedef
    int size_type
    typedef
    ptrdiff_t difference_type
    typedef
    std::reverse_iterator< const_iterator > const_reverse_iterator
    Reverse iterator support.
    typedef
    std::reverse_iterator< iterator > reverse_iterator
    typedef
    internal::RepeatedPtrOverPtrsIterator< Element *, void * > pointer_iterator
    Custom STL-like iterator that iterates over and returns the underlying pointers to Element rather than Element itself.
    typedef
    internal::RepeatedPtrOverPtrsIterator< const Element *const, const void *const > const_pointer_iterator
    constexpr
    RepeatedPtrField()
    explicit
    RepeatedPtrField(Arena * arena)
    RepeatedPtrField(const RepeatedPtrField & other)
    template
    RepeatedPtrField(Iter begin, Iter end)
    ~RepeatedPtrField()
    RepeatedPtrField &
    operator=(const RepeatedPtrField & other)
    RepeatedPtrField(RepeatedPtrField && other)
    RepeatedPtrField &
    operator=(RepeatedPtrField && other)
    bool
    empty() const
    int
    size() const
    const Element &
    Get(int index) const
    Element *
    Mutable(int index)
    Element *
    Add()
    void
    Add(Element && value)
    template void
    Add(Iter begin, Iter end)
    Append elements in the range [begin, end) after reserving the appropriate number of elements.
    const Element &
    operator[](int index) const
    Element &
    operator[](int index)
    const Element &
    at(int index) const
    Element &
    at(int index)
    void
    RemoveLast()
    Remove the last element in the array. more...
    void
    DeleteSubrange(int start, int num)
    Delete elements with indices in the range [start . more...
    void
    Clear()
    void
    MergeFrom(const RepeatedPtrField & other)
    void
    CopyFrom(const RepeatedPtrField & other)
    template void
    Assign(Iter begin, Iter end)
    Replaces the contents with RepeatedPtrField(begin, end).
    void
    Reserve(int new_size)
    Reserve space to expand the field to at least the given size. more...
    int
    Capacity() const
    Element **
    mutable_data()
    Gets the underlying array. more...
    const Element *const *
    data() const
    void
    Swap(RepeatedPtrField * other)
    Swap entire contents with "other". more...
    void
    UnsafeArenaSwap(RepeatedPtrField * other)
    Swap entire contents with "other". more...
    void
    SwapElements(int index1, int index2)
    Swap two elements.
    iterator
    begin()
    const_iterator
    begin() const
    const_iterator
    cbegin() const
    iterator
    end()
    const_iterator
    end() const
    const_iterator
    cend() const
    reverse_iterator
    rbegin()
    const_reverse_iterator
    rbegin() const
    reverse_iterator
    rend()
    const_reverse_iterator
    rend() const
    pointer_iterator
    pointer_begin()
    const_pointer_iterator
    pointer_begin() const
    pointer_iterator
    pointer_end()
    const_pointer_iterator
    pointer_end() const
    size_t
    SpaceUsedExcludingSelfLong() const
    Returns (an estimate of) the number of bytes used by the repeated field, excluding sizeof(*this).
    int
    SpaceUsedExcludingSelf() const
    template
    RepeatedPtrField(Iter begin, Iter end)

    Advanced memory management

    When hardcore memory management becomes necessary – as it sometimes does here at Google – the following methods may be useful.
    void
    AddAllocated(Element * value)
    Add an already-allocated object, passing ownership to the RepeatedPtrField. more...
    PROTOBUF_FUTURE_MUST_USE_RESULT Element *
    ReleaseLast()
    Remove the last element and return it, passing ownership to the caller. more...
    void
    UnsafeArenaAddAllocated(Element * value)
    Add an already-allocated object, skipping arena-ownership checks. more...
    Element *
    UnsafeArenaReleaseLast()
    Remove the last element and return it. more...
    void
    ExtractSubrange(int start, int num, Element ** elements)
    Extract elements with indices in the range "[start .. start+num-1]". more...
    void
    UnsafeArenaExtractSubrange(int start, int num, Element ** elements)
    Identical to ExtractSubrange() described above, except that when this repeated field is on an arena, no object copies are performed. more...
    int
    ClearedCount() const
    Get the number of cleared objects that are currently being kept around for reuse.
    void
    AddCleared(Element * value)
    Add an element to the pool of cleared objects, passing ownership to the RepeatedPtrField. more...
    PROTOBUF_FUTURE_MUST_USE_RESULT Element *
    ReleaseCleared()
    Remove a single element from the cleared pool and return it, passing ownership to the caller. more...
    iterator
    erase(const_iterator position)
    Removes the element referenced by position. more...
    iterator
    erase(const_iterator first, const_iterator last)
    Removes the elements in the range [first, last). more...
    Arena *
    GetArena() const
    Gets the arena on which this RepeatedPtrField stores its elements.
    void
    InternalSwap(RepeatedPtrField * other)
    For internal use only. more...

    void RepeatedPtrField::RemoveLast()

    Remove the last element in the array.

    Ownership of the element is retained by the array.

    +

    template class RepeatedPtrField

    #include <google/protobuf/repeated_field.h>
    namespace google::protobuf

    template <typename >

    RepeatedPtrField is like RepeatedField, but used for repeated strings or Messages.

    Members

    typedef
    internal::RepeatedPtrIterator< Element > iterator
    STL-like iterator support.
    typedef
    internal::RepeatedPtrIterator< const Element > const_iterator
    typedef
    Element value_type
    typedef
    value_type & reference
    typedef
    const value_type & const_reference
    typedef
    value_type * pointer
    typedef
    const value_type * const_pointer
    typedef
    int size_type
    typedef
    ptrdiff_t difference_type
    typedef
    std::reverse_iterator< const_iterator > const_reverse_iterator
    Reverse iterator support.
    typedef
    std::reverse_iterator< iterator > reverse_iterator
    typedef
    internal::RepeatedPtrOverPtrsIterator< Element *, void * > pointer_iterator
    Custom STL-like iterator that iterates over and returns the underlying pointers to Element rather than Element itself.
    typedef
    internal::RepeatedPtrOverPtrsIterator< const Element *const, const void *const > const_pointer_iterator
    constexpr
    RepeatedPtrField()
    explicit
    RepeatedPtrField(Arena * arena)
    RepeatedPtrField(const RepeatedPtrField & other)
    template
    RepeatedPtrField(Iter begin, Iter end)
    ~RepeatedPtrField()
    RepeatedPtrField &
    operator=(const RepeatedPtrField & other)
    RepeatedPtrField(RepeatedPtrField && other)
    RepeatedPtrField &
    operator=(RepeatedPtrField && other)
    bool
    empty() const
    int
    size() const
    const Element &
    Get(int index) const
    Element *
    Mutable(int index)
    Element *
    Add()
    void
    Add(Element && value)
    template void
    Add(Iter begin, Iter end)
    Append elements in the range [begin, end) after reserving the appropriate number of elements.
    const Element &
    operator[](int index) const
    Element &
    operator[](int index)
    const Element &
    at(int index) const
    Element &
    at(int index)
    void
    RemoveLast()
    Remove the last element in the array. more...
    void
    DeleteSubrange(int start, int num)
    Delete elements with indices in the range [start . more...
    void
    Clear()
    void
    MergeFrom(const RepeatedPtrField & other)
    void
    CopyFrom(const RepeatedPtrField & other)
    template void
    Assign(Iter begin, Iter end)
    Replaces the contents with RepeatedPtrField(begin, end).
    void
    Reserve(int new_size)
    Reserve space to expand the field to at least the given size. more...
    int
    Capacity() const
    Element **
    mutable_data()
    Gets the underlying array. more...
    const Element *const *
    data() const
    void
    Swap(RepeatedPtrField * other)
    Swap entire contents with "other". more...
    void
    UnsafeArenaSwap(RepeatedPtrField * other)
    Swap entire contents with "other". more...
    void
    SwapElements(int index1, int index2)
    Swap two elements.
    iterator
    begin()
    const_iterator
    begin() const
    const_iterator
    cbegin() const
    iterator
    end()
    const_iterator
    end() const
    const_iterator
    cend() const
    reverse_iterator
    rbegin()
    const_reverse_iterator
    rbegin() const
    reverse_iterator
    rend()
    const_reverse_iterator
    rend() const
    pointer_iterator
    pointer_begin()
    const_pointer_iterator
    pointer_begin() const
    pointer_iterator
    pointer_end()
    const_pointer_iterator
    pointer_end() const
    size_t
    SpaceUsedExcludingSelfLong() const
    Returns (an estimate of) the number of bytes used by the repeated field, excluding sizeof(*this).
    int
    SpaceUsedExcludingSelf() const
    template
    RepeatedPtrField(Iter begin, Iter end)

    Advanced memory management

    When hardcore memory management becomes necessary – as it sometimes does here at Google – the following methods may be useful.
    void
    AddAllocated(Element * value)
    Add an already-allocated object, passing ownership to the RepeatedPtrField. more...
    PROTOBUF_FUTURE_MUST_USE_RESULT Element *
    ReleaseLast()
    Remove the last element and return it, passing ownership to the caller. more...
    void
    UnsafeArenaAddAllocated(Element * value)
    Add an already-allocated object, skipping arena-ownership checks. more...
    Element *
    UnsafeArenaReleaseLast()
    Remove the last element and return it. more...
    void
    ExtractSubrange(int start, int num, Element ** elements)
    Extract elements with indices in the range "[start .. start+num-1]". more...
    void
    UnsafeArenaExtractSubrange(int start, int num, Element ** elements)
    Identical to ExtractSubrange() described above, except that when this repeated field is on an arena, no object copies are performed. more...
    int
    ClearedCount() const
    Get the number of cleared objects that are currently being kept around for reuse.
    void
    AddCleared(Element * value)
    Add an element to the pool of cleared objects, passing ownership to the RepeatedPtrField. more...
    PROTOBUF_FUTURE_MUST_USE_RESULT Element *
    ReleaseCleared()
    Remove a single element from the cleared pool and return it, passing ownership to the caller. more...
    iterator
    erase(const_iterator position)
    Removes the element referenced by position. more...
    iterator
    erase(const_iterator first, const_iterator last)
    Removes the elements in the range [first, last). more...
    Arena *
    GetArena() const
    Gets the arena on which this RepeatedPtrField stores its elements.
    void
    InternalSwap(RepeatedPtrField * other)
    For internal use only. more...

    void RepeatedPtrField::RemoveLast()

    Remove the last element in the array.

    Ownership of the element is retained by the array.


    void RepeatedPtrField::DeleteSubrange(
            int start,
            int num)

    Delete elements with indices in the range [start .

    . start+num-1]. Caution: implementation moves all elements with indices [start+num .. ]. Calling this routine inside a loop can cause quadratic behavior.


    void RepeatedPtrField::Reserve(
            int new_size)

    Reserve space to expand the field to at least the given size.

    This only resizes the pointer array; it doesn't allocate any objects. If the array is grown, it will always be at least doubled in size.


    Element ** RepeatedPtrField::mutable_data()

    Gets the underlying array.

    This pointer is possibly invalidated by any add or remove operation.

    diff --git a/content/reference/cpp/api-docs/google.protobuf.service.md b/content/reference/cpp/api-docs/google.protobuf.service.md index e4d9b007..69c6542b 100644 --- a/content/reference/cpp/api-docs/google.protobuf.service.md +++ b/content/reference/cpp/api-docs/google.protobuf.service.md @@ -6,7 +6,7 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/service.h>
    namespace google::protobuf

    DEPRECATED: This module declares the abstract interfaces underlying proto2 RPC services.

    These are intended to be independent of any particular RPC implementation, so that proto2 services can be used on top of a variety of implementations. Starting with version 2.3.0, RPC implementations should not try to build on these, but should instead provide code generator plugins which generate code specific to the particular RPC implementation. This way the generated code can be more appropriate for the implementation in use and can avoid unnecessary layers of indirection.

    +

    #include <google/protobuf/service.h>
    namespace google::protobuf

    DEPRECATED: This module declares the abstract interfaces underlying proto2 RPC services.

    These are intended to be independent of any particular RPC implementation, so that proto2 services can be used on top of a variety of implementations. Starting with version 2.3.0, RPC implementations should not try to build on these, but should instead provide code generator plugins which generate code specific to the particular RPC implementation. This way the generated code can be more appropriate for the implementation in use and can avoid unnecessary layers of indirection.

    When you use the protocol compiler to compile a service definition, it generates two classes: An abstract interface for the service (with methods matching the service definition) and a "stub" implementation. A stub is just a type-safe wrapper around an RpcChannel which emulates a local implementation of the service.

    @@ -52,8 +52,8 @@ stub.Foo(&controller, request, &response, NewCallback(HandleResponse));<

    Different RPC implementations may make different guarantees about what threads they may run callbacks on, and what threads the application is allowed to use to call the RPC system. Portable software should be ready for callbacks to be called on any thread, but should not try to call the RPC system from any thread except for the ones on which it received the callbacks. Realistically, though, simple software will probably want to use a single-threaded RPC system while high-end software will want to use multiple threads. RPC implementations should provide multiple choices.

    -

    Classes in this file

    Abstract base interface for protocol-buffer-based RPC services.
    An RpcController mediates a single method call.
    Abstract interface for an RPC channel.

    class Service

    #include <google/protobuf/service.h>
    namespace google::protobuf

    Abstract base interface for protocol-buffer-based RPC services.

    Services themselves are abstract interfaces (implemented either by servers or as stubs), but they subclass this base interface. The methods of this interface can be used to call the methods of the Service without knowing its exact type at compile time (analogous to Reflection).

    -

    Members

    enum
    ChannelOwnership
    When constructing a stub, you may pass STUB_OWNS_CHANNEL as the second parameter to the constructor to tell it to delete its RpcChannel when destroyed. more...
    Service()
    virtual
    ~Service()
    virtual const ServiceDescriptor *
    GetDescriptor() = 0
    Get the ServiceDescriptor describing this service and its methods.
    virtual void
    CallMethod(const MethodDescriptor * method, RpcController * controller, const Message * request, Message * response, Closure * done) = 0
    Call a method of the service specified by MethodDescriptor. more...
    virtual const Message &
    GetRequestPrototype(const MethodDescriptor * method) const = 0
    CallMethod() requires that the request and response passed in are of a particular subclass of Message. more...
    virtual const Message &
    GetResponsePrototype(const MethodDescriptor * method) const = 0

    enum Service::ChannelOwnership {
      STUB_OWNS_CHANNEL,
      STUB_DOESNT_OWN_CHANNEL
    }

    When constructing a stub, you may pass STUB_OWNS_CHANNEL as the second parameter to the constructor to tell it to delete its RpcChannel when destroyed.

    STUB_OWNS_CHANNEL
    STUB_DOESNT_OWN_CHANNEL

    virtual void Service::CallMethod(
            const MethodDescriptor * method,
            RpcController * controller,
            const Message * request,
            Message * response,
            Closure * done) = 0

    Call a method of the service specified by MethodDescriptor.

    This is normally implemented as a simple switch() that calls the standard definitions of the service's methods.

    +

    Classes in this file

    Abstract base interface for protocol-buffer-based RPC services.
    An RpcController mediates a single method call.
    Abstract interface for an RPC channel.

    class Service

    #include <google/protobuf/service.h>
    namespace google::protobuf

    Abstract base interface for protocol-buffer-based RPC services.

    Services themselves are abstract interfaces (implemented either by servers or as stubs), but they subclass this base interface. The methods of this interface can be used to call the methods of the Service without knowing its exact type at compile time (analogous to Reflection).

    +

    Members

    enum
    ChannelOwnership
    When constructing a stub, you may pass STUB_OWNS_CHANNEL as the second parameter to the constructor to tell it to delete its RpcChannel when destroyed. more...
    Service()
    virtual
    ~Service()
    virtual const ServiceDescriptor *
    GetDescriptor() = 0
    Get the ServiceDescriptor describing this service and its methods.
    virtual void
    CallMethod(const MethodDescriptor * method, RpcController * controller, const Message * request, Message * response, Closure * done) = 0
    Call a method of the service specified by MethodDescriptor. more...
    virtual const Message &
    GetRequestPrototype(const MethodDescriptor * method) const = 0
    CallMethod() requires that the request and response passed in are of a particular subclass of Message. more...
    virtual const Message &
    GetResponsePrototype(const MethodDescriptor * method) const = 0

    enum Service::ChannelOwnership {
      STUB_OWNS_CHANNEL,
      STUB_DOESNT_OWN_CHANNEL
    }

    When constructing a stub, you may pass STUB_OWNS_CHANNEL as the second parameter to the constructor to tell it to delete its RpcChannel when destroyed.

    STUB_OWNS_CHANNEL
    STUB_DOESNT_OWN_CHANNEL

    virtual void Service::CallMethod(
            const MethodDescriptor * method,
            RpcController * controller,
            const Message * request,
            Message * response,
            Closure * done) = 0

    Call a method of the service specified by MethodDescriptor.

    This is normally implemented as a simple switch() that calls the standard definitions of the service's methods.

    Preconditions:

    • method->service() == GetDescriptor()
    • @@ -67,7 +67,7 @@ stub.Foo(&controller, request, &response, NewCallback(HandleResponse));<
    • If the RPC succeeded, "response" contains the response returned by the server.
    • If the RPC failed, "response"'s contents are undefined. The RpcController can be queried to determine if an error occurred and possibly to get more information about the error.
    -

    virtual const Message & Service::GetRequestPrototype(
            const MethodDescriptor * method) const = 0

    CallMethod() requires that the request and response passed in are of a particular subclass of Message.

    GetRequestPrototype() and GetResponsePrototype() get the default instances of these required types. You can then call Message::New() on these instances to construct mutable objects which you can then pass to CallMethod().

    +

    virtual const Message & Service::GetRequestPrototype(
            const MethodDescriptor * method) const = 0

    CallMethod() requires that the request and response passed in are of a particular subclass of Message.

    GetRequestPrototype() and GetResponsePrototype() get the default instances of these required types. You can then call Message::New() on these instances to construct mutable objects which you can then pass to CallMethod().

    Example:

    const MethodDescriptor* method =
       service->GetDescriptor()->FindMethodByName("Foo");
    @@ -75,7 +75,7 @@ Message* request  = stub->GetRequestPrototype (method)->New();
     Message* response = stub->GetResponsePrototype(method)->New();
     request->ParseFromString(input);
     service->CallMethod(method, *request, response, callback);
    -

    class RpcController

    #include <google/protobuf/service.h>
    namespace google::protobuf

    An RpcController mediates a single method call.

    The primary purpose of the controller is to provide a way to manipulate settings specific to the RPC implementation and to find out about RPC-level errors.

    +

    class RpcController

    #include <google/protobuf/service.h>
    namespace google::protobuf

    An RpcController mediates a single method call.

    The primary purpose of the controller is to provide a way to manipulate settings specific to the RPC implementation and to find out about RPC-level errors.

    The methods provided by the RpcController interface are intended to be a "least common denominator" set of features which we expect all implementations to support. Specific implementations may provide more advanced features (e.g. deadline propagation).

    Members

    RpcController()
    virtual
    ~RpcController()

    Client-side methods

    These calls may be made from the client side only. Their results are undefined on the server side (may crash).
    virtual void
    Reset() = 0
    Resets the RpcController to its initial state so that it may be reused in a new call. more...
    virtual bool
    Failed() const = 0
    After a call has finished, returns true if the call failed. more...
    virtual std::string
    ErrorText() const = 0
    If Failed() is true, returns a human-readable description of the error.
    virtual void
    StartCancel() = 0
    Advises the RPC system that the caller desires that the RPC call be canceled. more...

    Server-side methods

    These calls may be made from the server side only.

    @@ -87,9 +87,9 @@ service->CallMethod(method, *request, response, callback);

    virtual bool RpcController::IsCanceled() const = 0

    If 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) = 0

    Asks 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.

    -

    class RpcChannel

    #include <google/protobuf/service.h>
    namespace google::protobuf

    Abstract interface for an RPC channel.

    An RpcChannel represents a communication line to a Service which can be used to call that Service's methods. The Service may be running on another machine. Normally, you should not call an RpcChannel directly, but instead construct a stub Service wrapping it. Example:

    +

    class RpcChannel

    #include <google/protobuf/service.h>
    namespace google::protobuf

    Abstract interface for an RPC channel.

    An RpcChannel represents a communication line to a Service which can be used to call that Service's methods. The Service may be running on another machine. Normally, you should not call an RpcChannel directly, but instead construct a stub Service wrapping it. Example:

    RpcChannel* channel = new MyRpcChannel("remotehost.example.com:1234");
     MyService* service = new MyService::Stub(channel);
     service->MyMethod(request, &response, callback);
    -

    Members

    RpcChannel()
    virtual
    ~RpcChannel()
    virtual void
    CallMethod(const MethodDescriptor * method, RpcController * controller, const Message * request, Message * response, Closure * done) = 0
    Call the given method of the remote service. more...

    virtual void RpcChannel::CallMethod(
            const MethodDescriptor * method,
            RpcController * controller,
            const Message * request,
            Message * response,
            Closure * done) = 0

    Call the given method of the remote service.

    The signature of this procedure looks the same as Service::CallMethod(), but the requirements are less strict in one important way: the request and response objects need not be of any specific class as long as their descriptors are method->input_type() and method->output_type().

    +

    Members

    RpcChannel()
    virtual
    ~RpcChannel()
    virtual void
    CallMethod(const MethodDescriptor * method, RpcController * controller, const Message * request, Message * response, Closure * done) = 0
    Call the given method of the remote service. more...

    virtual void RpcChannel::CallMethod(
            const MethodDescriptor * method,
            RpcController * controller,
            const Message * request,
            Message * response,
            Closure * done) = 0

    Call the given method of the remote service.

    The signature of this procedure looks the same as Service::CallMethod(), but the requirements are less strict in one important way: the request and response objects need not be of any specific class as long as their descriptors are method->input_type() and method->output_type().

    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 f02945f3..3dd5876e 100644 --- a/content/reference/cpp/api-docs/google.protobuf.text_format.md +++ b/content/reference/cpp/api-docs/google.protobuf.text_format.md @@ -6,36 +6,36 @@ description = "This section contains reference documentation for working with Pr 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 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.

    class TextFormat

    #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.

    +

    #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.

    class TextFormat

    #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.

    -

    Members

    static bool
    Print(const Message & message, io::ZeroCopyOutputStream * output)
    Outputs a textual representation of the given message to the given output stream. more...
    static bool
    PrintUnknownFields(const UnknownFieldSet & unknown_fields, io::ZeroCopyOutputStream * output)
    Print the fields in an UnknownFieldSet. more...
    static bool
    PrintToString(const Message & message, std::string * output)
    Like Print(), but outputs directly to a string. more...
    static bool
    PrintUnknownFieldsToString(const UnknownFieldSet & unknown_fields, std::string * output)
    Like PrintUnknownFields(), but outputs directly to a string. more...
    static void
    PrintFieldValueToString(const Message & message, const FieldDescriptor * field, int index, std::string * output)
    Outputs a textual representation of the value of the field supplied on the message supplied. more...
    static bool
    Parse(io::ZeroCopyInputStream * input, Message * output)
    Parses a text-format protocol message from the given input stream to the given message object. more...
    static bool
    ParseFromString(ConstStringParam input, Message * output)
    Like Parse(), but reads directly from a string.
    static bool
    Merge(io::ZeroCopyInputStream * input, Message * output)
    Like Parse(), but the data is merged into the given message, as if using Message::MergeFrom().
    static bool
    MergeFromString(ConstStringParam input, Message * output)
    Like Merge(), but reads directly from a string.
    static bool
    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. more...

    static bool TextFormat::Print(
            const Message & message,
            io::ZeroCopyOutputStream * output)

    Outputs a textual representation of the given message to the given output stream.

    Returns false if printing fails.

    -

    static bool TextFormat::PrintUnknownFields(
            const UnknownFieldSet & unknown_fields,
            io::ZeroCopyOutputStream * output)

    Print the fields in an UnknownFieldSet.

    They are printed by tag number only. Embedded messages are heuristically identified by attempting to parse them. Returns false if printing fails.

    -

    static bool TextFormat::PrintToString(
            const Message & message,
            std::string * output)

    Like Print(), but outputs directly to a string.

    Note: output will be cleared prior to printing, and will be left empty even if printing fails. Returns false if printing fails.

    -

    static bool TextFormat::PrintUnknownFieldsToString(
            const UnknownFieldSet & unknown_fields,
            std::string * output)

    Like PrintUnknownFields(), but outputs directly to a string.

    Returns false if printing fails.

    -

    static void TextFormat::PrintFieldValueToString(
            const Message & message,
            const FieldDescriptor * field,
            int index,
            std::string * output)

    Outputs a textual representation of the value of the field supplied on the message supplied.

    For non-repeated fields, an index of -1 must be supplied. Note that this method will print the default value for a field if it is not set.

    -

    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.

    +

    Members

    static bool
    Print(const Message & message, io::ZeroCopyOutputStream * output)
    Outputs a textual representation of the given message to the given output stream. more...
    static bool
    PrintUnknownFields(const UnknownFieldSet & unknown_fields, io::ZeroCopyOutputStream * output)
    Print the fields in an UnknownFieldSet. more...
    static bool
    PrintToString(const Message & message, std::string * output)
    Like Print(), but outputs directly to a string. more...
    static bool
    PrintUnknownFieldsToString(const UnknownFieldSet & unknown_fields, std::string * output)
    Like PrintUnknownFields(), but outputs directly to a string. more...
    static void
    PrintFieldValueToString(const Message & message, const FieldDescriptor * field, int index, std::string * output)
    Outputs a textual representation of the value of the field supplied on the message supplied. more...
    static bool
    Parse(io::ZeroCopyInputStream * input, Message * output)
    Parses a text-format protocol message from the given input stream to the given message object. more...
    static bool
    ParseFromString(ConstStringParam input, Message * output)
    Like Parse(), but reads directly from a string.
    static bool
    Merge(io::ZeroCopyInputStream * input, Message * output)
    Like Parse(), but the data is merged into the given message, as if using Message::MergeFrom().
    static bool
    MergeFromString(ConstStringParam input, Message * output)
    Like Merge(), but reads directly from a string.
    static bool
    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. more...

    static bool TextFormat::Print(
            const Message & message,
            io::ZeroCopyOutputStream * output)

    Outputs a textual representation of the given message to the given output stream.

    Returns false if printing fails.

    +

    static bool TextFormat::PrintUnknownFields(
            const UnknownFieldSet & unknown_fields,
            io::ZeroCopyOutputStream * output)

    Print the fields in an UnknownFieldSet.

    They are printed by tag number only. Embedded messages are heuristically identified by attempting to parse them. Returns false if printing fails.

    +

    static bool TextFormat::PrintToString(
            const Message & message,
            std::string * output)

    Like Print(), but outputs directly to a string.

    Note: output will be cleared prior to printing, and will be left empty even if printing fails. Returns false if printing fails.

    +

    static bool TextFormat::PrintUnknownFieldsToString(
            const UnknownFieldSet & unknown_fields,
            std::string * output)

    Like PrintUnknownFields(), but outputs directly to a string.

    Returns false if printing fails.

    +

    static void TextFormat::PrintFieldValueToString(
            const Message & message,
            const FieldDescriptor * field,
            int index,
            std::string * output)

    Outputs a textual representation of the value of the field supplied on the message supplied.

    For non-repeated fields, an index of -1 must be supplied. Note that this method will print the default value for a field if it is not set.

    +

    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 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

    -

    class TextFormat::BaseTextGenerator

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    Members

    virtual
    ~BaseTextGenerator()
    virtual void
    Indent()
    virtual void
    Outdent()
    virtual size_t
    GetCurrentIndentationSize() const
    Returns the current indentation size in characters.
    virtual void
    Print(const char * text, size_t size) = 0
    Print text to the output stream.
    void
    PrintString(const std::string & str)
    template void
    PrintLiteral(const char(&) text)

    class TextFormat::FastFieldValuePrinter

    #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) const
    Allows 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) const

    Allows 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).

    -

    class TextFormat::FieldValuePrinter

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    Deprecated: please use FastFieldValuePrinter instead.

    Members

    FieldValuePrinter()
    virtual
    ~FieldValuePrinter()
    virtual std::string
    PrintBool(bool val) const
    virtual std::string
    PrintInt32(int32 val) const
    virtual std::string
    PrintUInt32(uint32 val) const
    virtual std::string
    PrintInt64(int64 val) const
    virtual std::string
    PrintUInt64(uint64 val) const
    virtual std::string
    PrintFloat(float val) const
    virtual std::string
    PrintDouble(double val) const
    virtual std::string
    PrintString(const std::string & val) const
    virtual std::string
    PrintBytes(const std::string & val) const
    virtual std::string
    PrintEnum(int32 val, const std::string & name) const
    virtual std::string
    PrintFieldName(const Message & message, const Reflection * reflection, const FieldDescriptor * field) const
    virtual std::string
    PrintMessageStart(const Message & message, int field_index, int field_count, bool single_line_mode) const
    virtual std::string
    PrintMessageEnd(const Message & message, int field_index, int field_count, bool single_line_mode) const

    class TextFormat::Finder

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    Interface that Printers or Parsers can use to find extensions, or types referenced in Any messages.

    Members

    virtual
    ~Finder()
    virtual const FieldDescriptor *
    FindExtension(Message * message, const std::string & name) const
    Try to find an extension of *message by fully-qualified field name. more...
    virtual const FieldDescriptor *
    FindExtensionByNumber(const Descriptor * descriptor, int number) const
    Similar to FindExtension, but uses a Descriptor and the extension number instead of using a Message and the name when doing the look up.
    virtual const Descriptor *
    FindAnyType(const Message & message, const std::string & prefix, const std::string & name) const
    Find the message type for an Any proto. more...
    virtual MessageFactory *
    FindExtensionFactory(const FieldDescriptor * field) const
    Find the message factory for the given extension field. more...

    virtual const FieldDescriptor *
        Finder::FindExtension(
            Message * message,
            const std::string & name) const

    Try to find an extension of *message by fully-qualified field name.

    Returns NULL if no extension is known for this name or number. The base implementation uses the extensions already known by the message.

    -

    virtual const Descriptor *
        Finder::FindAnyType(
            const Message & message,
            const std::string & prefix,
            const std::string & name) const

    Find the message type for an Any proto.

    Returns NULL if no message is known for this name. The base implementation only accepts prefixes of type.googleprod.com/ or type.googleapis.com/, and searches the DescriptorPool of the parent message.

    -

    virtual MessageFactory * Finder::FindExtensionFactory(
            const FieldDescriptor * field) const

    Find the message factory for the given extension field.

    This can be used to generalize the Parser to add extension fields to a message in the same way as the "input" message for the Parser.

    -

    class TextFormat::MessagePrinter

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    Members

    MessagePrinter()
    virtual
    ~MessagePrinter()
    virtual void
    Print(const Message & message, bool single_line_mode, BaseTextGenerator * generator) const = 0

    class TextFormat::ParseInfoTree

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    Data structure which is populated with the locations of each field value parsed from the text.

    Members

    ParseInfoTree()
    ParseInfoTree(const ParseInfoTree & )
    ParseInfoTree &
    operator=(const ParseInfoTree & )
    ParseLocation
    GetLocation(const FieldDescriptor * field, int index) const
    Returns the parse location for index-th value of the field in the parsed text. more...
    ParseInfoTree *
    GetTreeForNested(const FieldDescriptor * field, int index) const
    Returns the parse info tree for the given field, which must be a message type. more...

    ParseLocation ParseInfoTree::GetLocation(
            const FieldDescriptor * field,
            int index) const

    Returns the parse location for index-th value of the field in the parsed text.

    If none exists, returns a location with line = -1. Index should be -1 for not-repeated fields.

    -

    ParseInfoTree * ParseInfoTree::GetTreeForNested(
            const FieldDescriptor * field,
            int index) const

    Returns the parse info tree for the given field, which must be a message type.

    The nested information tree is owned by the root tree and will be deleted when it is deleted.

    -

    struct TextFormat::ParseLocation

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    A location in the parsed text.

    Members

    int
    line
    int
    column
    ParseLocation()
    ParseLocation(int line_param, int column_param)

    class TextFormat::Parser

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    For more control over parsing, use this class.

    Members

    Parser()
    ~Parser()
    bool
    Parse(io::ZeroCopyInputStream * input, Message * output)
    bool
    ParseFromString(ConstStringParam input, Message * output)
    bool
    Merge(io::ZeroCopyInputStream * input, Message * output)
    bool
    MergeFromString(ConstStringParam input, Message * output)
    void
    RecordErrorsTo(io::ErrorCollector * error_collector)
    Set where to report parse errors. more...
    void
    SetFinder(const Finder * finder)
    Set how parser finds extensions. more...
    void
    WriteLocationsTo(ParseInfoTree * tree)
    Sets where location information about the parse will be written. more...
    void
    AllowPartialMessage(bool allow)
    Normally parsing fails if, after parsing, output->IsInitialized() returns false. more...
    void
    AllowCaseInsensitiveField(bool allow)
    Allow field names to be matched case-insensitively. more...
    bool
    ParseFieldValueFromString(const std::string & input, const FieldDescriptor * field, Message * output)
    void
    AllowUnknownExtension(bool allow)
    When an unknown extension is met, parsing will fail if this option is set to false (the default). more...
    void
    AllowUnknownField(bool allow)
    When an unknown field is met, parsing will fail if this option is set to false (the default). more...
    void
    AllowFieldNumber(bool allow)
    void
    SetRecursionLimit(int limit)
    Sets maximum recursion depth which parser can use. more...

    void Parser::RecordErrorsTo(
            io::ErrorCollector * error_collector)

    Set where to report parse errors.

    If NULL (the default), errors will be printed to stderr.

    -

    void Parser::SetFinder(
            const Finder * finder)

    Set how parser finds extensions.

    If NULL (the default), the parser will use the standard Reflection object associated with the message being parsed.

    +

    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 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

    +

    class TextFormat::BaseTextGenerator

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    Members

    virtual
    ~BaseTextGenerator()
    virtual void
    Indent()
    virtual void
    Outdent()
    virtual size_t
    GetCurrentIndentationSize() const
    Returns the current indentation size in characters.
    virtual void
    Print(const char * text, size_t size) = 0
    Print text to the output stream.
    void
    PrintString(const std::string & str)
    template void
    PrintLiteral(const char(&) text)

    class TextFormat::FastFieldValuePrinter

    #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) const
    Allows 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) const

    Allows 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).

    +

    class TextFormat::FieldValuePrinter

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    Deprecated: please use FastFieldValuePrinter instead.

    Members

    FieldValuePrinter()
    virtual
    ~FieldValuePrinter()
    virtual std::string
    PrintBool(bool val) const
    virtual std::string
    PrintInt32(int32 val) const
    virtual std::string
    PrintUInt32(uint32 val) const
    virtual std::string
    PrintInt64(int64 val) const
    virtual std::string
    PrintUInt64(uint64 val) const
    virtual std::string
    PrintFloat(float val) const
    virtual std::string
    PrintDouble(double val) const
    virtual std::string
    PrintString(const std::string & val) const
    virtual std::string
    PrintBytes(const std::string & val) const
    virtual std::string
    PrintEnum(int32 val, const std::string & name) const
    virtual std::string
    PrintFieldName(const Message & message, const Reflection * reflection, const FieldDescriptor * field) const
    virtual std::string
    PrintMessageStart(const Message & message, int field_index, int field_count, bool single_line_mode) const
    virtual std::string
    PrintMessageEnd(const Message & message, int field_index, int field_count, bool single_line_mode) const

    class TextFormat::Finder

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    Interface that Printers or Parsers can use to find extensions, or types referenced in Any messages.

    Members

    virtual
    ~Finder()
    virtual const FieldDescriptor *
    FindExtension(Message * message, const std::string & name) const
    Try to find an extension of *message by fully-qualified field name. more...
    virtual const FieldDescriptor *
    FindExtensionByNumber(const Descriptor * descriptor, int number) const
    Similar to FindExtension, but uses a Descriptor and the extension number instead of using a Message and the name when doing the look up.
    virtual const Descriptor *
    FindAnyType(const Message & message, const std::string & prefix, const std::string & name) const
    Find the message type for an Any proto. more...
    virtual MessageFactory *
    FindExtensionFactory(const FieldDescriptor * field) const
    Find the message factory for the given extension field. more...

    virtual const FieldDescriptor *
        Finder::FindExtension(
            Message * message,
            const std::string & name) const

    Try to find an extension of *message by fully-qualified field name.

    Returns NULL if no extension is known for this name or number. The base implementation uses the extensions already known by the message.

    +

    virtual const Descriptor *
        Finder::FindAnyType(
            const Message & message,
            const std::string & prefix,
            const std::string & name) const

    Find the message type for an Any proto.

    Returns NULL if no message is known for this name. The base implementation only accepts prefixes of type.googleprod.com/ or type.googleapis.com/, and searches the DescriptorPool of the parent message.

    +

    virtual MessageFactory * Finder::FindExtensionFactory(
            const FieldDescriptor * field) const

    Find the message factory for the given extension field.

    This can be used to generalize the Parser to add extension fields to a message in the same way as the "input" message for the Parser.

    +

    class TextFormat::MessagePrinter

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    Members

    MessagePrinter()
    virtual
    ~MessagePrinter()
    virtual void
    Print(const Message & message, bool single_line_mode, BaseTextGenerator * generator) const = 0

    class TextFormat::ParseInfoTree

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    Data structure which is populated with the locations of each field value parsed from the text.

    Members

    ParseInfoTree()
    ParseInfoTree(const ParseInfoTree & )
    ParseInfoTree &
    operator=(const ParseInfoTree & )
    ParseLocation
    GetLocation(const FieldDescriptor * field, int index) const
    Returns the parse location for index-th value of the field in the parsed text. more...
    ParseInfoTree *
    GetTreeForNested(const FieldDescriptor * field, int index) const
    Returns the parse info tree for the given field, which must be a message type. more...

    ParseLocation ParseInfoTree::GetLocation(
            const FieldDescriptor * field,
            int index) const

    Returns the parse location for index-th value of the field in the parsed text.

    If none exists, returns a location with line = -1. Index should be -1 for not-repeated fields.

    +

    ParseInfoTree * ParseInfoTree::GetTreeForNested(
            const FieldDescriptor * field,
            int index) const

    Returns the parse info tree for the given field, which must be a message type.

    The nested information tree is owned by the root tree and will be deleted when it is deleted.

    +

    struct TextFormat::ParseLocation

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    A location in the parsed text.

    Members

    int
    line
    int
    column
    ParseLocation()
    ParseLocation(int line_param, int column_param)

    class TextFormat::Parser

    #include <google/protobuf/text_format.h>
    namespace google::protobuf

    For more control over parsing, use this class.

    Members

    Parser()
    ~Parser()
    bool
    Parse(io::ZeroCopyInputStream * input, Message * output)
    bool
    ParseFromString(ConstStringParam input, Message * output)
    bool
    Merge(io::ZeroCopyInputStream * input, Message * output)
    bool
    MergeFromString(ConstStringParam input, Message * output)
    void
    RecordErrorsTo(io::ErrorCollector * error_collector)
    Set where to report parse errors. more...
    void
    SetFinder(const Finder * finder)
    Set how parser finds extensions. more...
    void
    WriteLocationsTo(ParseInfoTree * tree)
    Sets where location information about the parse will be written. more...
    void
    AllowPartialMessage(bool allow)
    Normally parsing fails if, after parsing, output->IsInitialized() returns false. more...
    void
    AllowCaseInsensitiveField(bool allow)
    Allow field names to be matched case-insensitively. more...
    bool
    ParseFieldValueFromString(const std::string & input, const FieldDescriptor * field, Message * output)
    void
    AllowUnknownExtension(bool allow)
    When an unknown extension is met, parsing will fail if this option is set to false (the default). more...
    void
    AllowUnknownField(bool allow)
    When an unknown field is met, parsing will fail if this option is set to false (the default). more...
    void
    AllowFieldNumber(bool allow)
    void
    SetRecursionLimit(int limit)
    Sets maximum recursion depth which parser can use. more...

    void Parser::RecordErrorsTo(
            io::ErrorCollector * error_collector)

    Set where to report parse errors.

    If NULL (the default), errors will be printed to stderr.

    +

    void Parser::SetFinder(
            const Finder * finder)

    Set how parser finds extensions.

    If NULL (the default), the parser will use the standard Reflection object associated with the message being parsed.


    void Parser::WriteLocationsTo(
            ParseInfoTree * tree)

    Sets where location information about the parse will be written.

    If NULL (the default), then no location will be written.


    void Parser::AllowPartialMessage(
            bool allow)

    Normally parsing fails if, after parsing, output->IsInitialized() returns false.

    Call AllowPartialMessage(true) to skip this check.


    void Parser::AllowCaseInsensitiveField(
            bool allow)

    Allow field names to be matched case-insensitively.

    This is not advisable if there are fields that only differ in case, or if you want to enforce writing in the canonical form. This is 'false' by default.


    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.

    -

    class TextFormat::Printer

    #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) const
    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.

    +

    class TextFormat::Printer

    #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) const
    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.

    @@ -48,6 +48,6 @@ type = "docs"
    type_url: "<type_url>"  value: "serialized_content"

    void Printer::SetTruncateStringFieldLongerThan(
            const int64 truncate_string_field_longer_than)

    If non-zero, we truncate all string fields that are longer than this threshold.

    This is useful when the proto message has very long strings, e.g., dump of encoded image file.

    NOTE(hfgong): Setting a non-zero value breaks round-trip safe property of TextFormat::Printer. That is, from the printed message, we cannot fully recover the original string field any more.

    -

    bool Printer::RegisterFieldValuePrinter(
            const FieldDescriptor * field,
            const FastFieldValuePrinter * printer)

    Register a custom field-specific FastFieldValuePrinter for fields with a particular FieldDescriptor.

    Returns "true" if the registration succeeded, or "false", if there is already a printer for that FieldDescriptor. Takes ownership of the printer on successful registration.

    -

    bool Printer::RegisterMessagePrinter(
            const Descriptor * descriptor,
            const MessagePrinter * printer)

    Register a custom message-specific MessagePrinter for messages with a particular Descriptor.

    Returns "true" if the registration succeeded, or "false" if there is already a printer for that Descriptor.

    +

    bool Printer::RegisterFieldValuePrinter(
            const FieldDescriptor * field,
            const FastFieldValuePrinter * printer)

    Register a custom field-specific FastFieldValuePrinter for fields with a particular FieldDescriptor.

    Returns "true" if the registration succeeded, or "false", if there is already a printer for that FieldDescriptor. Takes ownership of the printer on successful registration.

    +

    bool Printer::RegisterMessagePrinter(
            const Descriptor * descriptor,
            const MessagePrinter * printer)

    Register a custom message-specific MessagePrinter for messages with a particular Descriptor.

    Returns "true" if the registration succeeded, or "false" if there is already a printer for that Descriptor.

    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 7ebb4623..e2778fff 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 @@ -8,19 +8,19 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/unknown_field_set.h>
    namespace google::protobuf

    Contains classes used to keep track of unrecognized fields seen while parsing a protocol message.

    Classes in this file

    An UnknownFieldSet contains fields that were encountered while parsing a message but were not defined by its type.
    Represents one field in an UnknownFieldSet.

    class UnknownFieldSet

    #include <google/protobuf/unknown_field_set.h>
    namespace google::protobuf

    An UnknownFieldSet contains fields that were encountered while parsing a message but were not defined by its type.

    Keeping track of these can be useful, especially in that they may be written if the message is serialized again without being cleared in between. This means that software which simply receives messages and forwards them to other servers does not need to be updated every time a new field is added to the message definition.

    +

    #include <google/protobuf/unknown_field_set.h>
    namespace google::protobuf

    Contains classes used to keep track of unrecognized fields seen while parsing a protocol message.

    Classes in this file

    An UnknownFieldSet contains fields that were encountered while parsing a message but were not defined by its type.
    Represents one field in an UnknownFieldSet.

    class UnknownFieldSet

    #include <google/protobuf/unknown_field_set.h>
    namespace google::protobuf

    An UnknownFieldSet contains fields that were encountered while parsing a message but were not defined by its type.

    Keeping track of these can be useful, especially in that they may be written if the message is serialized again without being cleared in between. This means that software which simply receives messages and forwards them to other servers does not need to be updated every time a new field is added to the message definition.

    -

    To get the UnknownFieldSet attached to any message, call Reflection::GetUnknownFields().

    +

    To get the UnknownFieldSet attached to any message, call Reflection::GetUnknownFields().

    -

    This class is necessarily tied to the Protobuf 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() const
    Is 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() const
    Computes (an estimate of) the total number of bytes currently used for storing the unknown fields in memory. more...
    int
    SpaceUsedExcludingSelf() const
    size_t
    SpaceUsedLong() const
    Version of SpaceUsed() including sizeof(*this).
    int
    SpaceUsed() const
    int
    field_count() const
    Returns the number of fields present in the UnknownFieldSet.
    const UnknownField &
    field(int index) const
    Get 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 helpers

    These 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() const

    Computes (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.

    +

    Members

    UnknownFieldSet()
    ~UnknownFieldSet()
    void
    Clear()
    Remove all fields.
    void
    ClearAndFreeMemory()
    Remove all fields and deallocate internal data objects.
    bool
    empty() const
    Is 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() const
    Computes (an estimate of) the total number of bytes currently used for storing the unknown fields in memory. more...
    int
    SpaceUsedExcludingSelf() const
    size_t
    SpaceUsedLong() const
    Version of SpaceUsed() including sizeof(*this).
    int
    SpaceUsed() const
    int
    field_count() const
    Returns the number of fields present in the UnknownFieldSet.
    const UnknownField &
    field(int index) const
    Get 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 helpers

    These 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() const

    Computes (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) const

    Get a field in the set, where 0 <= index < field_count().

    The fields appear in the order in which they were added.


    UnknownField * UnknownFieldSet::mutable_field(
            int index)

    Get a mutable pointer to a field in the set, where 0 <= index < field_count().

    The fields appear in the order in which they were added.


    static void UnknownFieldSet::MergeToInternalMetadata(
            const UnknownFieldSet & other,
            internal::InternalMetadata * metadata)

    Merge the contents an UnknownFieldSet with the UnknownFieldSet in *metadata, if there is one.

    If *metadata doesn't have an UnknownFieldSet then add one to it and make it be a copy of the first arg.


    void UnknownFieldSet::DeleteSubrange(
            int start,
            int num)

    Delete fields with indices in the range [start .

    . start+num-1]. Caution: implementation moves all fields with indices [start+num .. ].


    void UnknownFieldSet::DeleteByNumber(
            int number)

    Delete all fields with a specific field number.

    The order of left fields is preserved. Caution: implementation moves all fields after the first deleted field.


    template bool UnknownFieldSet::MergeFromMessage(
            const MessageType & message)

    Merges this message's unknown field data (if any).

    This works whether the message is a lite or full proto (for legacy reasons, lite and full return different types for MessageType::unknown_fields()).

    -

    class UnknownField

    #include <google/protobuf/unknown_field_set.h>
    namespace google::protobuf

    Represents one field in an UnknownFieldSet.

    Members

    enum
    Type
    uint64
    varint_
    uint32
    fixed32_
    uint64
    fixed64_
    union LengthDelimited
    length_delimited_
    UnknownFieldSet *
    group_
    int
    number() const
    The field's field number, as seen on the wire.
    Type
    type() const
    The field type.

    Accessors

    Each method works only for UnknownFields of the corresponding type.
    uint32
    number_
    uint32
    type_
    union google::protobuf::UnknownField::@35
    data_
    uint64
    varint() const
    uint32
    fixed32() const
    uint64
    fixed64() const
    const std::string &
    length_delimited() const
    const UnknownFieldSet &
    group() const
    void
    set_varint(uint64 value)
    void
    set_fixed32(uint32 value)
    void
    set_fixed64(uint64 value)
    void
    set_length_delimited(const std::string & value)
    std::string *
    mutable_length_delimited()
    UnknownFieldSet *
    mutable_group()
    void
    SerializeLengthDelimitedNoTag(io::CodedOutputStream * output) const
    Serialization API. more...
    size_t
    GetLengthDelimitedSize() const
    uint8 *
    InternalSerializeLengthDelimitedNoTag(uint8 * target, io::EpsCopyOutputStream * stream) const
    void
    Delete()
    If this UnknownField contains a pointer, delete it.
    void
    DeepCopy(const UnknownField & other)
    Make a deep copy of any pointers in this UnknownField.
    void
    SetType(Type type)
    Set the wire type of this UnknownField. more...

    enum UnknownField::Type {
      TYPE_VARINT,
      TYPE_FIXED32,
      TYPE_FIXED64,
      TYPE_LENGTH_DELIMITED,
      TYPE_GROUP
    }

    TYPE_VARINT
    TYPE_FIXED32
    TYPE_FIXED64
    TYPE_LENGTH_DELIMITED
    TYPE_GROUP

    void UnknownField::SerializeLengthDelimitedNoTag(
            io::CodedOutputStream * output) const

    Serialization API.

    These methods can take advantage of the underlying implementation and may achieve a better performance than using getters to retrieve the data and do the serialization yourself.

    +

    class UnknownField

    #include <google/protobuf/unknown_field_set.h>
    namespace google::protobuf

    Represents one field in an UnknownFieldSet.

    Members

    enum
    Type
    uint64
    varint_
    uint32
    fixed32_
    uint64
    fixed64_
    union LengthDelimited
    length_delimited_
    UnknownFieldSet *
    group_
    int
    number() const
    The field's field number, as seen on the wire.
    Type
    type() const
    The field type.

    Accessors

    Each method works only for UnknownFields of the corresponding type.
    uint32
    number_
    uint32
    type_
    union google::protobuf::UnknownField::@35
    data_
    uint64
    varint() const
    uint32
    fixed32() const
    uint64
    fixed64() const
    const std::string &
    length_delimited() const
    const UnknownFieldSet &
    group() const
    void
    set_varint(uint64 value)
    void
    set_fixed32(uint32 value)
    void
    set_fixed64(uint64 value)
    void
    set_length_delimited(const std::string & value)
    std::string *
    mutable_length_delimited()
    UnknownFieldSet *
    mutable_group()
    void
    SerializeLengthDelimitedNoTag(io::CodedOutputStream * output) const
    Serialization API. more...
    size_t
    GetLengthDelimitedSize() const
    uint8 *
    InternalSerializeLengthDelimitedNoTag(uint8 * target, io::EpsCopyOutputStream * stream) const
    void
    Delete()
    If this UnknownField contains a pointer, delete it.
    void
    DeepCopy(const UnknownField & other)
    Make a deep copy of any pointers in this UnknownField.
    void
    SetType(Type type)
    Set the wire type of this UnknownField. more...

    enum UnknownField::Type {
      TYPE_VARINT,
      TYPE_FIXED32,
      TYPE_FIXED64,
      TYPE_LENGTH_DELIMITED,
      TYPE_GROUP
    }

    TYPE_VARINT
    TYPE_FIXED32
    TYPE_FIXED64
    TYPE_LENGTH_DELIMITED
    TYPE_GROUP

    void UnknownField::SerializeLengthDelimitedNoTag(
            io::CodedOutputStream * output) const

    Serialization API.

    These methods can take advantage of the underlying implementation and may achieve a better performance than using getters to retrieve the data and do the serialization yourself.


    void UnknownField::SetType(
            Type type)

    Set the wire type of this UnknownField.

    Should only be used when this UnknownField is being created.

    -

    union UnknownField::LengthDelimited

    #include <google/protobuf/unknown_field_set.h>
    namespace google::protobuf

    Members

    std::string *
    string_value
    +

    union UnknownField::LengthDelimited

    #include <google/protobuf/unknown_field_set.h>
    namespace google::protobuf

    Members

    std::string *
    string_value
    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 2e031bbe..c64b3d63 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 @@ -8,20 +8,20 @@ description = "This section contains reference documentation for working with Pr 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 Protobuf fields.
    Basic implementation of FieldComparator.

    class 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.

    +

    #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.

    class 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) = 0
    Compares the values of a field in two Protobuf 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:

    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) = 0
    Compares the values of a field in two Protobuf 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.

    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) = 0

    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.

    +

    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) = 0

    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.

    -

    class SimpleFieldComparator: public FieldComparator

    #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.

    +

    FieldContext contains information about the specific instances of the fields being compared, versus FieldDescriptor which only contains general type information about the fields.

    +

    class SimpleFieldComparator: public FieldComparator

    #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.

    -

    Known subclasses:

    Members

    enum
    FloatComparison
    SimpleFieldComparator()
    Creates new comparator with float comparison set to EXACT.
    ~SimpleFieldComparator()
    void
    set_float_comparison(FloatComparison float_comparison)
    FloatComparison
    float_comparison() const
    void
    set_treat_nan_as_equal(bool treat_nan_as_equal)
    Set whether the FieldComparator shall treat floats or doubles that are both NaN as equal (treat_nan_as_equal = true) or as different (treat_nan_as_equal = false). more...
    bool
    treat_nan_as_equal() const
    void
    SetFractionAndMargin(const FieldDescriptor * field, double fraction, double margin)
    Sets the fraction and margin for the float comparison of a given field. more...
    void
    SetDefaultFractionAndMargin(double fraction, double margin)
    Sets the fraction and margin for the float comparison of all float and double fields, unless a field has been given a specific setting via SetFractionAndMargin() above. more...
    protected ComparisonResult
    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. more...
    protected bool
    CompareWithDifferencer(MessageDifferencer * differencer, const Message & message1, const Message & message2, const util::FieldContext * field_context)
    Compare using the provided message_differencer. more...
    protected ComparisonResult
    ResultFromBoolean(bool boolean_result) const
    Returns FieldComparator::SAME if boolean_result is true and FieldComparator::DIFFERENT otherwise.

    enum SimpleFieldComparator::FloatComparison {
      EXACT,
      APPROXIMATE
    }

    EXACTFloats and doubles are compared exactly.
    APPROXIMATEFloats and doubles are compared using the MathUtil::AlmostEqual method or MathUtil::WithinFractionOrMargin method.

    void SimpleFieldComparator::set_treat_nan_as_equal(
            bool treat_nan_as_equal)

    Set whether the FieldComparator shall treat floats or doubles that are both NaN as equal (treat_nan_as_equal = true) or as different (treat_nan_as_equal = false).

    Default is treating NaNs always as different.

    -

    void SimpleFieldComparator::SetFractionAndMargin(
            const FieldDescriptor * field,
            double fraction,
            double margin)

    Sets the fraction and margin for the float comparison of a given field.

    Uses MathUtil::WithinFractionOrMargin to compare the values.

    +

    Known subclasses:

    Members

    enum
    FloatComparison
    SimpleFieldComparator()
    Creates new comparator with float comparison set to EXACT.
    ~SimpleFieldComparator()
    void
    set_float_comparison(FloatComparison float_comparison)
    FloatComparison
    float_comparison() const
    void
    set_treat_nan_as_equal(bool treat_nan_as_equal)
    Set whether the FieldComparator shall treat floats or doubles that are both NaN as equal (treat_nan_as_equal = true) or as different (treat_nan_as_equal = false). more...
    bool
    treat_nan_as_equal() const
    void
    SetFractionAndMargin(const FieldDescriptor * field, double fraction, double margin)
    Sets the fraction and margin for the float comparison of a given field. more...
    void
    SetDefaultFractionAndMargin(double fraction, double margin)
    Sets the fraction and margin for the float comparison of all float and double fields, unless a field has been given a specific setting via SetFractionAndMargin() above. more...
    protected ComparisonResult
    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. more...
    protected bool
    CompareWithDifferencer(MessageDifferencer * differencer, const Message & message1, const Message & message2, const util::FieldContext * field_context)
    Compare using the provided message_differencer. more...
    protected ComparisonResult
    ResultFromBoolean(bool boolean_result) const
    Returns FieldComparator::SAME if boolean_result is true and FieldComparator::DIFFERENT otherwise.

    enum SimpleFieldComparator::FloatComparison {
      EXACT,
      APPROXIMATE
    }

    EXACTFloats and doubles are compared exactly.
    APPROXIMATEFloats and doubles are compared using the MathUtil::AlmostEqual method or MathUtil::WithinFractionOrMargin method.

    void SimpleFieldComparator::set_treat_nan_as_equal(
            bool treat_nan_as_equal)

    Set whether the FieldComparator shall treat floats or doubles that are both NaN as equal (treat_nan_as_equal = true) or as different (treat_nan_as_equal = false).

    Default is treating NaNs always as different.

    +

    void SimpleFieldComparator::SetFractionAndMargin(
            const FieldDescriptor * field,
            double fraction,
            double margin)

    Sets the fraction and margin for the float comparison of a given field.

    Uses MathUtil::WithinFractionOrMargin to compare the values.

    -

    REQUIRES: field->cpp_type == FieldDescriptor::CPPTYPE_DOUBLE or

    +

    REQUIRES: field->cpp_type == FieldDescriptor::CPPTYPE_DOUBLE or

    field->cpp_type == FieldDescriptor::CPPTYPE_FLOAT
    @@ -29,10 +29,10 @@ type = "docs"

    void SimpleFieldComparator::SetDefaultFractionAndMargin(
            double fraction,
            double margin)

    Sets the fraction and margin for the float comparison of all float and double fields, unless a field has been given a specific setting via SetFractionAndMargin() above.

    Uses MathUtil::WithinFractionOrMargin to compare the values.

    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.

    -

    class DefaultFieldComparator: public SimpleFieldComparator

    #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.

    +

    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.

    +

    class DefaultFieldComparator: public SimpleFieldComparator

    #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.

    +

    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 86438565..aa24b210 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 @@ -6,11 +6,11 @@ description = "This section contains reference documentation for working with Pr 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

    class FieldMaskUtil

    #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.

    +

    #include <google/protobuf/util/field_mask_util.h>
    namespace google::protobuf::util

    Defines utilities for the FieldMask well known type.

    Classes in this file

    class FieldMaskUtil

    #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,11 +18,11 @@ 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.

    -

    class FieldMaskUtil::MergeOptions

    #include <google/protobuf/util/field_mask_util.h>
    namespace google::protobuf::util

    Members

    MergeOptions()
    void
    set_replace_message_fields(bool value)
    When merging message fields, the default behavior is to merge the content of two message fields together. more...
    bool
    replace_message_fields() const
    void
    set_replace_repeated_fields(bool value)
    The default merging behavior will append entries from the source repeated field to the destination repeated field. more...
    bool
    replace_repeated_fields() const

    void MergeOptions::set_replace_message_fields(
            bool value)

    When merging message fields, the default behavior is to merge the content of two message fields together.

    If you instead want to use the field from the source message to replace the corresponding field in the destination message, set this flag to true. When this flag is set, specified submessage fields that are missing in source will be cleared in destination.

    +

    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.

    +

    class FieldMaskUtil::MergeOptions

    #include <google/protobuf/util/field_mask_util.h>
    namespace google::protobuf::util

    Members

    MergeOptions()
    void
    set_replace_message_fields(bool value)
    When merging message fields, the default behavior is to merge the content of two message fields together. more...
    bool
    replace_message_fields() const
    void
    set_replace_repeated_fields(bool value)
    The default merging behavior will append entries from the source repeated field to the destination repeated field. more...
    bool
    replace_repeated_fields() const

    void MergeOptions::set_replace_message_fields(
            bool value)

    When merging message fields, the default behavior is to merge the content of two message fields together.

    If you instead want to use the field from the source message to replace the corresponding field in the destination message, set this flag to true. When this flag is set, specified submessage fields that are missing in source will be cleared in destination.


    void MergeOptions::set_replace_repeated_fields(
            bool value)

    The default merging behavior will append entries from the source repeated field to the destination repeated field.

    If you only want to keep the entries from the source repeated field, set this flag to true.

    -

    class FieldMaskUtil::TrimOptions

    #include <google/protobuf/util/field_mask_util.h>
    namespace google::protobuf::util

    Members

    TrimOptions()
    void
    set_keep_required_fields(bool value)
    When trimming message fields, the default behavior is to trim required fields of the present message if they are not specified in the field mask. more...
    bool
    keep_required_fields() const

    void TrimOptions::set_keep_required_fields(
            bool value)

    When trimming message fields, the default behavior is to trim required fields of the present message if they are not specified in the field mask.

    If you instead want to keep required fields of the present message even they are not specified in the field mask, set this flag to true.

    +

    class FieldMaskUtil::TrimOptions

    #include <google/protobuf/util/field_mask_util.h>
    namespace google::protobuf::util

    Members

    TrimOptions()
    void
    set_keep_required_fields(bool value)
    When trimming message fields, the default behavior is to trim required fields of the present message if they are not specified in the field mask. more...
    bool
    keep_required_fields() const

    void TrimOptions::set_keep_required_fields(
            bool value)

    When trimming message fields, the default behavior is to trim required fields of the present message if they are not specified in the field mask.

    If you instead want to keep required fields of the present message even they are not specified in the field mask, set this flag to true.

    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 6e263658..5d76dbd9 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 @@ -6,22 +6,22 @@ description = "This section contains reference documentation for working with Pr 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 Members

    These definitions are not part of any class.
    typedef
    JsonPrintOptions JsonOptions
    DEPRECATED. 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 Members

    These definitions are not part of any class.
    typedef
    JsonPrintOptions JsonOptions
    DEPRECATED. 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
        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
        information returned by TypeResolver.
    -

    struct JsonParseOptions

    #include <google/protobuf/util/json_util.h>
    namespace google::protobuf::util

    Members

    bool
    ignore_unknown_fields
    Whether to ignore unknown JSON fields during parsing.
    bool
    case_insensitive_enum_parsing
    If true, when a lowercase enum value fails to parse, try convert it to UPPER_CASE and see if it matches a valid enum. more...
    JsonParseOptions()

    bool JsonParseOptions::case_insensitive_enum_parsing

    If true, when a lowercase enum value fails to parse, try convert it to UPPER_CASE and see if it matches a valid enum.

    WARNING: This option exists only to preserve legacy behavior. Avoid using this option. If your enum needs to support different casing, consider using allow_alias instead.

    -

    struct JsonPrintOptions

    #include <google/protobuf/util/json_util.h>
    namespace google::protobuf::util

    Members

    bool
    add_whitespace
    Whether to add spaces, line breaks and indentation to make the JSON output easy to read.
    bool
    always_print_primitive_fields
    Whether to always print primitive fields. more...
    bool
    always_print_enums_as_ints
    Whether to always print enums as ints. more...
    bool
    preserve_proto_field_names
    Whether to preserve proto field names.
    JsonPrintOptions()

    bool JsonPrintOptions::always_print_primitive_fields

    Whether to always print primitive fields.

    By default proto3 primitive fields with default values will be omitted in JSON output. For example, an int32 field set to 0 will be omitted. Set this flag to true will override the default behavior and print primitive fields regardless of their values.

    +

    struct JsonParseOptions

    #include <google/protobuf/util/json_util.h>
    namespace google::protobuf::util

    Members

    bool
    ignore_unknown_fields
    Whether to ignore unknown JSON fields during parsing.
    bool
    case_insensitive_enum_parsing
    If true, when a lowercase enum value fails to parse, try convert it to UPPER_CASE and see if it matches a valid enum. more...
    JsonParseOptions()

    bool JsonParseOptions::case_insensitive_enum_parsing

    If true, when a lowercase enum value fails to parse, try convert it to UPPER_CASE and see if it matches a valid enum.

    WARNING: This option exists only to preserve legacy behavior. Avoid using this option. If your enum needs to support different casing, consider using allow_alias instead.

    +

    struct JsonPrintOptions

    #include <google/protobuf/util/json_util.h>
    namespace google::protobuf::util

    Members

    bool
    add_whitespace
    Whether to add spaces, line breaks and indentation to make the JSON output easy to read.
    bool
    always_print_primitive_fields
    Whether to always print primitive fields. more...
    bool
    always_print_enums_as_ints
    Whether to always print enums as ints. more...
    bool
    preserve_proto_field_names
    Whether to preserve proto field names.
    JsonPrintOptions()

    bool JsonPrintOptions::always_print_primitive_fields

    Whether to always print primitive fields.

    By default proto3 primitive fields with default values will be omitted in JSON output. For example, an int32 field set to 0 will be omitted. Set this flag to true will override the default behavior and print primitive fields regardless of their values.


    bool JsonPrintOptions::always_print_enums_as_ints

    Whether to always print enums as ints.

    By default they are rendered as strings.

    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 16b1daac..e0f1a68c 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 @@ -8,31 +8,31 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    This file defines static methods and classes for comparing Protocol Messages.

    Aug. 2008: Added Unknown Fields Comparison for messages. Aug. 2009: Added different options to compare repeated fields. Apr. 2010: Moved field comparison to FieldComparator Sep. 2020: Added option to output map keys in path

    +

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    This file defines static methods and classes for comparing Protocol Messages.

    Aug. 2008: Added Unknown Fields Comparison for messages. Aug. 2009: Added different options to compare repeated fields. Apr. 2010: Moved field comparison to FieldComparator Sep. 2020: Added option to output map keys in path

    -

    Classes in this file

    A basic differencer that can be used to determine the differences between two specified Protocol Messages.
    Abstract base class from which all IgnoreCriteria derive.
    MapKeyComparator is used to determine if two elements have the same key when comparing elements of a repeated field as a map.
    Abstract base class from which all MessageDifferencer reporters derive.
    Identifies an individual field in a message instance.
    An implementation of the MessageDifferencer Reporter that outputs any differences found in human-readable form to the supplied ZeroCopyOutputStream or Printer.
    Class for processing Any deserialization.
    This class provides extra information to the FieldComparator::Compare function.

    File Members

    These definitions are not part of any class.
    typedef
    std::vector< const FieldDescriptor * > FieldDescriptorArray
    Defines a collection of field descriptors. more...

    typedef util::FieldDescriptorArray

    Defines a collection of field descriptors.

    In case of internal google codebase we are using absl::FixedArray instead of vector. It significantly speeds up proto comparison (by ~30%) by reducing the number of malloc/free operations

    -

    class MessageDifferencer

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    A basic differencer that can be used to determine the differences between two specified Protocol Messages.

    If any differences are found, the Compare method will return false, and any differencer reporter specified via ReportDifferencesTo will have its reporting methods called (see below for implementation of the report). Based off of the original ProtocolDifferencer implementation in //net/proto/protocol-differencer.h (Thanks Todd!).

    +

    Classes in this file

    A basic differencer that can be used to determine the differences between two specified Protocol Messages.
    Abstract base class from which all IgnoreCriteria derive.
    MapKeyComparator is used to determine if two elements have the same key when comparing elements of a repeated field as a map.
    Abstract base class from which all MessageDifferencer reporters derive.
    Identifies an individual field in a message instance.
    An implementation of the MessageDifferencer Reporter that outputs any differences found in human-readable form to the supplied ZeroCopyOutputStream or Printer.
    Class for processing Any deserialization.
    This class provides extra information to the FieldComparator::Compare function.

    File Members

    These definitions are not part of any class.
    typedef
    std::vector< const FieldDescriptor * > FieldDescriptorArray
    Defines a collection of field descriptors. more...

    typedef util::FieldDescriptorArray

    Defines a collection of field descriptors.

    In case of internal google codebase we are using absl::FixedArray instead of vector. It significantly speeds up proto comparison (by ~30%) by reducing the number of malloc/free operations

    +

    class MessageDifferencer

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    A basic differencer that can be used to determine the differences between two specified Protocol Messages.

    If any differences are found, the Compare method will return false, and any differencer reporter specified via ReportDifferencesTo will have its reporting methods called (see below for implementation of the report). Based off of the original ProtocolDifferencer implementation in //net/proto/protocol-differencer.h (Thanks Todd!).

    MessageDifferencer REQUIRES that compared messages be the same type, defined as messages that share the same descriptor. If not, the behavior of this class is undefined.

    People disagree on what MessageDifferencer should do when asked to compare messages with different descriptors. Some people think it should always return false. Others expect it to try to look for similar fields and compare them anyway – especially if the descriptors happen to be identical. If we chose either of these behaviors, some set of people would find it surprising, and could end up writing code expecting the other behavior without realizing their error. Therefore, we forbid that usage.

    This class is implemented based on the proto2 reflection. The performance should be good enough for normal usages. However, for places where the performance is extremely sensitive, there are several alternatives:

    • Comparing serialized string Downside: false negatives (there are messages that are the same but their serialized strings are different).
    -

    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 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
    FloatComparison
    DEPRECATED. Use FieldComparator::FloatComparison instead. more...
    enum
    RepeatedFieldComparison
    DefaultFieldComparator *
    default_impl
    FieldComparator *
    base
    static bool
    Equals(const Message & message1, const Message & message2)
    Determines whether the supplied messages are equal. more...
    static bool
    Equivalent(const Message & message1, const Message & message2)
    Determines whether the supplied messages are equivalent. more...
    static bool
    ApproximatelyEquals(const Message & message1, const Message & message2)
    Determines whether the supplied messages are approximately equal. more...
    static bool
    ApproximatelyEquivalent(const Message & message1, const Message & message2)
    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 Protobuf 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
    Compare(const Message & message1, const Message & message2)
    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
    }

    EQUALFields 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.

    +

    Members

    enum
    MessageFieldComparison
    enum
    Scope
    enum
    FloatComparison
    DEPRECATED. Use FieldComparator::FloatComparison instead. more...
    enum
    RepeatedFieldComparison
    DefaultFieldComparator *
    default_impl
    FieldComparator *
    base
    static bool
    Equals(const Message & message1, const Message & message2)
    Determines whether the supplied messages are equal. more...
    static bool
    Equivalent(const Message & message1, const Message & message2)
    Determines whether the supplied messages are equivalent. more...
    static bool
    ApproximatelyEquals(const Message & message1, const Message & message2)
    Determines whether the supplied messages are approximately equal. more...
    static bool
    ApproximatelyEquivalent(const Message & message1, const Message & message2)
    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 Protobuf 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
    Compare(const Message & message1, const Message & message2)
    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
    }

    EQUALFields 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
    }

    FULLAll fields of both messages are considered in the comparison.
    PARTIALOnly 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.

    EXACTFloats and doubles are compared exactly.
    APPROXIMATEFloats 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.

    -
    AS_SMART_SETSimilar to AS_SET, but match elements with fewest diffs.

    static bool MessageDifferencer::Equals(
            const Message & message1,
            const Message & message2)

    Determines whether the supplied messages are equal.

    Equality is defined as all fields within the two messages being set to the same value. Primitive fields and strings are compared by value while embedded messages/groups are compared as if via a recursive call. Use Compare() with IgnoreField() if some fields should be ignored in the comparison. Use Compare() with TreatAsSet() if there are repeated fields where ordering does not matter.

    -

    This method REQUIRES that the two messages have the same Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).

    -

    static bool MessageDifferencer::Equivalent(
            const Message & message1,
            const Message & message2)

    Determines whether the supplied messages are equivalent.

    Equivalency is defined as all fields within the two messages having the same value. This differs from the Equals method above in that fields with default values are considered set to said value automatically. For details on how default values are defined for each field type, see: static bool MessageDifferencer::ApproximatelyEquals(
            const
    Message & message1,
            const Message & message2)

    Determines whether the supplied messages are approximately equal.

    Approximate equality is defined as all fields within the two messages being approximately equal. Primitive (non-float) fields and strings are compared by value, floats are compared using MathUtil::AlmostEquals() and embedded messages/groups are compared as if via a recursive call. Use IgnoreField() and Compare() if some fields should be ignored in the comparison.

    -

    This method REQUIRES that the two messages have the same Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).

    -

    static bool MessageDifferencer::ApproximatelyEquivalent(
            const Message & message1,
            const Message & message2)

    Determines whether the supplied messages are approximately equivalent.

    Approximate equivalency is defined as all fields within the two messages being approximately equivalent. As in MessageDifferencer::ApproximatelyEquals, primitive (non-float) fields and strings are compared by value, floats are compared using MathUtil::AlmostEquals() and embedded messages/groups are compared as if via a recursive call. However, fields with default values are considered set to said value, as per MessageDiffencer::Equivalent. Use IgnoreField() and Compare() if some fields should be ignored in the comparison.

    -

    This method REQUIRES that the two messages have the same Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).

    -

    void MessageDifferencer::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.

    Elements which are present on both sides of the comparison but which have changed position will be reported with ReportMoved(). Elements which only exist on one side or the other are reported with ReportAdded() and ReportDeleted() regardless of their positions. ReportModified() is never used for this repeated field. If the only differences between the compared messages is that some fields have been moved, then the comparison returns true.

    +
    AS_SMART_SETSimilar to AS_SET, but match elements with fewest diffs.

    static bool MessageDifferencer::Equals(
            const Message & message1,
            const Message & message2)

    Determines whether the supplied messages are equal.

    Equality is defined as all fields within the two messages being set to the same value. Primitive fields and strings are compared by value while embedded messages/groups are compared as if via a recursive call. Use Compare() with IgnoreField() if some fields should be ignored in the comparison. Use Compare() with TreatAsSet() if there are repeated fields where ordering does not matter.

    +

    This method REQUIRES that the two messages have the same Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).

    +

    static bool MessageDifferencer::Equivalent(
            const Message & message1,
            const Message & message2)

    Determines whether the supplied messages are equivalent.

    Equivalency is defined as all fields within the two messages having the same value. This differs from the Equals method above in that fields with default values are considered set to said value automatically. For details on how default values are defined for each field type, see: static bool MessageDifferencer::ApproximatelyEquals(
            const
    Message & message1,
            const Message & message2)

    Determines whether the supplied messages are approximately equal.

    Approximate equality is defined as all fields within the two messages being approximately equal. Primitive (non-float) fields and strings are compared by value, floats are compared using MathUtil::AlmostEquals() and embedded messages/groups are compared as if via a recursive call. Use IgnoreField() and Compare() if some fields should be ignored in the comparison.

    +

    This method REQUIRES that the two messages have the same Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).

    +

    static bool MessageDifferencer::ApproximatelyEquivalent(
            const Message & message1,
            const Message & message2)

    Determines whether the supplied messages are approximately equivalent.

    Approximate equivalency is defined as all fields within the two messages being approximately equivalent. As in MessageDifferencer::ApproximatelyEquals, primitive (non-float) fields and strings are compared by value, floats are compared using MathUtil::AlmostEquals() and embedded messages/groups are compared as if via a recursive call. However, fields with default values are considered set to said value, as per MessageDiffencer::Equivalent. Use IgnoreField() and Compare() if some fields should be ignored in the comparison.

    +

    This method REQUIRES that the two messages have the same Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).

    +

    void MessageDifferencer::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.

    Elements which are present on both sides of the comparison but which have changed position will be reported with ReportMoved(). Elements which only exist on one side or the other are reported with ReportAdded() and ReportDeleted() regardless of their positions. ReportModified() is never used for this repeated field. If the only differences between the compared messages is that some fields have been moved, then the comparison returns true.

    Note that despite the name of this method, this is really comparison as multisets: if one side of the comparison has a duplicate in the repeated field but the other side doesn't, this will count as a mismatch.

    If the scope of comparison is set to PARTIAL, then in addition to what's above, extra values added to repeated fields of the second message will not cause the comparison to fail.

    Note that set comparison is currently O(k * n^2) (where n is the total number of elements, and k is the average size of each element). In theory it could be made O(n * k) with a more complex hashing implementation. Feel free to contribute one if the current implementation is too slow for you. If partial matching is also enabled, the time complexity will be O(k * n^2

    @@ -40,11 +40,11 @@ type = "docs"
  • n^3) in which n^3 is the time complexity of the maximum matching algorithm.
  • REQUIRES: field->is_repeated() and field not registered with TreatAsMap*

    -

    void MessageDifferencer::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.

    REQUIRES: field->is_repeated() and field not registered with TreatAsMap*

    -

    void MessageDifferencer::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.

    Thus, elements with the same key will be compared even if they do not appear at the same index. Differences are reported similarly to TreatAsSet(), except that ReportModified() is used to report elements with the same key but different values. Note that if an element is both moved and modified, only ReportModified() will be called. As with TreatAsSet, if the only differences between the compared messages is that some fields have been moved, then the comparison returns true. See TreatAsSet for notes on performance.

    -

    REQUIRES: field->is_repeated() REQUIRES: field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE REQUIRES: key->containing_type() == field->message_type()

    -

    void MessageDifferencer::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.

    All specified fields in 'key_fields' should be present in the compared elements. Two elements will be treated as having the same key iff they have the same value for every specified field. There are two steps in the comparison process. The first one is key matching. Every element from one message will be compared to every element from the other message. Only fields in 'key_fields' are compared in this step to decide if two elements have the same key. The second step is value comparison. Those pairs of elements with the same key (with equal value for every field in 'key_fields') will be compared in this step. Time complexity of the first step is O(s * m * n ^ 2) where s is the average size of the fields specified in 'key_fields', m is the number of fields in 'key_fields' and n is the number of elements. If partial matching is enabled, an extra O(n^3) will be incured by the maximum matching algorithm. The second step is O(k * n) where k is the average size of each element.

    -

    void MessageDifferencer::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.

    Each element in key_field_paths indicate a path from the message being compared, listing successive subfield to reach the key field.

    +

    void MessageDifferencer::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.

    REQUIRES: field->is_repeated() and field not registered with TreatAsMap*

    +

    void MessageDifferencer::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.

    Thus, elements with the same key will be compared even if they do not appear at the same index. Differences are reported similarly to TreatAsSet(), except that ReportModified() is used to report elements with the same key but different values. Note that if an element is both moved and modified, only ReportModified() will be called. As with TreatAsSet, if the only differences between the compared messages is that some fields have been moved, then the comparison returns true. See TreatAsSet for notes on performance.

    +

    REQUIRES: field->is_repeated() REQUIRES: field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE REQUIRES: key->containing_type() == field->message_type()

    +

    void MessageDifferencer::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.

    All specified fields in 'key_fields' should be present in the compared elements. Two elements will be treated as having the same key iff they have the same value for every specified field. There are two steps in the comparison process. The first one is key matching. Every element from one message will be compared to every element from the other message. Only fields in 'key_fields' are compared in this step to decide if two elements have the same key. The second step is value comparison. Those pairs of elements with the same key (with equal value for every field in 'key_fields') will be compared in this step. Time complexity of the first step is O(s * m * n ^ 2) where s is the average size of the fields specified in 'key_fields', m is the number of fields in 'key_fields' and n is the number of elements. If partial matching is enabled, an extra O(n^3) will be incured by the maximum matching algorithm. The second step is O(k * n) where k is the average size of each element.

    +

    void MessageDifferencer::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.

    Each element in key_field_paths indicate a path from the message being compared, listing successive subfield to reach the key field.

    REQUIRES:

    for key_field_path in key_field_paths:
       key_field_path[0]->containing_type() == field->message_type()
    @@ -53,29 +53,29 @@ type = "docs"
             key_field_path[i]->message_type()
         key_field_path[i]->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE
         !key_field_path[i]->is_repeated()
    -

    void MessageDifferencer::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.

    The caller is responsible to delete the key_comparator. This method varies from TreatAsMapWithMultipleFieldsAsKey only in the first key matching step. Rather than comparing some specified fields, it will invoke the IsMatch method of the given 'key_comparator' to decide if two elements have the same key.

    +

    void MessageDifferencer::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.

    The caller is responsible to delete the key_comparator. This method varies from TreatAsMapWithMultipleFieldsAsKey only in the first key matching step. Rather than comparing some specified fields, it will invoke the IsMatch method of the given 'key_comparator' to decide if two elements have the same key.


    void MessageDifferencer::AddIgnoreCriteria(
            IgnoreCriteria * ignore_criteria)

    Add a custom ignore criteria that is evaluated in addition to the ignored fields added with IgnoreField.

    Takes ownership of ignore_criteria.

    -

    void MessageDifferencer::IgnoreField(
            const FieldDescriptor * field)

    Indicates that any field with the given descriptor should be ignored for the purposes of comparing two messages.

    This applies to fields nested in the message structure as well as top level ones. When the MessageDifferencer encounters an ignored field, ReportIgnored is called on the reporter, if one is specified.

    +

    void MessageDifferencer::IgnoreField(
            const FieldDescriptor * field)

    Indicates that any field with the given descriptor should be ignored for the purposes of comparing two messages.

    This applies to fields nested in the message structure as well as top level ones. When the MessageDifferencer encounters an ignored field, ReportIgnored is called on the reporter, if one is specified.

    The only place where the field's 'ignored' status is not applied is when it is being used as a key in a field passed to TreatAsMap or is one of the fields passed to TreatAsMapWithMultipleFieldsAsKey. In this case it is compared in key matching but after that it's ignored in value comparison.

    -

    void MessageDifferencer::set_field_comparator(
            FieldComparator * comparator)

    Sets the field comparator used to determine differences between Protobuf fields.

    By default it's set to a DefaultFieldComparator instance. MessageDifferencer doesn't take ownership over the passed object. Note that this method must be called before Compare for the comparator to be used.

    -

    void MessageDifferencer::SetFractionAndMargin(
            const FieldDescriptor * field,
            double fraction,
            double margin)

    DEPRECATED.

    Pass a DefaultFieldComparator instance instead. Sets the fraction and margin for the float comparison of a given field. Uses MathUtil::WithinFractionOrMargin to compare the values. NOTE: this method does nothing if differencer's field comparator has been

    +

    void MessageDifferencer::set_field_comparator(
            FieldComparator * comparator)

    Sets the field comparator used to determine differences between Protobuf fields.

    By default it's set to a DefaultFieldComparator instance. MessageDifferencer doesn't take ownership over the passed object. Note that this method must be called before Compare for the comparator to be used.

    +

    void MessageDifferencer::SetFractionAndMargin(
            const FieldDescriptor * field,
            double fraction,
            double margin)

    DEPRECATED.

    Pass a DefaultFieldComparator instance instead. Sets the fraction and margin for the float comparison of a given field. Uses MathUtil::WithinFractionOrMargin to compare the values. NOTE: this method does nothing if differencer's field comparator has been

    set to a custom object.
    -

    REQUIRES: field->cpp_type == FieldDescriptor::CPPTYPE_DOUBLE or

    +

    REQUIRES: field->cpp_type == FieldDescriptor::CPPTYPE_DOUBLE or

    field->cpp_type == FieldDescriptor::CPPTYPE_FLOAT

    REQUIRES: float_comparison_ == APPROXIMATE


    void MessageDifferencer::set_report_matches(
            bool report_matches)

    Tells the differencer whether or not to report matches.

    This method must be called before Compare. The default for a new differencer is false.


    void MessageDifferencer::set_report_moves(
            bool report_moves)

    Tells the differencer whether or not to report moves (in a set or map repeated field).

    This method must be called before Compare. The default for a new differencer is true.


    void MessageDifferencer::set_report_ignores(
            bool report_ignores)

    Tells the differencer whether or not to report ignored values.

    This method must be called before Compare. The default for a new differencer is true.

    -

    void MessageDifferencer::set_float_comparison(
            FloatComparison comparison)

    DEPRECATED.

    Pass a DefaultFieldComparator instance instead. Sets the type of comparison (as defined in the FloatComparison enumeration above) that is used by this differencer when comparing float (and double) fields in messages. NOTE: this method does nothing if differencer's field comparator has been

    +

    void MessageDifferencer::set_float_comparison(
            FloatComparison comparison)

    DEPRECATED.

    Pass a DefaultFieldComparator instance instead. Sets the type of comparison (as defined in the FloatComparison enumeration above) that is used by this differencer when comparing float (and double) fields in messages. NOTE: this method does nothing if differencer's field comparator has been

    set to a custom object.
    -

    bool MessageDifferencer::Compare(
            const Message & message1,
            const Message & message2)

    Compares the two specified messages, returning true if they are the same, false otherwise.

    If this method returns false, any changes between the two messages will be reported if a Reporter was specified via ReportDifferencesTo (see also ReportDifferencesToString).

    -

    This method REQUIRES that the two messages have the same Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).

    +

    bool MessageDifferencer::Compare(
            const Message & message1,
            const Message & message2)

    Compares the two specified messages, returning true if they are the same, false otherwise.

    If this method returns false, any changes between the two messages will be reported if a Reporter was specified via ReportDifferencesTo (see also ReportDifferencesToString).

    +

    This method REQUIRES that the two messages have the same Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).


    void MessageDifferencer::ReportDifferencesToString(
            std::string * output)

    Automatically creates a reporter that will output the differences found (if any) to the specified output string pointer.

    Note that this method must be called before Compare.


    void MessageDifferencer::ReportDifferencesTo(
            Reporter * reporter)

    Tells the MessageDifferencer to report differences via the specified reporter.

    Note that this method must be called before Compare for the reporter to be used. It is the responsibility of the caller to delete this object. If the provided pointer equals NULL, the MessageDifferencer stops reporting differences to any previously set reporters or output strings.

    -

    class MessageDifferencer::IgnoreCriteria

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    Abstract base class from which all IgnoreCriteria derive.

    By adding IgnoreCriteria more complex ignore logic can be implemented. IgnoreCriteria are registered with AddIgnoreCriteria. For each compared field IsIgnored is called on each added IgnoreCriteria until one returns true or all return false. IsIgnored is called for fields where at least one side has a value.

    -

    Members

    IgnoreCriteria()
    virtual
    ~IgnoreCriteria()
    virtual bool
    IsIgnored(const Message & , const Message & , const FieldDescriptor * , const std::vector< SpecificField > & ) = 0
    Returns true if the field should be ignored.
    virtual bool
    IsUnknownFieldIgnored(const Message & , const Message & , const SpecificField & , const std::vector< SpecificField > & )
    Returns true if the unknown field should be ignored. more...

    virtual bool IgnoreCriteria::IsUnknownFieldIgnored(
            const Message & ,
            const Message & ,
            const SpecificField & ,
            const std::vector< SpecificField > & )

    Returns true if the unknown field should be ignored.

    Note: This will be called for unknown fields as well in which case

    +

    class MessageDifferencer::IgnoreCriteria

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    Abstract base class from which all IgnoreCriteria derive.

    By adding IgnoreCriteria more complex ignore logic can be implemented. IgnoreCriteria are registered with AddIgnoreCriteria. For each compared field IsIgnored is called on each added IgnoreCriteria until one returns true or all return false. IsIgnored is called for fields where at least one side has a value.

    +

    Members

    IgnoreCriteria()
    virtual
    ~IgnoreCriteria()
    virtual bool
    IsIgnored(const Message & , const Message & , const FieldDescriptor * , const std::vector< SpecificField > & ) = 0
    Returns true if the field should be ignored.
    virtual bool
    IsUnknownFieldIgnored(const Message & , const Message & , const SpecificField & , const std::vector< SpecificField > & )
    Returns true if the unknown field should be ignored. more...

    virtual bool IgnoreCriteria::IsUnknownFieldIgnored(
            const Message & ,
            const Message & ,
            const SpecificField & ,
            const std::vector< SpecificField > & )

    Returns true if the unknown field should be ignored.

    Note: This will be called for unknown fields as well in which case

    field.field will be null.
    -

    class MessageDifferencer::MapKeyComparator

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    MapKeyComparator is used to determine if two elements have the same key when comparing elements of a repeated field as a map.

    Members

    MapKeyComparator()
    virtual
    ~MapKeyComparator()
    virtual bool
    IsMatch(const Message & , const Message & , const std::vector< SpecificField > & ) const

    class MessageDifferencer::Reporter

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    Abstract base class from which all MessageDifferencer reporters derive.

    The five Report* methods below will be called when a field has been added, deleted, modified, moved, or matched. The third argument is a vector of FieldDescriptor pointers which describes the chain of fields that was taken to find the current field. For example, for a field found in an embedded message, the vector will contain two FieldDescriptors. The first will be the field of the embedded message itself and the second will be the actual field in the embedded message that was added/deleted/modified. Fields will be reported in PostTraversalOrder. For example, given the following proto, if both baz and mooo are changed. +

    class MessageDifferencer::MapKeyComparator

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    MapKeyComparator is used to determine if two elements have the same key when comparing elements of a repeated field as a map.

    Members

    MapKeyComparator()
    virtual
    ~MapKeyComparator()
    virtual bool
    IsMatch(const Message & , const Message & , const std::vector< SpecificField > & ) const

    class MessageDifferencer::Reporter

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    Abstract base class from which all MessageDifferencer reporters derive.

    The five Report* methods below will be called when a field has been added, deleted, modified, moved, or matched. The third argument is a vector of FieldDescriptor pointers which describes the chain of fields that was taken to find the current field. For example, for a field found in an embedded message, the vector will contain two FieldDescriptors. The first will be the field of the embedded message itself and the second will be the actual field in the embedded message that was added/deleted/modified. Fields will be reported in PostTraversalOrder. For example, given the following proto, if both baz and mooo are changed.

    foo {
       bar {
         baz: 1
    @@ -89,27 +89,27 @@ type = "docs"
       
  • foo.bar
  • foo
  • -

    Known subclasses:

    Members

    Reporter()
    virtual
    ~Reporter()
    virtual void
    ReportAdded(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path) = 0
    Reports that a field has been added into Message2.
    virtual void
    ReportDeleted(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path) = 0
    Reports that a field has been deleted from Message1.
    virtual void
    ReportModified(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path) = 0
    Reports that the value of a field has been modified.
    virtual void
    ReportMoved(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that a repeated field has been moved to another location. more...
    virtual void
    ReportMatched(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that two fields match. more...
    virtual void
    ReportIgnored(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that two fields would have been compared, but the comparison has been skipped because the field was marked as 'ignored' using IgnoreField(). more...
    virtual void
    ReportUnknownFieldIgnored(const Message & , const Message & , const std::vector< SpecificField > & )
    Report that an unknown field is ignored. more...

    virtual void Reporter::ReportMoved(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that a repeated field has been moved to another location.

    This only applies when using TreatAsSet or TreatAsMap() – see below. Also note that for any given field, ReportModified and ReportMoved are mutually exclusive. If a field has been both moved and modified, then only ReportModified will be called.

    -

    virtual void Reporter::ReportMatched(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that two fields match.

    Useful for doing side-by-side diffs. This function is mutually exclusive with ReportModified and ReportMoved. Note that you must call set_report_matches(true) before calling Compare to make use of this function.

    -

    virtual void Reporter::ReportIgnored(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that two fields would have been compared, but the comparison has been skipped because the field was marked as 'ignored' using IgnoreField().

    This function is mutually exclusive with all the other Report() functions.

    +

    Known subclasses:

    Members

    Reporter()
    virtual
    ~Reporter()
    virtual void
    ReportAdded(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path) = 0
    Reports that a field has been added into Message2.
    virtual void
    ReportDeleted(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path) = 0
    Reports that a field has been deleted from Message1.
    virtual void
    ReportModified(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path) = 0
    Reports that the value of a field has been modified.
    virtual void
    ReportMoved(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that a repeated field has been moved to another location. more...
    virtual void
    ReportMatched(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that two fields match. more...
    virtual void
    ReportIgnored(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that two fields would have been compared, but the comparison has been skipped because the field was marked as 'ignored' using IgnoreField(). more...
    virtual void
    ReportUnknownFieldIgnored(const Message & , const Message & , const std::vector< SpecificField > & )
    Report that an unknown field is ignored. more...

    virtual void Reporter::ReportMoved(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that a repeated field has been moved to another location.

    This only applies when using TreatAsSet or TreatAsMap() – see below. Also note that for any given field, ReportModified and ReportMoved are mutually exclusive. If a field has been both moved and modified, then only ReportModified will be called.

    +

    virtual void Reporter::ReportMatched(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that two fields match.

    Useful for doing side-by-side diffs. This function is mutually exclusive with ReportModified and ReportMoved. Note that you must call set_report_matches(true) before calling Compare to make use of this function.

    +

    virtual void Reporter::ReportIgnored(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that two fields would have been compared, but the comparison has been skipped because the field was marked as 'ignored' using IgnoreField().

    This function is mutually exclusive with all the other Report() functions.

    The contract of ReportIgnored is slightly different than the other Report() functions, in that |field_path.back().index| is always equal to -1, even if the last field is repeated. This is because while the other Report() functions indicate where in a repeated field the action (Addition, Deletion, etc...) happened, when a repeated field is 'ignored', the differencer simply calls ReportIgnored on the repeated field as a whole and moves on without looking at its individual elements.

    Furthermore, ReportIgnored() does not indicate whether the fields were in fact equal or not, as Compare() does not inspect these fields at all. It is up to the Reporter to decide whether the fields are equal or not (perhaps with a second call to Compare()), if it cares.

    -

    virtual void Reporter::ReportUnknownFieldIgnored(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Report that an unknown field is ignored.

    (see comment above). Note this is a different function since the last SpecificField in field path has a null field. This could break existing Reporter.

    -

    struct MessageDifferencer::SpecificField

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    Identifies an individual field in a message instance.

    Used for field_path, below.

    -

    Members

    const FieldDescriptor *
    field = = nullptr
    For known fields, "field" is filled in and "unknown_field_number" is -1. more...
    int
    unknown_field_number = = -1
    UnknownField::Type
    unknown_field_type = = UnknownField::Type::TYPE_VARINT
    int
    index = = -1
    If this a repeated field, "index" is the index within it. more...
    int
    new_index = = -1
    If "field" is a repeated field which is being treated as a map or a set (see TreatAsMap() and TreatAsSet(), below), new_index indicates the index the position to which the element has moved. more...
    const UnknownFieldSet *
    unknown_field_set1 = = nullptr
    For unknown fields, these are the pointers to the UnknownFieldSet containing the unknown fields. more...
    const UnknownFieldSet *
    unknown_field_set2 = = nullptr
    int
    unknown_field_index1 = = -1
    For unknown fields, these are the index of the field within the UnknownFieldSets. more...
    int
    unknown_field_index2 = = -1

    const FieldDescriptor * SpecificField::field = = nullptr

    For known fields, "field" is filled in and "unknown_field_number" is -1.

    For unknown fields, "field" is NULL, "unknown_field_number" is the field number, and "unknown_field_type" is its type.

    +

    virtual void Reporter::ReportUnknownFieldIgnored(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Report that an unknown field is ignored.

    (see comment above). Note this is a different function since the last SpecificField in field path has a null field. This could break existing Reporter.

    +

    struct MessageDifferencer::SpecificField

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    Identifies an individual field in a message instance.

    Used for field_path, below.

    +

    Members

    const FieldDescriptor *
    field = = nullptr
    For known fields, "field" is filled in and "unknown_field_number" is -1. more...
    int
    unknown_field_number = = -1
    UnknownField::Type
    unknown_field_type = = UnknownField::Type::TYPE_VARINT
    int
    index = = -1
    If this a repeated field, "index" is the index within it. more...
    int
    new_index = = -1
    If "field" is a repeated field which is being treated as a map or a set (see TreatAsMap() and TreatAsSet(), below), new_index indicates the index the position to which the element has moved. more...
    const UnknownFieldSet *
    unknown_field_set1 = = nullptr
    For unknown fields, these are the pointers to the UnknownFieldSet containing the unknown fields. more...
    const UnknownFieldSet *
    unknown_field_set2 = = nullptr
    int
    unknown_field_index1 = = -1
    For unknown fields, these are the index of the field within the UnknownFieldSets. more...
    int
    unknown_field_index2 = = -1

    const FieldDescriptor * SpecificField::field = = nullptr

    For known fields, "field" is filled in and "unknown_field_number" is -1.

    For unknown fields, "field" is NULL, "unknown_field_number" is the field number, and "unknown_field_type" is its type.


    int SpecificField::index = = -1

    If this a repeated field, "index" is the index within it.

    For unknown fields, this is the index of the field among all unknown fields of the same field number and type.


    int SpecificField::new_index = = -1

    If "field" is a repeated field which is being treated as a map or a set (see TreatAsMap() and TreatAsSet(), below), new_index indicates the index the position to which the element has moved.

    If the element has not moved, "new_index" will have the same value as "index".

    -

    const UnknownFieldSet * SpecificField::unknown_field_set1 = = nullptr

    For unknown fields, these are the pointers to the UnknownFieldSet containing the unknown fields.

    In certain cases (e.g. proto1's MessageSet, or nested groups of unknown fields), these may differ from the messages' internal UnknownFieldSets.

    +

    const UnknownFieldSet * SpecificField::unknown_field_set1 = = nullptr

    For unknown fields, these are the pointers to the UnknownFieldSet containing the unknown fields.

    In certain cases (e.g. proto1's MessageSet, or nested groups of unknown fields), these may differ from the messages' internal UnknownFieldSets.


    int SpecificField::unknown_field_index1 = = -1

    For unknown fields, these are the index of the field within the UnknownFieldSets.

    One or the other will be -1 when reporting an addition or deletion.

    -

    class MessageDifferencer::StreamReporter: public Reporter

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    An implementation of the MessageDifferencer Reporter that outputs any differences found in human-readable form to the supplied ZeroCopyOutputStream or Printer.

    If a printer is used, the delimiter must be '$'.

    +

    class MessageDifferencer::StreamReporter: public Reporter

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    An implementation of the MessageDifferencer Reporter that outputs any differences found in human-readable form to the supplied ZeroCopyOutputStream or Printer.

    If a printer is used, the delimiter must be '$'.

    WARNING: this reporter does not necessarily flush its output until it is destroyed. As a result, it is not safe to assume the output is valid or complete until after you destroy the reporter. For example, if you use a StreamReporter to write to a StringOutputStream, the target string may contain uninitialized data until the reporter is destroyed.

    -

    Members

    explicit
    StreamReporter(io::ZeroCopyOutputStream * output)
    explicit
    StreamReporter(io::Printer * printer)
    delimiter '$'
    ~StreamReporter()
    void
    set_report_modified_aggregates(bool report)
    When set to true, the stream reporter will also output aggregates nodes (i.e. more...
    virtual void
    ReportAdded(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path)
    Reports that a field has been added into Message2.
    virtual void
    ReportDeleted(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path)
    Reports that a field has been deleted from Message1.
    virtual void
    ReportModified(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path)
    Reports that the value of a field has been modified.
    virtual void
    ReportMoved(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that a repeated field has been moved to another location. more...
    virtual void
    ReportMatched(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that two fields match. more...
    virtual void
    ReportIgnored(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that two fields would have been compared, but the comparison has been skipped because the field was marked as 'ignored' using IgnoreField(). more...
    virtual void
    ReportUnknownFieldIgnored(const Message & , const Message & , const std::vector< SpecificField > & )
    Report that an unknown field is ignored. more...
    void
    SetMessages(const Message & message1, const Message & message2)
    Messages that are being compared must be provided to StreamReporter prior to processing.
    protected virtual void
    PrintPath(const std::vector< SpecificField > & field_path, bool left_side)
    Prints the specified path of fields to the buffer.
    protected virtual void
    PrintValue(const Message & message, const std::vector< SpecificField > & field_path, bool left_side)
    Prints the value of fields to the buffer. more...
    protected virtual void
    PrintUnknownFieldValue(const UnknownField * unknown_field)
    Prints the specified path of unknown fields to the buffer.
    protected void
    Print(const std::string & str)
    Just print a string.
    protected void
    PrintMapKey(const std::vector< SpecificField > & field_path, bool left_side, const SpecificField & specific_field, size_t target_field_index)
    helper function for PrintPath that contains logic for printing maps

    void StreamReporter::set_report_modified_aggregates(
            bool report)

    When set to true, the stream reporter will also output aggregates nodes (i.e.

    messages and groups) whose subfields have been modified. When false, will only report the individual subfields. Defaults to false.

    -

    virtual void StreamReporter::ReportMoved(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that a repeated field has been moved to another location.

    This only applies when using TreatAsSet or TreatAsMap() – see below. Also note that for any given field, ReportModified and ReportMoved are mutually exclusive. If a field has been both moved and modified, then only ReportModified will be called.

    -

    virtual void StreamReporter::ReportMatched(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that two fields match.

    Useful for doing side-by-side diffs. This function is mutually exclusive with ReportModified and ReportMoved. Note that you must call set_report_matches(true) before calling Compare to make use of this function.

    -

    virtual void StreamReporter::ReportIgnored(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that two fields would have been compared, but the comparison has been skipped because the field was marked as 'ignored' using IgnoreField().

    This function is mutually exclusive with all the other Report() functions.

    +

    Members

    explicit
    StreamReporter(io::ZeroCopyOutputStream * output)
    explicit
    StreamReporter(io::Printer * printer)
    delimiter '$'
    ~StreamReporter()
    void
    set_report_modified_aggregates(bool report)
    When set to true, the stream reporter will also output aggregates nodes (i.e. more...
    virtual void
    ReportAdded(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path)
    Reports that a field has been added into Message2.
    virtual void
    ReportDeleted(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path)
    Reports that a field has been deleted from Message1.
    virtual void
    ReportModified(const Message & message1, const Message & message2, const std::vector< SpecificField > & field_path)
    Reports that the value of a field has been modified.
    virtual void
    ReportMoved(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that a repeated field has been moved to another location. more...
    virtual void
    ReportMatched(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that two fields match. more...
    virtual void
    ReportIgnored(const Message & , const Message & , const std::vector< SpecificField > & )
    Reports that two fields would have been compared, but the comparison has been skipped because the field was marked as 'ignored' using IgnoreField(). more...
    virtual void
    ReportUnknownFieldIgnored(const Message & , const Message & , const std::vector< SpecificField > & )
    Report that an unknown field is ignored. more...
    void
    SetMessages(const Message & message1, const Message & message2)
    Messages that are being compared must be provided to StreamReporter prior to processing.
    protected virtual void
    PrintPath(const std::vector< SpecificField > & field_path, bool left_side)
    Prints the specified path of fields to the buffer.
    protected virtual void
    PrintValue(const Message & message, const std::vector< SpecificField > & field_path, bool left_side)
    Prints the value of fields to the buffer. more...
    protected virtual void
    PrintUnknownFieldValue(const UnknownField * unknown_field)
    Prints the specified path of unknown fields to the buffer.
    protected void
    Print(const std::string & str)
    Just print a string.
    protected void
    PrintMapKey(const std::vector< SpecificField > & field_path, bool left_side, const SpecificField & specific_field, size_t target_field_index)
    helper function for PrintPath that contains logic for printing maps

    void StreamReporter::set_report_modified_aggregates(
            bool report)

    When set to true, the stream reporter will also output aggregates nodes (i.e.

    messages and groups) whose subfields have been modified. When false, will only report the individual subfields. Defaults to false.

    +

    virtual void StreamReporter::ReportMoved(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that a repeated field has been moved to another location.

    This only applies when using TreatAsSet or TreatAsMap() – see below. Also note that for any given field, ReportModified and ReportMoved are mutually exclusive. If a field has been both moved and modified, then only ReportModified will be called.

    +

    virtual void StreamReporter::ReportMatched(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that two fields match.

    Useful for doing side-by-side diffs. This function is mutually exclusive with ReportModified and ReportMoved. Note that you must call set_report_matches(true) before calling Compare to make use of this function.

    +

    virtual void StreamReporter::ReportIgnored(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Reports that two fields would have been compared, but the comparison has been skipped because the field was marked as 'ignored' using IgnoreField().

    This function is mutually exclusive with all the other Report() functions.

    The contract of ReportIgnored is slightly different than the other Report() functions, in that |field_path.back().index| is always equal to -1, even if the last field is repeated. This is because while the other Report() functions indicate where in a repeated field the action (Addition, Deletion, etc...) happened, when a repeated field is 'ignored', the differencer simply calls ReportIgnored on the repeated field as a whole and moves on without looking at its individual elements.

    Furthermore, ReportIgnored() does not indicate whether the fields were in fact equal or not, as Compare() does not inspect these fields at all. It is up to the Reporter to decide whether the fields are equal or not (perhaps with a second call to Compare()), if it cares.

    -

    virtual void StreamReporter::ReportUnknownFieldIgnored(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Report that an unknown field is ignored.

    (see comment above). Note this is a different function since the last SpecificField in field path has a null field. This could break existing Reporter.

    -

    protected virtual void StreamReporter::PrintValue(
            const Message & message,
            const std::vector< SpecificField > & field_path,
            bool left_side)

    Prints the value of fields to the buffer.

    left_side is true if the given message is from the left side of the comparison, false if it was the right. This is relevant only to decide whether to follow unknown_field_index1 or unknown_field_index2 when an unknown field is encountered in field_path.

    -

    class MessageDifferencer::UnpackAnyField

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    Class for processing Any deserialization.

    This logic is used by both the MessageDifferencer and StreamReporter classes.

    -

    Members

    UnpackAnyField()
    ~UnpackAnyField()
    bool
    UnpackAny(const Message & any, std::unique_ptr< Message > * data)
    If "any" is of type google.protobuf.Any, extract its payload using DynamicMessageFactory and store in "data".

    class FieldContext

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    This class provides extra information to the FieldComparator::Compare function.

    Members

    explicit
    FieldContext(std::vector< MessageDifferencer::SpecificField > * parent_fields)
    std::vector< MessageDifferencer::SpecificField > *
    parent_fields() const
    +

    virtual void StreamReporter::ReportUnknownFieldIgnored(
            const Message & ,
            const Message & ,
            const std::vector< SpecificField > & )

    Report that an unknown field is ignored.

    (see comment above). Note this is a different function since the last SpecificField in field path has a null field. This could break existing Reporter.

    +

    protected virtual void StreamReporter::PrintValue(
            const Message & message,
            const std::vector< SpecificField > & field_path,
            bool left_side)

    Prints the value of fields to the buffer.

    left_side is true if the given message is from the left side of the comparison, false if it was the right. This is relevant only to decide whether to follow unknown_field_index1 or unknown_field_index2 when an unknown field is encountered in field_path.

    +

    class MessageDifferencer::UnpackAnyField

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    Class for processing Any deserialization.

    This logic is used by both the MessageDifferencer and StreamReporter classes.

    +

    Members

    UnpackAnyField()
    ~UnpackAnyField()
    bool
    UnpackAny(const Message & any, std::unique_ptr< Message > * data)
    If "any" is of type google.protobuf.Any, extract its payload using DynamicMessageFactory and store in "data".

    class FieldContext

    #include <google/protobuf/util/message_differencer.h>
    namespace google::protobuf::util

    This class provides extra information to the FieldComparator::Compare function.

    Members

    explicit
    FieldContext(std::vector< MessageDifferencer::SpecificField > * parent_fields)
    std::vector< MessageDifferencer::SpecificField > *
    parent_fields() const
    diff --git a/content/reference/cpp/api-docs/google.protobuf.util.time_util.md b/content/reference/cpp/api-docs/google.protobuf.util.time_util.md index e011d878..03eb77c9 100644 --- a/content/reference/cpp/api-docs/google.protobuf.util.time_util.md +++ b/content/reference/cpp/api-docs/google.protobuf.util.time_util.md @@ -6,7 +6,7 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/util/time_util.h>
    namespace google::protobuf::util

    Defines utilities for the Timestamp and Duration well known types.

    Classes in this file

    Utility functions for Timestamp and Duration.

    class TimeUtil

    #include <google/protobuf/util/time_util.h>
    namespace google::protobuf::util

    Utility functions for Timestamp and Duration.

    Members

    const int64_t
    kTimestampMinSeconds = = -62135596800LL
    The min/max Timestamp/Duration values we support. more...
    const int64_t
    kTimestampMaxSeconds = = 253402300799LL
    For "9999-12-31T23:59:59.999999999Z".
    const int64_t
    kDurationMinSeconds = = -315576000000LL
    const int64_t
    kDurationMaxSeconds = = 315576000000LL
    static std::string
    ToString(const Timestamp & timestamp)
    Converts Timestamp to/from RFC 3339 date string format. more...
    static bool
    FromString(const std::string & value, Timestamp * timestamp)
    static std::string
    ToString(const Duration & duration)
    Converts Duration to/from string format. more...
    static bool
    FromString(const std::string & value, Duration * timestamp)
    static Timestamp
    GetCurrentTime()
    Gets the current UTC time.
    static Timestamp
    GetEpoch()
    Returns the Time representing "1970-01-01 00:00:00".
    static Duration
    NanosecondsToDuration(int64_t nanos)
    Converts between Duration and integer types. more...
    static Duration
    MicrosecondsToDuration(int64_t micros)
    static Duration
    MillisecondsToDuration(int64_t millis)
    static Duration
    SecondsToDuration(int64_t seconds)
    static Duration
    MinutesToDuration(int64_t minutes)
    static Duration
    HoursToDuration(int64_t hours)
    static int64_t
    DurationToNanoseconds(const Duration & duration)
    Result will be truncated towards zero. more...
    static int64_t
    DurationToMicroseconds(const Duration & duration)
    static int64_t
    DurationToMilliseconds(const Duration & duration)
    static int64_t
    DurationToSeconds(const Duration & duration)
    static int64_t
    DurationToMinutes(const Duration & duration)
    static int64_t
    DurationToHours(const Duration & duration)
    static Timestamp
    NanosecondsToTimestamp(int64_t nanos)
    Creates Timestamp from integer types. more...
    static Timestamp
    MicrosecondsToTimestamp(int64_t micros)
    static Timestamp
    MillisecondsToTimestamp(int64_t millis)
    static Timestamp
    SecondsToTimestamp(int64_t seconds)
    static int64_t
    TimestampToNanoseconds(const Timestamp & timestamp)
    Result will be truncated down to the nearest integer value. more...
    static int64_t
    TimestampToMicroseconds(const Timestamp & timestamp)
    static int64_t
    TimestampToMilliseconds(const Timestamp & timestamp)
    static int64_t
    TimestampToSeconds(const Timestamp & timestamp)
    static Timestamp
    TimeTToTimestamp(time_t value)
    Conversion to/from other time/date types. more...
    static time_t
    TimestampToTimeT(const Timestamp & value)
    static Timestamp
    TimevalToTimestamp(const timeval & value)
    Conversion to/from timeval.
    static timeval
    TimestampToTimeval(const Timestamp & value)
    static Duration
    TimevalToDuration(const timeval & value)
    static timeval
    DurationToTimeval(const Duration & value)

    const int64_t TimeUtil::kTimestampMinSeconds = = -62135596800LL

    The min/max Timestamp/Duration values we support.

    For "0001-01-01T00:00:00Z".

    +

    #include <google/protobuf/util/time_util.h>
    namespace google::protobuf::util

    Defines utilities for the Timestamp and Duration well known types.

    Classes in this file

    Utility functions for Timestamp and Duration.

    class TimeUtil

    #include <google/protobuf/util/time_util.h>
    namespace google::protobuf::util

    Utility functions for Timestamp and Duration.

    Members

    const int64_t
    kTimestampMinSeconds = = -62135596800LL
    The min/max Timestamp/Duration values we support. more...
    const int64_t
    kTimestampMaxSeconds = = 253402300799LL
    For "9999-12-31T23:59:59.999999999Z".
    const int64_t
    kDurationMinSeconds = = -315576000000LL
    const int64_t
    kDurationMaxSeconds = = 315576000000LL
    static std::string
    ToString(const Timestamp & timestamp)
    Converts Timestamp to/from RFC 3339 date string format. more...
    static bool
    FromString(const std::string & value, Timestamp * timestamp)
    static std::string
    ToString(const Duration & duration)
    Converts Duration to/from string format. more...
    static bool
    FromString(const std::string & value, Duration * timestamp)
    static Timestamp
    GetCurrentTime()
    Gets the current UTC time.
    static Timestamp
    GetEpoch()
    Returns the Time representing "1970-01-01 00:00:00".
    static Duration
    NanosecondsToDuration(int64_t nanos)
    Converts between Duration and integer types. more...
    static Duration
    MicrosecondsToDuration(int64_t micros)
    static Duration
    MillisecondsToDuration(int64_t millis)
    static Duration
    SecondsToDuration(int64_t seconds)
    static Duration
    MinutesToDuration(int64_t minutes)
    static Duration
    HoursToDuration(int64_t hours)
    static int64_t
    DurationToNanoseconds(const Duration & duration)
    Result will be truncated towards zero. more...
    static int64_t
    DurationToMicroseconds(const Duration & duration)
    static int64_t
    DurationToMilliseconds(const Duration & duration)
    static int64_t
    DurationToSeconds(const Duration & duration)
    static int64_t
    DurationToMinutes(const Duration & duration)
    static int64_t
    DurationToHours(const Duration & duration)
    static Timestamp
    NanosecondsToTimestamp(int64_t nanos)
    Creates Timestamp from integer types. more...
    static Timestamp
    MicrosecondsToTimestamp(int64_t micros)
    static Timestamp
    MillisecondsToTimestamp(int64_t millis)
    static Timestamp
    SecondsToTimestamp(int64_t seconds)
    static int64_t
    TimestampToNanoseconds(const Timestamp & timestamp)
    Result will be truncated down to the nearest integer value. more...
    static int64_t
    TimestampToMicroseconds(const Timestamp & timestamp)
    static int64_t
    TimestampToMilliseconds(const Timestamp & timestamp)
    static int64_t
    TimestampToSeconds(const Timestamp & timestamp)
    static Timestamp
    TimeTToTimestamp(time_t value)
    Conversion to/from other time/date types. more...
    static time_t
    TimestampToTimeT(const Timestamp & value)
    static Timestamp
    TimevalToTimestamp(const timeval & value)
    Conversion to/from timeval.
    static timeval
    TimestampToTimeval(const Timestamp & value)
    static Duration
    TimevalToDuration(const timeval & value)
    static timeval
    DurationToTimeval(const Duration & value)

    const int64_t TimeUtil::kTimestampMinSeconds = = -62135596800LL

    The min/max Timestamp/Duration values we support.

    For "0001-01-01T00:00:00Z".


    static std::string TimeUtil::ToString(
            const Timestamp & timestamp)

    Converts Timestamp to/from RFC 3339 date string format.

    Generated output will always be Z-normalized and uses 3, 6 or 9 fractional digits as required to represent the exact time. When parsing, any fractional digits (or none) and any offset are accepted as long as they fit into nano-seconds precision. Note that Timestamp can only represent time from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. Converting a Timestamp outside of this range is undefined behavior. See https://www.ietf.org/rfc/rfc3339.txt.

    Example of generated format:

    diff --git a/content/reference/cpp/api-docs/google.protobuf.util.type_resolver.md b/content/reference/cpp/api-docs/google.protobuf.util.type_resolver.md index 4866f95f..ac056c98 100644 --- a/content/reference/cpp/api-docs/google.protobuf.util.type_resolver.md +++ b/content/reference/cpp/api-docs/google.protobuf.util.type_resolver.md @@ -8,6 +8,6 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/util/type_resolver.h>
    namespace google::protobuf::util

    Defines a TypeResolver for the Any message.

    Classes in this file

    Abstract interface for a type resolver.

    class TypeResolver

    #include <google/protobuf/util/type_resolver.h>
    namespace google::protobuf::util

    Abstract interface for a type resolver.

    Implementations of this interface must be thread-safe.

    +

    #include <google/protobuf/util/type_resolver.h>
    namespace google::protobuf::util

    Defines a TypeResolver for the Any message.

    Classes in this file

    Abstract interface for a type resolver.

    class TypeResolver

    #include <google/protobuf/util/type_resolver.h>
    namespace google::protobuf::util

    Abstract interface for a type resolver.

    Implementations of this interface must be thread-safe.

    Members

    TypeResolver()
    virtual
    ~TypeResolver()
    virtual util::Status
    ResolveMessageType(const std::string & type_url, google::protobuf::Type * message_type) = 0
    Resolves a type url for a message type.
    virtual util::Status
    ResolveEnumType(const std::string & type_url, google::protobuf::Enum * enum_type) = 0
    Resolves a type url for an enum type.
    diff --git a/content/reference/cpp/api-docs/google.protobuf.util.type_resolver_util.md b/content/reference/cpp/api-docs/google.protobuf.util.type_resolver_util.md index aea64a3d..95848a16 100644 --- a/content/reference/cpp/api-docs/google.protobuf.util.type_resolver_util.md +++ b/content/reference/cpp/api-docs/google.protobuf.util.type_resolver_util.md @@ -8,6 +8,6 @@ description = "This section contains reference documentation for working with Pr type = "docs" +++ -

    #include <google/protobuf/util/type_resolver_util.h>
    namespace google::protobuf::util

    Defines utilities for the TypeResolver.

    Classes in this file

    File Members

    These definitions are not part of any class.
    TypeResolver *
    NewTypeResolverForDescriptorPool(const std::string & url_prefix, const DescriptorPool * pool)
    Creates a TypeResolver that serves type information in the given descriptor pool. more...

    TypeResolver * util::NewTypeResolverForDescriptorPool(
            const std::string & url_prefix,
            const DescriptorPool * pool)

    Creates a TypeResolver that serves type information in the given descriptor pool.

    Caller takes ownership of the returned TypeResolver.

    +

    #include <google/protobuf/util/type_resolver_util.h>
    namespace google::protobuf::util

    Defines utilities for the TypeResolver.

    Classes in this file

    File Members

    These definitions are not part of any class.
    TypeResolver *
    NewTypeResolverForDescriptorPool(const std::string & url_prefix, const DescriptorPool * pool)
    Creates a TypeResolver that serves type information in the given descriptor pool. more...

    TypeResolver * util::NewTypeResolverForDescriptorPool(
            const std::string & url_prefix,
            const DescriptorPool * pool)

    Creates a TypeResolver that serves type information in the given descriptor pool.

    Caller takes ownership of the returned TypeResolver.