Re: [C++-sig] How to hangle a NULL pointer?

2012-10-02 Thread Stefan Seefeld
On 10/02/2012 12:29 PM, Luiz Vitor Martinez Cardoso wrote: > > All the members are initialized to 0 or NULL if it's a pointer. > > The problem is that I'm getting a "Segmentation Fault" message when I > try to access the pointers members from Python. Can you elaborate on what you want to happen in

Re: [C++-sig] How to hangle a NULL pointer?

2012-10-02 Thread Luiz Vitor Martinez Cardoso
Stefan, Thank you! To clarify my explanation... the pointer declarations are members from a class called FaceObject. qint32 * gender; float * age; float * ageDeviationDen; quint32 * happy; quint32 * sad; quint32 * surprised; quint32 * angry; Depending on the software

Re: [C++-sig] How to hangle a NULL pointer?

2012-10-02 Thread Luiz Vitor Martinez Cardoso
Stefan, I would like to do on the Python side: t = faceparser.FaceObject() if (t.gender = None): print 'gender is not defined' else: print gender Best regards, Luiz Vitor. On Tue, Oct 2, 2012 at 1:44 PM, Luiz Vitor Martinez Cardoso < [email protected]> wrote: > Stefan, > > Thank you! > >

Re: [C++-sig] How to hangle a NULL pointer?

2012-10-02 Thread Stefan Seefeld
I would write little wrapper functions that check the pointer, and if it's NULL, return None instead of the dereferenced value. To illustrate: object get_age(FaceObject &f) { return f.getAge() ? object(*f.getAge()) : object();} ... class_(...).add_property("age", get_age); Thus, if the

Re: [C++-sig] How to hangle a NULL pointer?

2012-10-02 Thread Jeffrey Van Voorst
You might want to use wrapper functions in C++ boost::python::object gender_getter(const FaceObject& obj) { if(obj.gender == NULL) return Py_None; else return obj.gender; } Note: its been a bit since I used Boost.Python heavily. The syntax could be incorrect, but I hope this gives you a ge

Re: [C++-sig] How to hangle a NULL pointer?

2012-10-02 Thread Luiz Vitor Martinez Cardoso
Stefan/Jeffrey, Thank you, it's now working perfectly... but I have another issue. I wrote: object get_py_gender(const FaceObject &fobj) > { > return fobj.gender ? object(*fobj.gender) : object(); > } > object get_py_age(const FaceObject &fobj) > { > return fobj.age ? object(*fobj.age) :