logo       

Re: std::map problem: msg#00183

programming.swig

Subject: Re: std::map problem

Looking at java/std_map.i, I see that get() returns a non-const reference
to the object, so the std_string.i conversion to a native java string
won't apply (it would to a const ref). Furthermore, since std_string.i
doesn't actually declare a string class, you get something you can't do
much with. A number of options come to mind: 1. Declare a string class
that does useful things, including a method to give you a java string.
2. Give map<> (from swig's point of view) a method that returns a const
reference. You could just change the return type of get(), but you would
lose the ability to alter elements of your maps. Perhaps const T& get()
and T& set() would be appropriate; I've only glanced at the file. 3. Use
the specialize_std_map* macros in std_map.i, with an appropriate value of
CONVERT_FROM.

Josh

--
Joshua L. Cherry, Ph.D.
NCBI/NLM/NIH (Contractor)
jcherry@xxxxxxxxxxxxxxxx


On Fri, 28 May 2004, Rob Roy wrote:

> I am using a std::map in C++ of the following form
>
> std::map<std::string, std::string>
>
> which I am trying to translated to Java using SWIG.
>
>
>
> SWIG does not translate the return value of the get() method of the map
> class found in std_map.i to a java.lang.String. Instead it is creating a
> class called SWIGTYPE_p_std__string.java. I have included both
> std_string.i
> and std_map.i in my .i file. What can I do to fix this?
>
>
>
> Thanks,
>
> Rob
_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise