【发布时间】:2013-11-12 10:11:13
【问题描述】:
我正在使用 boost python 来实现 C++ 和 Python 之间的互操作性。我在 c++ 中有枚举和结构,并且在 c++ 中有可以将这些结构作为参数的函数。我可以通过使用 boost python 在 python 中访问这个函数,但我不知道如何在 python 中将结构作为参数发送。 Set 是 c++ 中的函数,可以将结构作为参数获取。所以在 python 中,我如何将此结构作为参数发送。我能够在 python 中获得此功能,但无法将发送结构作为参数发送。感谢您的帮助。
c++结构如下:
enum days
{
friday,
saturday
};
struct example
{
days m_day;
std: string m_value;
};
Class Base
{
public:
void Set(example& Result) = 0;
}
class Derived
{
public:
void Set(example& Result)
{
Result.m_day = friday;
}
【问题讨论】:
-
不,我想将结构作为 pyrameter 从 python 发送到 c++。
-
也许这对你有帮助? send-receive-cstruct-using-python
-
如何从 python 发送空结构,它可以评估 c++ 的 Structurevalue?无法从 python 发送结构
-
通过
boost::python::enum和boost::python::class_公开枚举和结构。 Boost.Python 将处理结构和相关 Python 类型之间的转换。 -
问题是我如何从 python 发送空结构,它可以访问 c++ 中的结构。
标签: c++ python boost-python