C++ -> CSharp usage of std_map.i ?

View: New views
3 Messages — Rating Filter:   Alert me  

C++ -> CSharp usage of std_map.i ?

by kentavr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I am new to swig and here is the question:

I am looking for example how I can use specialized templates defined in std_map.i.
It looks like that template specialize_std_map_on_both can solve my problem. (may be not)
My function in C++ returns std::map<std::string,double> foo();
declared in my.i file as

%include "C:\swig\swigwin-1.3.39\swigwin-1.3.39\Lib\csharp\std_map.i"
%template(DoubleMap) std::map<std::string,double>;

When I am trying to access values in this map from C# the return type is not "double".
I had to do this:
 SWIGTYPE_p_double swD = myMap.get(s);
I bet that there should be an easy way to export pure doubles.

Thanks for any help,
Sergey

Re: C++ -> CSharp usage of std_map.i ?

by wsfulton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

kentavr wrote:

> Hi All,
>
> I am new to swig and here is the question:
>
> I am looking for example how I can use specialized templates defined in
> std_map.i.
> It looks like that template specialize_std_map_on_both can solve my problem.
> (may be not)
> My function in C++ returns std::map<std::string,double> foo();
> declared in my.i file as
>
> %include "C:\swig\swigwin-1.3.39\swigwin-1.3.39\Lib\csharp\std_map.i"
> %template(DoubleMap) std::map<std::string,double>;
>
> When I am trying to access values in this map from C# the return type is not
> "double".
> I had to do this:
>  SWIGTYPE_p_double swD = myMap.get(s);
> I bet that there should be an easy way to export pure doubles.
>
> Thanks for any help,
> Sergey
std::map was radically overhauled for C# in 1.3.40. Please try this
updated version.

William

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: C++ -> CSharp usage of std_map.i ?

by kentavr :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks a lot for the advice.
Map in 1.3.40 works like a charm.

wsfulton wrote:
kentavr wrote:
> Hi All,
>
> I am new to swig and here is the question:
>
> I am looking for example how I can use specialized templates defined in
> std_map.i.
> It looks like that template specialize_std_map_on_both can solve my problem.
> (may be not)
> My function in C++ returns std::map<std::string,double> foo();
> declared in my.i file as
>
> %include "C:\swig\swigwin-1.3.39\swigwin-1.3.39\Lib\csharp\std_map.i"
> %template(DoubleMap) std::map<std::string,double>;
>
> When I am trying to access values in this map from C# the return type is not
> "double".
> I had to do this:
>  SWIGTYPE_p_double swD = myMap.get(s);
> I bet that there should be an easy way to export pure doubles.
>
> Thanks for any help,
> Sergey
std::map was radically overhauled for C# in 1.3.40. Please try this
updated version.

William

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Swig-user mailing list
Swig-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user