From 281448385a8d62a7efc64ca29e5803958e55eb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 5 Jul 2010 14:23:21 +0000 Subject: [PATCH] Add std::[w]string support to wxVariant. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64821 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/variant.h | 20 ++++++++++++++++++++ src/common/variant.cpp | 14 ++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/wx/variant.h b/include/wx/variant.h index 671db18c65..f3b1aca1ad 100644 --- a/include/wx/variant.h +++ b/include/wx/variant.h @@ -230,6 +230,26 @@ public: inline operator wxString () const { return MakeString(); } wxString GetString() const; +#if wxUSE_STD_STRING + wxVariant(const std::string& val, const wxString& name = wxEmptyString); + bool operator==(const std::string& value) const + { return operator==(wxString(value)); } + bool operator!=(const std::string& value) const + { return operator!=(wxString(value)); } + wxVariant& operator=(const std::string& value) + { return operator=(wxString(value)); } + operator std::string() const { return (operator wxString()).ToStdString(); } + + wxVariant(const wxStdWideString& val, const wxString& name = wxEmptyString); + bool operator==(const wxStdWideString& value) const + { return operator==(wxString(value)); } + bool operator!=(const wxStdWideString& value) const + { return operator!=(wxString(value)); } + wxVariant& operator=(const wxStdWideString& value) + { return operator=(wxString(value)); } + operator wxStdWideString() const { return (operator wxString()).ToStdWstring(); } +#endif // wxUSE_STD_STRING + // wxUniChar wxVariant(const wxUniChar& val, const wxString& name = wxEmptyString); wxVariant(const wxUniCharRef& val, const wxString& name = wxEmptyString); diff --git a/src/common/variant.cpp b/src/common/variant.cpp index f5a417ce37..371630d322 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -986,6 +986,20 @@ wxVariant::wxVariant(const wxScopedWCharBuffer& val, const wxString& name) m_name = name; } +#if wxUSE_STD_STRING +wxVariant::wxVariant(const std::string& val, const wxString& name) +{ + m_refData = new wxVariantDataString(wxString(val)); + m_name = name; +} + +wxVariant::wxVariant(const wxStdWideString& val, const wxString& name) +{ + m_refData = new wxVariantDataString(wxString(val)); + m_name = name; +} +#endif // wxUSE_STD_STRING + bool wxVariant::operator== (const wxString& value) const { wxString thisValue;