Iterating over std :: map in PHP using SWIG

I use SWIG to port a function that returns std::map in PHP.

In the PHP code, I need to iterate over the map elements.

The Thw SWIG library provides support for std::map using the std_map.i interface std_map.i , but only the following methods are wrapped:

  clear() del($key) get($key) has_key($key) is_empty() set($key, $x) size() 

How can I iterate over map elements? Should I extend the std_map.i file with some kind of wrappers for iterators and begin() and end() ?

+8
c ++ php map swig
source share
1 answer

As @awoodland said, you have to implement an iterator interface.

Here is another question about stackoverflow. Although this is java, it can give you a better idea of ​​what you are looking for:

There is no iterator for Java when using SWIG with std :: map in C ++

+1
source share

All Articles