|
From: Mr z. wo <se...@ya...> - 2011-02-02 02:09:14
|
my sample source code.
c++ :
void do_something( map<string, string>* mymap )
{
// assign values to my map
mymap->insert( make_pair("key_1", "value_1") );
mymap->insert( make_pair("key_2", "value_2") );
}
---------------
perl code :
my %hash = ();
myswig::do_something( $wrapper, \%hash);
# to display assigned hash values
---------------
swig perl API :
%template(stringstringMap) std::map<std::string, std::string>;
%perlcode
%{
sub do_something {
my ($wrapper, $hash_ref)=@_;
my $map_results = new myswig::stringstringMap;
# call c++ API
$wrapper->do_something( $map_results );
# need to convert map in c++ to hash, the problem is, how to do iteration here for a map?
# I need foreach function.
}
%}
-----------
Thanks,
-Jim
|