xti streaming extensions
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22600 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -204,20 +204,6 @@ template<> void wxStringWriteValue(wxString & , char * const & )
|
||||
assert(0) ;
|
||||
}
|
||||
|
||||
// const wxPoint
|
||||
/*
|
||||
template<> const wxTypeInfo* wxGetTypeInfo( const wxPoint * )
|
||||
{
|
||||
assert(0) ;
|
||||
static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ;
|
||||
return &s_typeInfo ;
|
||||
}
|
||||
|
||||
template<> void wxStringReadValue(const wxString & , const wxPoint & )
|
||||
{
|
||||
assert(0) ;
|
||||
}
|
||||
*/
|
||||
// ----------------------------------------------------------------------------
|
||||
// value streaming
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -238,8 +224,73 @@ wxString wxXmlGetContentFromNode( wxXmlNode *node )
|
||||
}
|
||||
|
||||
// streamer specializations
|
||||
// for all built-in types
|
||||
|
||||
// TODO for all built-in types
|
||||
// bool
|
||||
|
||||
template<> void wxStringReadValue(const wxString &s , bool &data )
|
||||
{
|
||||
int intdata ;
|
||||
wxSscanf(s, _T("%d"), &intdata ) ;
|
||||
data = bool(intdata) ;
|
||||
}
|
||||
|
||||
template<> void wxStringWriteValue(wxString &s , const bool &data )
|
||||
{
|
||||
s = wxString::Format("%d", data ) ;
|
||||
}
|
||||
|
||||
// char
|
||||
|
||||
template<> void wxStringReadValue(const wxString &s , char &data )
|
||||
{
|
||||
int intdata ;
|
||||
wxSscanf(s, _T("%d"), &intdata ) ;
|
||||
data = char(intdata) ;
|
||||
}
|
||||
|
||||
template<> void wxStringWriteValue(wxString &s , const char &data )
|
||||
{
|
||||
s = wxString::Format("%d", data ) ;
|
||||
}
|
||||
|
||||
// unsigned char
|
||||
|
||||
template<> void wxStringReadValue(const wxString &s , unsigned char &data )
|
||||
{
|
||||
int intdata ;
|
||||
wxSscanf(s, _T("%d"), &intdata ) ;
|
||||
data = unsigned char(intdata) ;
|
||||
}
|
||||
|
||||
template<> void wxStringWriteValue(wxString &s , const unsigned char &data )
|
||||
{
|
||||
s = wxString::Format("%d", data ) ;
|
||||
}
|
||||
|
||||
// int
|
||||
|
||||
template<> void wxStringReadValue(const wxString &s , int &data )
|
||||
{
|
||||
wxSscanf(s, _T("%d"), &data ) ;
|
||||
}
|
||||
|
||||
template<> void wxStringWriteValue(wxString &s , const int &data )
|
||||
{
|
||||
s = wxString::Format("%d", data ) ;
|
||||
}
|
||||
|
||||
// unsigned int
|
||||
|
||||
template<> void wxStringReadValue(const wxString &s , unsigned int &data )
|
||||
{
|
||||
wxSscanf(s, _T("%d"), &data ) ;
|
||||
}
|
||||
|
||||
template<> void wxStringWriteValue(wxString &s , const unsigned int &data )
|
||||
{
|
||||
s = wxString::Format("%d", data ) ;
|
||||
}
|
||||
|
||||
// long
|
||||
|
||||
@@ -253,16 +304,40 @@ template<> void wxStringWriteValue(wxString &s , const long &data )
|
||||
s = wxString::Format("%ld", data ) ;
|
||||
}
|
||||
|
||||
// int
|
||||
// unsigned long
|
||||
|
||||
template<> void wxStringReadValue(const wxString &s , int &data )
|
||||
template<> void wxStringReadValue(const wxString &s , unsigned long &data )
|
||||
{
|
||||
wxSscanf(s, _T("%d"), &data ) ;
|
||||
wxSscanf(s, _T("%ld"), &data ) ;
|
||||
}
|
||||
|
||||
template<> void wxStringWriteValue(wxString &s , const int &data )
|
||||
template<> void wxStringWriteValue(wxString &s , const unsigned long &data )
|
||||
{
|
||||
s = wxString::Format("%d", data ) ;
|
||||
s = wxString::Format("%ld", data ) ;
|
||||
}
|
||||
|
||||
// float
|
||||
|
||||
template<> void wxStringReadValue(const wxString &s , float &data )
|
||||
{
|
||||
wxSscanf(s, _T("%f"), &data ) ;
|
||||
}
|
||||
|
||||
template<> void wxStringWriteValue(wxString &s , const float &data )
|
||||
{
|
||||
s = wxString::Format("%f", data ) ;
|
||||
}
|
||||
|
||||
// double
|
||||
|
||||
template<> void wxStringReadValue(const wxString &s , double &data )
|
||||
{
|
||||
wxSscanf(s, _T("%lf"), &data ) ;
|
||||
}
|
||||
|
||||
template<> void wxStringWriteValue(wxString &s , const double &data )
|
||||
{
|
||||
s = wxString::Format("%lf", data ) ;
|
||||
}
|
||||
|
||||
// wxString
|
||||
@@ -309,6 +384,37 @@ template<> void wxStringWriteValue(wxString &s , const wxSize &data )
|
||||
|
||||
WX_CUSTOM_TYPE_INFO(wxSize)
|
||||
|
||||
/*
|
||||
|
||||
template<> void wxStringReadValue(const wxString &s , wxColour &data )
|
||||
{
|
||||
// copied from VS xrc
|
||||
unsigned long tmp = 0;
|
||||
|
||||
if (s.Length() != 7 || s[0u] != wxT('#') ||
|
||||
wxSscanf(s.c_str(), wxT("#%lX"), &tmp) != 1)
|
||||
{
|
||||
wxLogError(_("String To Colour : Incorrect colour specification : %s"),
|
||||
s.c_str() );
|
||||
data = wxNullColour;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = wxColour((unsigned char) ((tmp & 0xFF0000) >> 16) ,
|
||||
(unsigned char) ((tmp & 0x00FF00) >> 8),
|
||||
(unsigned char) ((tmp & 0x0000FF)));
|
||||
}
|
||||
}
|
||||
|
||||
template<> void wxStringWriteValue(wxString &s , const wxColour &data )
|
||||
{
|
||||
s = wxString::Format("#%2X%2X%2X", data.Red() , data.Green() , data.Blue() ) ;
|
||||
}
|
||||
|
||||
WX_CUSTOM_TYPE_INFO(wxColour)
|
||||
|
||||
*/
|
||||
|
||||
// removing header dependancy on string tokenizer
|
||||
|
||||
void wxSetStringToArray( const wxString &s , wxArrayString &array )
|
||||
@@ -419,7 +525,7 @@ wxxVariant wxClassInfo::GetProperty(wxObject *object, const char *propertyName)
|
||||
VARIANT TO OBJECT
|
||||
*/
|
||||
|
||||
wxObject* wxxVariant::GetAsObject() const
|
||||
wxObject* wxxVariant::GetAsObject()
|
||||
{
|
||||
const wxClassTypeInfo *ti = dynamic_cast<const wxClassTypeInfo*>( m_data->GetTypeInfo() ) ;
|
||||
if ( ti )
|
||||
|
Reference in New Issue
Block a user