template class proto_python_bindings¶
Overview¶
Class implementing python wrappers for protobuf Message types. More…
#include <proto_python_bindings.h> template <class MSG_TYPE, class ... FIELD_MSG_TYPES> class proto_python_bindings { public: // methods static void throw_python_error(PyObject* error, std::string msg); static bpy::object GetAttribute(MSG_TYPE& m, char const* name); static void SetAttribute( MSG_TYPE& m, char const* name, const bpy::object& value ); static bpy::object WhichOneof(MSG_TYPE& m, char const* name); static void ClearField(MSG_TYPE& m, char const* name); static bool HasField(MSG_TYPE& m, char const* name); static bpy::list GetFieldNames(MSG_TYPE& m); static bpy::str GetFieldTypeName(MSG_TYPE& m, char const* name); static bpy::class_<MSG_TYPE> create(); };
Detailed Documentation¶
Class implementing python wrappers for protobuf Message types.
The main access point is “create”, which effectively creates bindings for a MSG_TYPE class. The generated Python class resembles the original Protobuf Python API as described here:
https://developers.google.com/protocol-buffers/docs/reference/python-generated
https://googleapis.dev/python/protobuf/latest/google/protobuf/message.html
with the next limitations:
Well Known Types not supported (yet) https://developers.google.com/protocol-buffers/docs/reference/python-generated#wkt
Repeated Message field not supported (yet) https://developers.google.com/protocol-buffers/docs/reference/python-generated#repeated-message-fields
Map field type not supported (yet) https://developers.google.com/protocol-buffers/docs/reference/python-generated#map-fields
Basic Enum support. Enum fields get/set works with int. Enum constants can’t be accessed from python https://developers.google.com/protocol-buffers/docs/reference/python-generated#enum
Message Python wrapper supports only the a subset of the methods listed here https://googleapis.dev/python/protobuf/latest/google/protobuf/message.html (see “create” method)
Methods¶
static bpy::object GetAttribute(MSG_TYPE& m, char const* name)
getattr
static void SetAttribute( MSG_TYPE& m, char const* name, const bpy::object& value )
setattr
static bpy::object WhichOneof(MSG_TYPE& m, char const* name)
WhichOneof.
static void ClearField(MSG_TYPE& m, char const* name)
ClearField.
static bool HasField(MSG_TYPE& m, char const* name)
HasField.
static bpy::list GetFieldNames(MSG_TYPE& m)
GetFieldNames.
static bpy::str GetFieldTypeName(MSG_TYPE& m, char const* name)
GetFieldTypeName.
static bpy::class_<MSG_TYPE> create()
Creates bindings for Protobuf Message type MSG_TYPE.