相关疑难解决方法(0)

SWIG如何在Python中包装map <string,string>?

我正在使用SWIG 2.0为C++库创建一个Python包装器.一种方法的参数类型为"const std :: map&".SWIG很高兴为它生成一个包装器,但我无法弄清楚如何调用该方法.例如,如果我为该参数传递{"a":"b"},则会出现"NotImplementedError:重载函数的错误数字或参数类型"错误.

我查看生成的.cxx文件,希望它能澄清,但事实并非如此.这是处理该参数的代码:

res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_std__mapT_std__string_std__string_t,  0  | 0);
if (!SWIG_IsOK(res4)) {
  SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_Context" "', argument " "4"" of type '" "std::map< std::string,std::string > const &""'"); 
}
Run Code Online (Sandbox Code Playgroud)

它清楚地知道论证存在,并且它应该被转换为地图.但我无法弄清楚它实际上是希望我传递给它的.

c++ python swig stl

9
推荐指数
1
解决办法
6674
查看次数

标签 统计

c++ ×1

python ×1

stl ×1

swig ×1