Add std::[w]string support to wxVariant.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64821 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2010-07-05 14:23:21 +00:00
parent 76dd097ab7
commit 281448385a
2 changed files with 34 additions and 0 deletions

View File

@ -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);

View File

@ -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;