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:

with the next limitations:

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.