-/////////////////////////////////////////////////////////////////////////////\r
-// Name: src/common/any.cpp\r
-// Purpose: wxAny class, container for any type\r
-// Author: Jaakko Salli\r
-// Modified by:\r
-// Created: 07/05/2009\r
-// RCS-ID: $Id$\r
-// Copyright: (c) wxWidgets team\r
-// Licence: wxWindows licence\r
-/////////////////////////////////////////////////////////////////////////////\r
-\r
-// For compilers that support precompilation, includes "wx/wx.h".\r
-#include "wx/wxprec.h"\r
-\r
-#ifdef __BORLANDC__\r
- #pragma hdrstop\r
-#endif\r
-\r
-#include "wx/any.h"\r
-\r
-#if wxUSE_ANY\r
-\r
-#ifndef WX_PRECOMP\r
- #include "wx/math.h"\r
- #include "wx/crt.h"\r
-#endif\r
-\r
-#include "wx/vector.h"\r
-#include "wx/module.h"\r
-\r
-using namespace wxPrivate;\r
-\r
-//-------------------------------------------------------------------------\r
-// wxAnyValueTypeGlobals\r
-//-------------------------------------------------------------------------\r
-\r
-//\r
-// Helper class to manage wxAnyValueType instances and other\r
-// related global variables.\r
-//\r
-// NB: We really need to have wxAnyValueType instances allocated\r
-// in heap. They are stored as static template member variables,\r
-// and with them we just can't be too careful (eg. not allocating\r
-// them in heap broke the type identification in GCC).\r
-//\r
-class wxAnyValueTypeGlobals\r
-{\r
-public:\r
- wxAnyValueTypeGlobals()\r
- {\r
- }\r
- ~wxAnyValueTypeGlobals()\r
- {\r
- for ( size_t i=0; i<m_valueTypes.size(); i++ )\r
- delete m_valueTypes[i];\r
- }\r
-\r
- void RegisterValueType(wxAnyValueType* valueType)\r
- {\r
- m_valueTypes.push_back(valueType);\r
- }\r
-\r
-private:\r
- wxVector<wxAnyValueType*> m_valueTypes;\r
-};\r
-\r
-static wxAnyValueTypeGlobals* g_wxAnyValueTypeGlobals = NULL;\r
-\r
-//\r
-// This class is to make sure that wxAnyValueType instances\r
-// etc. get freed correctly. We must use a separate wxAnyValueTypeGlobals\r
-// because wxModule itself is instantiated too late.\r
-//\r
-class wxAnyValueTypeGlobalsManager : public wxModule\r
-{\r
- DECLARE_DYNAMIC_CLASS(wxAnyValueTypeGlobalsManager)\r
-public:\r
- wxAnyValueTypeGlobalsManager() : wxModule() { }\r
- virtual ~wxAnyValueTypeGlobalsManager() { }\r
-\r
- virtual bool OnInit()\r
- {\r
- return true;\r
- }\r
- virtual void OnExit()\r
- {\r
- delete g_wxAnyValueTypeGlobals;\r
- g_wxAnyValueTypeGlobals = NULL;\r
- }\r
-private:\r
-};\r
-\r
-IMPLEMENT_DYNAMIC_CLASS(wxAnyValueTypeGlobalsManager, wxModule)\r
-\r
-\r
-//-------------------------------------------------------------------------\r
-// wxAnyValueType\r
-//-------------------------------------------------------------------------\r
-\r
-wxAnyValueType::wxAnyValueType()\r
-{\r
- if ( !g_wxAnyValueTypeGlobals )\r
- g_wxAnyValueTypeGlobals = new wxAnyValueTypeGlobals();\r
-\r
- g_wxAnyValueTypeGlobals->RegisterValueType(this);\r
-}\r
-\r
-//-------------------------------------------------------------------------\r
-// wxAny\r
-//-------------------------------------------------------------------------\r
-\r
-void wxAny::AssignAny(const wxAny &any)\r
-{\r
- if ( !any.m_type->IsSameType(m_type) )\r
- {\r
- m_type->DeleteValue(m_buffer);\r
- m_type = any.m_type;\r
- }\r
- m_type->CopyBuffer(any.m_buffer, m_buffer);\r
-}\r
-\r
-//-------------------------------------------------------------------------\r
-// Dynamic conversion member functions\r
-//-------------------------------------------------------------------------\r
-\r
-//\r
-// Define integer minimum and maximum as helpers\r
-#ifdef wxLongLong_t\r
-const wxAnyBaseIntType UseIntMin = wxINT64_MIN;\r
-const wxAnyBaseUintType UseIntMax = wxINT64_MAX;\r
-const wxAnyBaseUintType UseUintMax = wxUINT64_MAX;\r
-#else\r
-const wxAnyBaseIntType UseIntMin = LONG_MIN;\r
-const wxAnyBaseUintType UseUintMax = ULONG_MAX;\r
-const wxAnyBaseUintType UseIntMax = LONG_MAX;\r
-#endif\r
-\r
-const double UseIntMinF = static_cast<double>(UseIntMin);\r
-#ifndef __VISUALC6__\r
-const double UseIntMaxF = static_cast<double>(UseIntMax);\r
-const double UseUintMaxF = static_cast<double>(UseUintMax);\r
-#else\r
-// VC6 doesn't implement conversion from unsigned __int64 to double\r
-const wxAnyBaseIntType UseIntMax0 = static_cast<wxAnyBaseIntType>(UseIntMax);\r
-const wxAnyBaseIntType UseUintMax0 = static_cast<wxAnyBaseIntType>(UseUintMax);\r
-const double UseIntMaxF = static_cast<double>(UseIntMax0);\r
-const double UseUintMaxF = static_cast<double>(UseUintMax0);\r
-#endif\r
-\r
-\r
-bool wxAnyValueTypeImplInt::ConvertValue(const wxAnyValueBuffer& src,\r
- wxAnyValueType* dstType,\r
- wxAnyValueBuffer& dst) const\r
-{\r
- wxAnyBaseIntType value = GetValue(src);\r
- if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) )\r
- {\r
-#ifdef wxLongLong_t\r
- wxLongLong ll(value);\r
- wxString s = ll.ToString();\r
-#else\r
- wxString s = wxString::Format(wxS("%ld"), (long)value);\r
-#endif\r
- wxAnyValueTypeImpl<wxString>::SetValue(s, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) )\r
- {\r
- if ( value < 0 )\r
- return false;\r
- wxAnyBaseUintType ul = (wxAnyBaseUintType) value;\r
- wxAnyValueTypeImplUint::SetValue(ul, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, double) )\r
- {\r
- double value2 = static_cast<double>(value);\r
- wxAnyValueTypeImplDouble::SetValue(value2, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, bool) )\r
- {\r
- bool value2 = value ? true : false;\r
- wxAnyValueTypeImpl<bool>::SetValue(value2, dst);\r
- }\r
- else\r
- return false;\r
-\r
- return true;\r
-}\r
-\r
-bool wxAnyValueTypeImplUint::ConvertValue(const wxAnyValueBuffer& src,\r
- wxAnyValueType* dstType,\r
- wxAnyValueBuffer& dst) const\r
-{\r
- wxAnyBaseUintType value = GetValue(src);\r
- if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) )\r
- {\r
-#ifdef wxLongLong_t\r
- wxULongLong ull(value);\r
- wxString s = ull.ToString();\r
-#else\r
- wxString s = wxString::Format(wxS("%lu"), (long)value);\r
-#endif\r
- wxAnyValueTypeImpl<wxString>::SetValue(s, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) )\r
- {\r
- if ( value > UseIntMax )\r
- return false;\r
- wxAnyBaseIntType l = (wxAnyBaseIntType) value;\r
- wxAnyValueTypeImplInt::SetValue(l, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, double) )\r
- {\r
-#ifndef __VISUALC6__\r
- double value2 = static_cast<double>(value);\r
-#else\r
- // VC6 doesn't implement conversion from unsigned __int64 to double\r
- wxAnyBaseIntType value0 = static_cast<wxAnyBaseIntType>(value);\r
- double value2 = static_cast<double>(value0);\r
-#endif\r
- wxAnyValueTypeImplDouble::SetValue(value2, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, bool) )\r
- {\r
- bool value2 = value ? true : false;\r
- wxAnyValueTypeImpl<bool>::SetValue(value2, dst);\r
- }\r
- else\r
- return false;\r
-\r
- return true;\r
-}\r
-\r
-bool wxAnyValueTypeImplString::ConvertValue(const wxAnyValueBuffer& src,\r
- wxAnyValueType* dstType,\r
- wxAnyValueBuffer& dst) const\r
-{\r
- wxString value = GetValue(src);\r
- if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) )\r
- {\r
- wxAnyBaseIntType value2;\r
-#ifdef wxLongLong_t\r
- if ( !value.ToLongLong(&value2) )\r
-#else\r
- if ( !value.ToLong(&value2) )\r
-#endif\r
- return false;\r
- wxAnyValueTypeImplInt::SetValue(value2, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) )\r
- {\r
- wxAnyBaseUintType value2;\r
-#ifdef wxLongLong_t\r
- if ( !value.ToULongLong(&value2) )\r
-#else\r
- if ( !value.ToULong(&value2) )\r
-#endif\r
- return false;\r
- wxAnyValueTypeImplUint::SetValue(value2, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, double) )\r
- {\r
- double value2;\r
- if ( !value.ToDouble(&value2) )\r
- return false;\r
- wxAnyValueTypeImplDouble::SetValue(value2, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, bool) )\r
- {\r
- bool value2;\r
- value.MakeLower();\r
- if ( value == wxS("true") ||\r
- value == wxS("yes") ||\r
- value == wxS('1') )\r
- value2 = true;\r
- else if ( value == wxS("false") ||\r
- value == wxS("no") ||\r
- value == wxS('0') )\r
- value2 = false;\r
- else\r
- return false;\r
-\r
- wxAnyValueTypeImpl<bool>::SetValue(value2, dst);\r
- }\r
- else\r
- return false;\r
-\r
- return true;\r
-}\r
-\r
-bool wxAnyValueTypeImpl<bool>::ConvertValue(const wxAnyValueBuffer& src,\r
- wxAnyValueType* dstType,\r
- wxAnyValueBuffer& dst) const\r
-{\r
- bool value = GetValue(src);\r
- if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) )\r
- {\r
- wxAnyBaseIntType value2 = static_cast<wxAnyBaseIntType>(value);\r
- wxAnyValueTypeImplInt::SetValue(value2, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) )\r
- {\r
- wxAnyBaseIntType value2 = static_cast<wxAnyBaseUintType>(value);\r
- wxAnyValueTypeImplUint::SetValue(value2, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) )\r
- {\r
- wxString s;\r
- if ( value )\r
- s = wxS("true");\r
- else\r
- s = wxS("false");\r
- wxAnyValueTypeImpl<wxString>::SetValue(s, dst);\r
- }\r
- else\r
- return false;\r
-\r
- return true;\r
-}\r
-\r
-bool wxAnyValueTypeImplDouble::ConvertValue(const wxAnyValueBuffer& src,\r
- wxAnyValueType* dstType,\r
- wxAnyValueBuffer& dst) const\r
-{\r
- double value = GetValue(src);\r
- if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) )\r
- {\r
- if ( value < UseIntMinF || value > UseIntMaxF )\r
- return false;\r
- wxAnyBaseUintType ul = static_cast<wxAnyBaseUintType>(value);\r
- wxAnyValueTypeImplUint::SetValue(ul, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) )\r
- {\r
- if ( value < 0.0 || value > UseUintMaxF )\r
- return false;\r
- wxAnyBaseUintType ul = static_cast<wxAnyBaseUintType>(value);\r
- wxAnyValueTypeImplUint::SetValue(ul, dst);\r
- }\r
- else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) )\r
- {\r
- wxString s = wxString::Format(wxS("%.14g"), value);\r
- wxAnyValueTypeImpl<wxString>::SetValue(s, dst);\r
- }\r
- else\r
- return false;\r
-\r
- return true;\r
-}\r
-\r
-WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplInt)\r
-WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplUint)\r
-WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplString)\r
-WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<bool>)\r
-WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplDouble)\r
-\r
-//-------------------------------------------------------------------------\r
-// wxAnyNullValueType implementation\r
-//-------------------------------------------------------------------------\r
-\r
-class wxAnyNullValue\r
-{\r
-private:\r
- void* m_dummy;\r
-};\r
-\r
-template <>\r
-class wxAnyValueTypeImpl<wxAnyNullValue> : public wxAnyValueType\r
-{\r
- WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxAnyNullValue>)\r
-public:\r
- virtual void DeleteValue(wxAnyValueBuffer& buf) const\r
- {\r
- buf.m_ptr = NULL; // This is important\r
- }\r
-\r
- // Dummy implementations\r
- virtual void CopyBuffer(const wxAnyValueBuffer& src,\r
- wxAnyValueBuffer& dst) const\r
- {\r
- wxUnusedVar(src);\r
- wxUnusedVar(dst);\r
- }\r
-\r
- virtual bool ConvertValue(const wxAnyValueBuffer& src,\r
- wxAnyValueType* dstType,\r
- wxAnyValueBuffer& dst) const\r
- {\r
- wxUnusedVar(src);\r
- wxUnusedVar(dstType);\r
- wxUnusedVar(dst);\r
- return false;\r
- }\r
-\r
-private:\r
-};\r
-\r
-WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxAnyNullValue>)\r
-\r
-wxAnyValueType* wxAnyNullValueType =\r
- wxAnyValueTypeImpl<wxAnyNullValue>::GetInstance();\r
-\r
-#endif // wxUSE_ANY\r
+/////////////////////////////////////////////////////////////////////////////
+// Name: src/common/any.cpp
+// Purpose: wxAny class, container for any type
+// Author: Jaakko Salli
+// Modified by:
+// Created: 07/05/2009
+// RCS-ID: $Id$
+// Copyright: (c) wxWidgets team
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#include "wx/any.h"
+
+#if wxUSE_ANY
+
+#ifndef WX_PRECOMP
+ #include "wx/math.h"
+ #include "wx/crt.h"
+#endif
+
+#include "wx/vector.h"
+#include "wx/module.h"
+
+using namespace wxPrivate;
+
+//-------------------------------------------------------------------------
+// wxAnyValueTypeGlobals
+//-------------------------------------------------------------------------
+
+//
+// Helper class to manage wxAnyValueType instances and other
+// related global variables.
+//
+// NB: We really need to have wxAnyValueType instances allocated
+// in heap. They are stored as static template member variables,
+// and with them we just can't be too careful (eg. not allocating
+// them in heap broke the type identification in GCC).
+//
+class wxAnyValueTypeGlobals
+{
+public:
+ wxAnyValueTypeGlobals()
+ {
+ }
+ ~wxAnyValueTypeGlobals()
+ {
+ for ( size_t i=0; i<m_valueTypes.size(); i++ )
+ delete m_valueTypes[i];
+ }
+
+ void RegisterValueType(wxAnyValueType* valueType)
+ {
+ m_valueTypes.push_back(valueType);
+ }
+
+private:
+ wxVector<wxAnyValueType*> m_valueTypes;
+};
+
+static wxAnyValueTypeGlobals* g_wxAnyValueTypeGlobals = NULL;
+
+//
+// This class is to make sure that wxAnyValueType instances
+// etc. get freed correctly. We must use a separate wxAnyValueTypeGlobals
+// because wxModule itself is instantiated too late.
+//
+class wxAnyValueTypeGlobalsManager : public wxModule
+{
+ DECLARE_DYNAMIC_CLASS(wxAnyValueTypeGlobalsManager)
+public:
+ wxAnyValueTypeGlobalsManager() : wxModule() { }
+ virtual ~wxAnyValueTypeGlobalsManager() { }
+
+ virtual bool OnInit()
+ {
+ return true;
+ }
+ virtual void OnExit()
+ {
+ delete g_wxAnyValueTypeGlobals;
+ g_wxAnyValueTypeGlobals = NULL;
+ }
+private:
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxAnyValueTypeGlobalsManager, wxModule)
+
+
+//-------------------------------------------------------------------------
+// wxAnyValueType
+//-------------------------------------------------------------------------
+
+wxAnyValueType::wxAnyValueType()
+{
+ if ( !g_wxAnyValueTypeGlobals )
+ g_wxAnyValueTypeGlobals = new wxAnyValueTypeGlobals();
+
+ g_wxAnyValueTypeGlobals->RegisterValueType(this);
+}
+
+//-------------------------------------------------------------------------
+// Dynamic conversion member functions
+//-------------------------------------------------------------------------
+
+//
+// Define integer minimum and maximum as helpers
+#ifdef wxLongLong_t
+ #define UseIntMin (wxINT64_MIN)
+ #define UseIntMax (wxINT64_MAX)
+ #define UseUintMax (wxUINT64_MAX)
+#else
+ #define UseIntMin (LONG_MIN)
+ #define UseIntMax (LONG_MAX)
+ #define UseUintMax (ULONG_MAX)
+#endif
+
+namespace
+{
+
+const double UseIntMinF = static_cast<double>(UseIntMin);
+const double UseIntMaxF = static_cast<double>(UseIntMax);
+const double UseUintMaxF = static_cast<double>(UseUintMax);
+
+} // anonymous namespace
+
+bool wxAnyValueTypeImplInt::ConvertValue(const wxAnyValueBuffer& src,
+ wxAnyValueType* dstType,
+ wxAnyValueBuffer& dst) const
+{
+ wxAnyBaseIntType value = GetValue(src);
+ if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) )
+ {
+#ifdef wxLongLong_t
+ wxLongLong ll(value);
+ wxString s = ll.ToString();
+#else
+ wxString s = wxString::Format(wxS("%ld"), (long)value);
+#endif
+ wxAnyValueTypeImpl<wxString>::SetValue(s, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) )
+ {
+ if ( value < 0 )
+ return false;
+ wxAnyBaseUintType ul = (wxAnyBaseUintType) value;
+ wxAnyValueTypeImplUint::SetValue(ul, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, double) )
+ {
+ double value2 = static_cast<double>(value);
+ wxAnyValueTypeImplDouble::SetValue(value2, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, bool) )
+ {
+ bool value2 = value ? true : false;
+ wxAnyValueTypeImpl<bool>::SetValue(value2, dst);
+ }
+ else
+ return false;
+
+ return true;
+}
+
+bool wxAnyValueTypeImplUint::ConvertValue(const wxAnyValueBuffer& src,
+ wxAnyValueType* dstType,
+ wxAnyValueBuffer& dst) const
+{
+ wxAnyBaseUintType value = GetValue(src);
+ if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) )
+ {
+#ifdef wxLongLong_t
+ wxULongLong ull(value);
+ wxString s = ull.ToString();
+#else
+ wxString s = wxString::Format(wxS("%lu"), (long)value);
+#endif
+ wxAnyValueTypeImpl<wxString>::SetValue(s, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) )
+ {
+ if ( value > UseIntMax )
+ return false;
+ wxAnyBaseIntType l = (wxAnyBaseIntType) value;
+ wxAnyValueTypeImplInt::SetValue(l, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, double) )
+ {
+#ifndef __VISUALC6__
+ double value2 = static_cast<double>(value);
+#else
+ // VC6 doesn't implement conversion from unsigned __int64 to double
+ wxAnyBaseIntType value0 = static_cast<wxAnyBaseIntType>(value);
+ double value2 = static_cast<double>(value0);
+#endif
+ wxAnyValueTypeImplDouble::SetValue(value2, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, bool) )
+ {
+ bool value2 = value ? true : false;
+ wxAnyValueTypeImpl<bool>::SetValue(value2, dst);
+ }
+ else
+ return false;
+
+ return true;
+}
+
+bool wxAnyValueTypeImplString::ConvertValue(const wxAnyValueBuffer& src,
+ wxAnyValueType* dstType,
+ wxAnyValueBuffer& dst) const
+{
+ wxString value = GetValue(src);
+ if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) )
+ {
+ wxAnyBaseIntType value2;
+#ifdef wxLongLong_t
+ if ( !value.ToLongLong(&value2) )
+#else
+ if ( !value.ToLong(&value2) )
+#endif
+ return false;
+ wxAnyValueTypeImplInt::SetValue(value2, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) )
+ {
+ wxAnyBaseUintType value2;
+#ifdef wxLongLong_t
+ if ( !value.ToULongLong(&value2) )
+#else
+ if ( !value.ToULong(&value2) )
+#endif
+ return false;
+ wxAnyValueTypeImplUint::SetValue(value2, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, double) )
+ {
+ double value2;
+ if ( !value.ToDouble(&value2) )
+ return false;
+ wxAnyValueTypeImplDouble::SetValue(value2, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, bool) )
+ {
+ bool value2;
+ value.MakeLower();
+ if ( value == wxS("true") ||
+ value == wxS("yes") ||
+ value == wxS('1') )
+ value2 = true;
+ else if ( value == wxS("false") ||
+ value == wxS("no") ||
+ value == wxS('0') )
+ value2 = false;
+ else
+ return false;
+
+ wxAnyValueTypeImpl<bool>::SetValue(value2, dst);
+ }
+ else
+ return false;
+
+ return true;
+}
+
+bool wxAnyValueTypeImpl<bool>::ConvertValue(const wxAnyValueBuffer& src,
+ wxAnyValueType* dstType,
+ wxAnyValueBuffer& dst) const
+{
+ bool value = GetValue(src);
+ if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) )
+ {
+ wxAnyBaseIntType value2 = static_cast<wxAnyBaseIntType>(value);
+ wxAnyValueTypeImplInt::SetValue(value2, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) )
+ {
+ wxAnyBaseIntType value2 = static_cast<wxAnyBaseUintType>(value);
+ wxAnyValueTypeImplUint::SetValue(value2, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) )
+ {
+ wxString s;
+ if ( value )
+ s = wxS("true");
+ else
+ s = wxS("false");
+ wxAnyValueTypeImpl<wxString>::SetValue(s, dst);
+ }
+ else
+ return false;
+
+ return true;
+}
+
+bool wxAnyValueTypeImplDouble::ConvertValue(const wxAnyValueBuffer& src,
+ wxAnyValueType* dstType,
+ wxAnyValueBuffer& dst) const
+{
+ double value = GetValue(src);
+ if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseIntType) )
+ {
+ if ( value < UseIntMinF || value > UseIntMaxF )
+ return false;
+ wxAnyBaseUintType ul = static_cast<wxAnyBaseUintType>(value);
+ wxAnyValueTypeImplUint::SetValue(ul, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxAnyBaseUintType) )
+ {
+ if ( value < 0.0 || value > UseUintMaxF )
+ return false;
+ wxAnyBaseUintType ul = static_cast<wxAnyBaseUintType>(value);
+ wxAnyValueTypeImplUint::SetValue(ul, dst);
+ }
+ else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) )
+ {
+ wxString s = wxString::Format(wxS("%.14g"), value);
+ wxAnyValueTypeImpl<wxString>::SetValue(s, dst);
+ }
+ else
+ return false;
+
+ return true;
+}
+
+WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplInt)
+WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplUint)
+WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplString)
+WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<bool>)
+WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplDouble)
+
+WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxDateTime>)
+//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxObject*>)
+//WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxArrayString>)
+
+//-------------------------------------------------------------------------
+// wxAnyNullValueType implementation
+//-------------------------------------------------------------------------
+
+class wxAnyNullValue
+{
+private:
+ void* m_dummy;
+};
+
+template <>
+class wxAnyValueTypeImpl<wxAnyNullValue> : public wxAnyValueType
+{
+ WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxAnyNullValue>)
+public:
+ // Dummy implementations
+ virtual void DeleteValue(wxAnyValueBuffer& buf) const
+ {
+ wxUnusedVar(buf);
+ }
+
+ virtual void CopyBuffer(const wxAnyValueBuffer& src,
+ wxAnyValueBuffer& dst) const
+ {
+ wxUnusedVar(src);
+ wxUnusedVar(dst);
+ }
+
+ virtual bool ConvertValue(const wxAnyValueBuffer& src,
+ wxAnyValueType* dstType,
+ wxAnyValueBuffer& dst) const
+ {
+ wxUnusedVar(src);
+ wxUnusedVar(dstType);
+ wxUnusedVar(dst);
+ return false;
+ }
+
+private:
+};
+
+WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxAnyNullValue>)
+
+wxAnyValueType* wxAnyNullValueType =
+ wxAnyValueTypeImpl<wxAnyNullValue>::GetInstance();
+
+#endif // wxUSE_ANY