DCCL v4
|
Helper class for creating google::protobuf::Message objects that are not statically compiled into the application. More...
#include <dccl/dynamic_protobuf_manager.h>
Public Member Functions | |
DynamicProtobufManager (const DynamicProtobufManager &)=delete | |
DynamicProtobufManager & | operator= (const DynamicProtobufManager &)=delete |
Static Public Member Functions | |
static const google::protobuf::Descriptor * | find_descriptor (const std::string &protobuf_type_name, bool user_pool_first=false) |
Finds the Google Protobuf Descriptor (essentially a meta-class for a given Message) from a given Message name. More... | |
template<typename GoogleProtobufMessagePointer > | |
static GoogleProtobufMessagePointer | new_protobuf_message (const std::string &protobuf_type_name, bool user_pool_first=false) |
Create a new (empty) Google Protobuf message of a given type by name. More... | |
template<typename GoogleProtobufMessagePointer > | |
static GoogleProtobufMessagePointer | new_protobuf_message (const google::protobuf::Descriptor *desc) |
Create a new (empty) Google Protobuf message of a given type by Descriptor. More... | |
static std::shared_ptr< google::protobuf::Message > | new_protobuf_message (const google::protobuf::Descriptor *desc) |
Create a new (empty) Google Protobuf message of a given type by Descriptor. More... | |
static std::shared_ptr< google::protobuf::Message > | new_protobuf_message (const std::string &protobuf_type_name) |
Create a new (empty) Google Protobuf message of a given type by name. More... | |
static void | add_database (std::shared_ptr< google::protobuf::DescriptorDatabase > database) |
Add a Google Protobuf DescriptorDatabase to the set of databases searched for Message Descriptors. | |
static void | enable_compilation () |
Enable on the fly compilation of .proto files on the local disk. Must be called before load_from_proto_file() is called. | |
static const google::protobuf::FileDescriptor * | load_from_proto_file (const std::string &protofile_absolute_path) |
Load a message from a .proto file on the disk. enable_compilation() must be called first. More... | |
static void | add_include_path (const std::string &path) |
Add a path for searching for import messages when loading .proto files using load_from_proto_file() More... | |
static void * | load_from_shared_lib (const std::string &shared_lib_path) |
Load compiled .proto files from a UNIX shared library (i.e. *.so or *.dylib) More... | |
static void | protobuf_shutdown () |
static const google::protobuf::FileDescriptor * | add_protobuf_file (const google::protobuf::FileDescriptorProto &proto) |
Add a protobuf file defined in a google::protobuf::FileDescriptorProto. | |
static void | reset () |
static void | custom_deleter (DynamicProtobufManager *obj) |
static google::protobuf::DynamicMessageFactory & | msg_factory () |
static google::protobuf::DescriptorPool & | user_descriptor_pool () |
static google::protobuf::SimpleDescriptorDatabase & | simple_database () |
template<typename ReturnType , typename... Args1, typename... Args2> | |
static ReturnType | msg_factory_call (ReturnType(google::protobuf::DynamicMessageFactory::*func)(Args1...) const, Args2... args) |
template<typename ReturnType , typename... Args1, typename... Args2> | |
static ReturnType | user_descriptor_pool_call (ReturnType(google::protobuf::DescriptorPool::*func)(Args1...) const, Args2... args) |
template<typename ReturnType , typename... Args1, typename... Args2> | |
static ReturnType | simple_database_call (ReturnType(google::protobuf::SimpleDescriptorDatabase::*func)(Args1...) const, Args2... args) |
Helper class for creating google::protobuf::Message objects that are not statically compiled into the application.
Definition at line 47 of file dynamic_protobuf_manager.h.
|
static |
Add a path for searching for import messages when loading .proto files using load_from_proto_file()
Exception | If enable_compilation() has not been called before using this function. |
Definition at line 87 of file dynamic_protobuf_manager.cpp.
|
static |
Finds the Google Protobuf Descriptor (essentially a meta-class for a given Message) from a given Message name.
protobuf_type_name | The fully qualified name of the Google Protobuf Message including package name. E.g. in the .proto file: package dccl.protobuf
message A { }
|
user_pool_first | Search the user pool first, then the generated (compiled-in) pool (useful in case the generated pool is missing extensions that are in the user pool) |
Definition at line 37 of file dynamic_protobuf_manager.cpp.
|
static |
Load a message from a .proto file on the disk. enable_compilation() must be called first.
protofile_absolute_path | It is critical that the argument be the absolute, canonical path to the file. (No relative paths and no "." or "..") This could be achieved, e.g., by using Boost filesystem as follows... boost::filesystem::path abs_path = boost::filesystem::complete(rel_path);
abs_path.normalize();
|
Exception | If enable_compilation() has not been called before using this function |
Exception | If any error exists in locating or parsing this .proto file. |
It is critical that the argument be the absolute, canonical path to the file. This could be achieved, e.g., by using Boost filesystem as follows... boost::filesystem::path abs_path = boost::filesystem::complete(rel_path); abs_path.normalize();
Definition at line 113 of file dynamic_protobuf_manager.cpp.
|
static |
Load compiled .proto files from a UNIX shared library (i.e. *.so or *.dylib)
shared_lib_path | Path to shared library. May be relative if known by ld.so |
Definition at line 98 of file dynamic_protobuf_manager.cpp.
|
inlinestatic |
Create a new (empty) Google Protobuf message of a given type by Descriptor.
desc | The Google Protobuf Descriptor of the message to create. |
GoogleProtobufMessagePointer | A pointer or anything that acts like a pointer (has operator*()) to a google::protobuf::Message |
Definition at line 99 of file dynamic_protobuf_manager.h.
|
static |
Create a new (empty) Google Protobuf message of a given type by Descriptor.
desc | The Google Protobuf Descriptor of the message to create. |
Definition at line 66 of file dynamic_protobuf_manager.cpp.
|
static |
Create a new (empty) Google Protobuf message of a given type by name.
protobuf_type_name | The full name (including package) of the Google Protobuf message to create (e.g. "package.MyMessage"). |
Definition at line 73 of file dynamic_protobuf_manager.cpp.
|
inlinestatic |
Create a new (empty) Google Protobuf message of a given type by name.
protobuf_type_name | The fully qualified name of the Google Protobuf Message including package name. E.g. in the .proto file: package dccl.protobuf
message A { }
|
GoogleProtobufMessagePointer | A pointer or anything that acts like a pointer (has operator*()) to a google::protobuf::Message |
Definition at line 77 of file dynamic_protobuf_manager.h.