Using RTI/XML

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
zobbo
Experienced Solver
Experienced Solver
Posts: 58
Joined: Sat Aug 18, 2007 4:41 am

Using RTI/XML

Post by zobbo » Fri Oct 25, 2013 9:25 am

Hi, I'm trying to use RTI to serialize an object. I realise it's experimental, but wondered if anyone had come across this issue. I'm using wxwidgets 2.9 with wxUSE_EXTENDED_RTTI =1. But I can't see any trace of IMPLEMENT_DYNAMIC_CLASS_XTI anywhere. Maybe I'm missing something obvious, I'm not sure. So for the below code I get a syntax error string for the "person.h" bit. But I can't see the IMPLEMENT_DYNAMIC_CLASS_XTI macro anywhere in the RTI code (and neither can VC++2012 by the looks of it). It's just a copy of http://wiki.wxwidgets.org/Object_serial ... TI_and_XML .

Code: Select all

#include "person.h"

#include "wx/xml/xml.h"
#include "wx/xtistrm.h"
#include "wx/xtixml.h"
 
#if wxUSE_EXTENDED_RTTI
	IMPLEMENT_DYNAMIC_CLASS_XTI(wxPerson, wxObject, "person.h")	
 
	wxBEGIN_PROPERTIES_TABLE(wxPerson)
		wxPROPERTY( Age, int, SetAge, GetAge, 3, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
	wxEND_PROPERTIES_TABLE()
 
	wxBEGIN_HANDLERS_TABLE(wxPerson)
	wxEND_HANDLERS_TABLE()
 
	wxCONSTRUCTOR_1(wxPerson, int, Age)
#else
	IMPLEMENT_DYNAMIC_CLASS(wxPerson, wxObject)
#endif
Cheers,
Zobbo
Zobbo

Wxwidgets 2.9.0, Visual C++ Express 2005, Windows Vista x64 Home Premium

User avatar
doublemax
Moderator
Moderator
Posts: 14100
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Using RTI/XML

Post by doublemax » Fri Oct 25, 2013 11:51 pm

The macro is called wxIMPLEMENT_DYNAMIC_CLASS_XTI (note the "wx" at the beginning).
Use the source, Luke!

zobbo
Experienced Solver
Experienced Solver
Posts: 58
Joined: Sat Aug 18, 2007 4:41 am

Re: Using RTI/XML

Post by zobbo » Sat Oct 26, 2013 4:11 am

doublemax wrote:The macro is called wxIMPLEMENT_DYNAMIC_CLASS_XTI (note the "wx" at the beginning).
Doh...thanks for that. :oops:

Cheers,
Zobbo
Zobbo

Wxwidgets 2.9.0, Visual C++ Express 2005, Windows Vista x64 Home Premium

zobbo
Experienced Solver
Experienced Solver
Posts: 58
Joined: Sat Aug 18, 2007 4:41 am

Re: Using RTI/XML

Post by zobbo » Sat Oct 26, 2013 4:13 am

So it looks like the wiki is wrong because I just copied it, this is pasted from the wiki:

Code: Select all

#include "person.h"
 
#if wxUSE_EXTENDED_RTTI
	IMPLEMENT_DYNAMIC_CLASS_XTI(wxPerson, wxObject, "person.h")	
 
	wxBEGIN_PROPERTIES_TABLE(wxPerson)
		wxPROPERTY( Age, int, SetAge, GetAge, 3, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
	wxEND_PROPERTIES_TABLE()
 
	wxBEGIN_HANDLERS_TABLE(wxPerson)
	wxEND_HANDLERS_TABLE()
 
	wxCONSTRUCTOR_1(wxPerson, int, Age)
#else
	IMPLEMENT_DYNAMIC_CLASS(wxPerson, wxObject)
#endif
Zobbo

Wxwidgets 2.9.0, Visual C++ Express 2005, Windows Vista x64 Home Premium

zobbo
Experienced Solver
Experienced Solver
Posts: 58
Joined: Sat Aug 18, 2007 4:41 am

Re: Using RTI/XML

Post by zobbo » Sat Oct 26, 2013 5:03 am

Hmm,

I didn't get very far, now when I try to compile I get this:

"Cannot convert from void to bool" for the return value in xtictor.h

Code: Select all

// 1 param

template<typename Class, typename T0>
struct wxObjectAllocatorAndCreator_1 : public wxObjectAllocatorAndCreator
{
    bool Create(wxObject * &o, wxAny *args)
    {
        Class *obj = wx_dynamic_cast(Class*, o);
        return obj->Create(
            (args[0]).As(static_cast<T0*>(NULL))
            );
    }
};
Cheers,
Zobbo
Zobbo

Wxwidgets 2.9.0, Visual C++ Express 2005, Windows Vista x64 Home Premium

User avatar
doublemax
Moderator
Moderator
Posts: 14100
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Using RTI/XML

Post by doublemax » Sat Oct 26, 2013 10:16 am

Have you tried if the "xti" sample works for you?
Use the source, Luke!

Post Reply