Added extract_traceback function

Create a C++ traceback from a boost::python object. Refactored get_exception_info() to return a struct of boost::python::objects instead of a tuple with magic knowledge in it. Also refactored and modularized tests some more.
Do what you think is best.


On Fri, Aug 15, 2014 at 2:16 PM, MathMagique <notifications@github.com>
wrote:

> In src/boost_python_exception/traceback_step.hpp:
>
> > @@ -0,0 +1,39 @@
> > +#ifndef INCLUDE_BOOST_PYTHON_EXCEPTION_TRACEBACK_STEP_H
> > +#define INCLUDE_BOOST_PYTHON_EXCEPTION_TRACEBACK_STEP_H
> > +
> > +#include <iosfwd>
> > +#include <string>
> > +
> > +namespace boost_python_exception {
> > +
> > +/*
> > + * @brief Represents a single step of a python traceback.
> > + */
> > +struct traceback_step
>
> Sorry for reopening the discussion once again, even though I said I would
> not:
>
> When I try to make the members const, I run into this issue when
> extracting the traceback:
>
> http://stackoverflow.com/questions/4124271/stdvector-of-objects-and-const-correctness
> Basically, I try to push values with const members into a vector. This
> does not work, because this requires an assignment operator. Try assigning
> const values...
>
> So I cannot make the members const (I do not want to build vectors of
> smart pointers to traceback_steps), but I could add a constructor +
> accessors to const references of the members. This would work fine, but
> introduce additional code:
>
>    - constructor code
>    - constructor test code
>    - accessor code
>    - accessor test code Everything trivial, of course, but nevertheless
>    code which I don't want to write when the compiler can generate everything
>    I need if I just make the members of the struct non-const.
>
> Considering this, I think it is the best option to make members of structs
> mutable.
>
>    - If users want to modify values, I let them do it.
>    - If users need not modify values, I still let them do it.
>    - If users must not modify values:
>       - Do not use a struct, but a class with private members and const
>       accessors
>       - Return (references to) const instances of structs, because
>       members of const instances are const as well.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/abingham/boost_python_exception/pull/10/files#r16289748>
> .
>