在PHP中使用SWIG迭代std :: map [英] Iterating over std::map in PHP with SWIG
问题描述
我使用SWIG封装在PHP中返回 std :: map
的函数。
I am using SWIG to wrap a function that returns an std::map
in PHP.
PHP代码,我需要迭代地图的元素。
In the PHP code, I need to iterate over the elements of the map.
Thw SWIG库支持 std :: map
与 std_map.i
接口文件,但只有以下方法包装:
Thw SWIG library provides support for std::map
with the std_map.i
interface file, but only the following methods are wrapped:
clear()
del($key)
get($key)
has_key($key)
is_empty()
set($key, $x)
size()
如何迭代地图?我需要扩展 std_map.i
文件与某些类型的包装器的迭代器和 begin()
和 end()
?
How can I iterate over the elements of the map? Would I need to extend the std_map.i
file with some sort of wrappers for iterators and begin()
and end()
?
推荐答案
迭代器接口。
这里是stackoverflow的另一个问题。虽然它是java,它可以让你更好地了解你正在寻找什么:
Here is another question on stackoverflow. Although it is java it can give you a better idea of what you are looking for:
No iterator for Java when using swig with c++ and std::map
这篇关于在PHP中使用SWIG迭代std :: map的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!