Re: [C++-sig] TypeError: No to_python (by-value) converter found for C++ type: class std::basic_ostream >

2010-09-29 Thread Jakub Zytka
> I get this error: > *TypeError: No to_python (by-value) converter found for C++ type: class > std::basic_ostream >* > > This is the python function > *def serialise(self, gameobj, file): > if(gameobj in self.components): > file.write("HEY", 3)* > > What's the problem h

[C++-sig] Read and write byte streams python<-->c++

2010-09-29 Thread Simon W
Hey, I'm trying to serialise some data. I have a c++ class: class ostream { std::ostream& stream; public: ostream(std::ostream& s) : stream(s) {} void write(const char* bytes, Uint32 count) { stream.write(byte

Re: [C++-sig] TypeError: No to_python (by-value) converter found for C++ type: class std::basic_ostream >

2010-09-29 Thread Simon W
Thank you for the answer. Is there any way I can prevent it from copying the stream object even though std::ostream::write() returns a std::ostream& ? On Wed, Sep 29, 2010 at 11:38 AM, Jakub Zytka wrote: > > > I get this error: > > *TypeError: No to_python (by-value) converter found for C++ type

Re: [C++-sig] TypeError: No to_python (by-value) converter found for C++ type: class std::basic_ostream >

2010-09-29 Thread Jakub Zytka
On 09/29/10 14:11, Simon W wrote: Thank you for the answer. Is there any way I can prevent it from copying the stream object even though std::ostream::write() returns a std::ostream& ? You can use other return policy, or define one on your own. http://www.boost.org/doc/libs/1_44_0/libs/python/d

[C++-sig] Derivation from Python str

2010-09-29 Thread Willi Karel
I'd like to derive from either Python's built-in 'str' or boost::python::str, resulting in a class that provides additional methods / member functions / attributes. The definitions of these additional methods are implemented in C++. Is there any way to achieve that? Please note that implicit conver

Re: [C++-sig] Derivation from Python str

2010-09-29 Thread Hans Meine
Am Mittwoch 29 September 2010, 17:02:57 schrieb Willi Karel: > I'd like to derive from either Python's built-in 'str' or > boost::python::str, resulting in a class that provides additional > methods / member functions / attributes. [...] AFAIK this is just an unsupported feature of the BPL. I was

Re: [C++-sig] Derivation from Python str

2010-09-29 Thread Jim Bosch
On 09/29/2010 09:01 AM, Hans Meine wrote: Am Mittwoch 29 September 2010, 17:02:57 schrieb Willi Karel: I'd like to derive from either Python's built-in 'str' or boost::python::str, resulting in a class that provides additional methods / member functions / attributes. [...] AFAIK this is just a

Re: [C++-sig] Derivation from Python str

2010-09-29 Thread Willi Karel
Dear Hans and Jim, thanks a lot for your replies! I tried to wrap/def boost::python::str's methods for my derived class, which is possible in a quite compact way using boost::function_types and some templates. However, I quit my attempt when it came to operators - too much work for now. Cheers,