.. index:: pair: class; proto_python_bindings .. _doxid-classproto__python__bindings: template class proto_python_bindings ==================================== .. toctree:: :hidden: Overview ~~~~~~~~ Class implementing python wrappers for protobuf Message types. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class proto_python_bindings { public: // methods static void :target:`throw_python_error`(PyObject* error, std::string msg); static bpy::object :ref:`GetAttribute`(MSG_TYPE& m, char const* name); static void :ref:`SetAttribute`( MSG_TYPE& m, char const* name, const bpy::object& value ); static bpy::object :ref:`WhichOneof`(MSG_TYPE& m, char const* name); static void :ref:`ClearField`(MSG_TYPE& m, char const* name); static bool :ref:`HasField`(MSG_TYPE& m, char const* name); static bpy::list :ref:`GetFieldNames`(MSG_TYPE& m); static bpy::str :ref:`GetFieldTypeName`(MSG_TYPE& m, char const* name); static bpy::class_ :ref:`create`(); }; .. _details-classproto__python__bindings: 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: * 1. Well Known Types not supported (yet) `https://developers.google.com/protocol-buffers/docs/reference/python-generated#wkt `__ * 2. Repeated Message field not supported (yet) `https://developers.google.com/protocol-buffers/docs/reference/python-generated#repeated-message-fields `__ * 3. Map field type not supported (yet) `https://developers.google.com/protocol-buffers/docs/reference/python-generated#map-fields `__ * 4. 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 `__ * 5. 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 ------- .. index:: pair: function; GetAttribute .. _doxid-classproto__python__bindings_1a0b9554d151e81c700cca465e68f19372: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bpy::object GetAttribute(MSG_TYPE& m, char const* name) **getattr** .. index:: pair: function; SetAttribute .. _doxid-classproto__python__bindings_1a267a482f49a0bcbb325723c1c3fd49b9: .. ref-code-block:: cpp :class: doxyrest-title-code-block static void SetAttribute( MSG_TYPE& m, char const* name, const bpy::object& value ) **setattr** .. index:: pair: function; WhichOneof .. _doxid-classproto__python__bindings_1a11a6a51d80aa68f2cd93c1a44a72d83c: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bpy::object WhichOneof(MSG_TYPE& m, char const* name) WhichOneof. .. index:: pair: function; ClearField .. _doxid-classproto__python__bindings_1a711d88c66090b6d50bc9920ae18fcbab: .. ref-code-block:: cpp :class: doxyrest-title-code-block static void ClearField(MSG_TYPE& m, char const* name) ClearField. .. index:: pair: function; HasField .. _doxid-classproto__python__bindings_1aed64f1dd4fd7eedf1b8e8f3ae76448c5: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool HasField(MSG_TYPE& m, char const* name) HasField. .. index:: pair: function; GetFieldNames .. _doxid-classproto__python__bindings_1aa1ca287897b05d1501cf109f14352e99: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bpy::list GetFieldNames(MSG_TYPE& m) GetFieldNames. .. index:: pair: function; GetFieldTypeName .. _doxid-classproto__python__bindings_1a50854cb67fd2cb5177e7ab6a22aaa02f: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bpy::str GetFieldTypeName(MSG_TYPE& m, char const* name) GetFieldTypeName. .. index:: pair: function; create .. _doxid-classproto__python__bindings_1a41062a4ea1d09ea4ae1ed3e7f966fd90: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bpy::class_ create() Creates bindings for Protobuf Message type MSG_TYPE.