[C++-sig] [newbie] Pyste overloaded member function problems
Sengan.Baring-Gould at nsc.com
Sengan.Baring-Gould at nsc.com
Thu Jun 26 01:35:06 CEST 2003
Hi,
I am using pyste and boost 1.30.0 to wrap a C++ class which has the following
overloaded member functions:
class Parser {
...
typedef unsigned char CFormatFlags;
const string& Get( string, string, const string&, const CFormatFlags in_flags = DEFAULT_FORMATTING ) const;
long Get( string, string, const long ) const;
int Get( string, string, const int ) const;
const string& Get( string, const string&, const CFormatFlags in_flags = DEFAULT_FORMATTING ) const;
long Get( string, const long ) const;
int Get( string, const int ) const;
...
};
In order to prevent Python from converting Get( string, string, const long )
into const string& Get( string, const string&, CFormatFlags ) I have to hack
the generated file to remove all but the first 2 def() statements corresponding
to the first 2 Gets.
1/ Is there a more elegant method to solve this problem?
2/ Is there a way to tell pyste to exclude particular overloaded member
functions?
3/ Is there a way to specify a policy in pyste dependent on the overloaded
member function: I have
set_policy(CSettingsParser.Get, return_value_policy(copy_const_reference))
but then I have to remove that for the long Get(string, string. long) case
from the generated file.
Secondly, this class has member functions:
class Parser {
...
typedef list<string> CNameList;
CNameList List( void ) const;
CNameList List( const string section_name ) const;
... };
In order to get a python list from this I wrote 2 wrapper functions.
However, I can't figure out how to get pyste to use the set_wrapper() functions to use the wrappers. So again I hacked the generated file.
4/ Is there some other way to do this without hacking the generated file?
I would like to congratulate the authors of pyste and boost python. Having
dipped my foot in the water by writing an extension module for
std::list<int>/std::list<string>, I can see this package really reduces the
amount of code one needs to write.
Thanks,
Sengan
More information about the Cplusplus-sig
mailing list