<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2657.73">
<TITLE>Wrapping class methods with array parameters</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2 FACE="Arial">I am in the process of wrapping two C++ classes, each of which has at least one method which takes a pointer, which is really the first item in an array of known length. My problem is I don't see how to do it! Given that Boost Python is so robust, I suspect I've missed something in all the documentation, or perhaps I read it and did not grasp its relevance.</FONT></P>
<P><FONT SIZE=2 FACE="Arial">Here is one of the classes/methods:</FONT>
<BR><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">class</FONT><FONT SIZE=2 FACE="Courier New"> </FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">scifidict</FONT>
<BR><FONT SIZE=2 FACE="Courier New">{</FONT>
<BR><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">public</FONT><FONT SIZE=2 FACE="Courier New">:</FONT>
<BR> <FONT SIZE=2 FACE="Arial">/* a bunch of stuff */</FONT>
<BR><FONT COLOR="#000000" SIZE=2 FACE="Courier New">size_t</FONT><FONT SIZE=2 FACE="Courier New"> </FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">getOwners</FONT><FONT SIZE=2 FACE="Courier New">(</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">string</FONT><FONT SIZE=2 FACE="Courier New">* </FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">ps</FONT><FONT SIZE=2 FACE="Courier New"> = </FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">NULL</FONT><FONT SIZE=2 FACE="Courier New">)</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> </FONT><FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">throw</FONT><FONT SIZE=2 FACE="Courier New"> (</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">invalid_argument</FONT><FONT SIZE=2 FACE="Courier New">);</FONT>
</P>
<P> <FONT SIZE=2 FACE="Courier New">/* more fun stuff */</FONT>
<BR><FONT SIZE=2 FACE="Courier New">};</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">The other C++ class' method is similar, but it uses an array of integers as one of its arguments.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">In the above method, ps is a std::string array passed in by the caller, which getOwners() than proceeds to populate. It works fine in C++. I've made numerous attempts to get code that works for Python, and either the code did not compile, or it did compile but then Python didn't like the method when I tried to execute it ("TypeError: bad argument type for built-in operation").</FONT></P>
<P><FONT SIZE=2 FACE="Arial">What is the proper way to wrap array arguments so the data can be passed back and forth between C++ and Python?</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Thanks in advance for the help.</FONT>
</P>
</BODY>
</HTML>