PTLib
Version 2.10.4
|
00001 /* 00002 * wxstring.h 00003 * 00004 * Adapter class for WX Widgets strings. 00005 * 00006 * Portable Tools Library 00007 * 00008 * Copyright (c) 2009 Vox Lucida 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Contributor(s): ______________________________________. 00025 * 00026 * $Revision: 25648 $ 00027 * $Author: rjongbloed $ 00028 * $Date: 2011-05-01 20:19:23 -0500 (Sun, 01 May 2011) $ 00029 */ 00030 00031 #ifndef PTLIB_WXSTRING_H 00032 #define PTLIB_WXSTRING_H 00033 00034 #ifdef P_USE_PRAGMA 00035 #pragma interface 00036 #endif 00037 00040 class PwxString : public wxString 00041 { 00042 public: 00043 PwxString() { } 00044 PwxString(const wxString & str) : wxString(str) { } 00045 PwxString(const PString & str) : wxString((const char *)str, wxConvUTF8 ) { } 00046 PwxString(const PFilePath & fn) : wxString((const char *)fn, wxConvUTF8 ) { } 00047 PwxString(const char * str) : wxString(str, wxConvUTF8) { } 00048 #ifdef OPAL_OPAL_MEDIAFMT_H 00049 PwxString(const OpalMediaFormat & fmt) : wxString((const char *)fmt.GetName(), wxConvUTF8) { } 00050 #endif 00051 #if wxUSE_UNICODE 00052 PwxString(const wchar_t * wstr) : wxString(wstr) { } 00053 #endif 00054 00055 inline PwxString & operator=(const char * str) { *this = wxString(str, wxConvUTF8); return *this; } 00056 #if wxUSE_UNICODE 00057 inline PwxString & operator=(const wchar_t * wstr) { wxString::operator=(wstr); return *this; } 00058 #endif 00059 inline PwxString & operator=(const wxString & str) { wxString::operator=(str); return *this; } 00060 inline PwxString & operator=(const PString & str) { *this = wxString((const char *)str, wxConvUTF8); return *this; } 00061 00062 inline bool operator==(const char * other) const { return IsSameAs(wxString(other, wxConvUTF8)); } 00063 #if wxUSE_UNICODE 00064 inline bool operator==(const wchar_t * other) const { return IsSameAs(other); } 00065 #endif 00066 inline bool operator==(const wxString & other) const { return IsSameAs(other); } 00067 inline bool operator==(const PString & other) const { return IsSameAs(wxString((const char *)other, wxConvUTF8)); } 00068 inline bool operator==(const PwxString & other) const { return IsSameAs(other); } 00069 #ifdef OPAL_OPAL_MEDIAFMT_H 00070 inline bool operator==(const OpalMediaFormat & other) const { return IsSameAs(wxString((const char *)other.GetName(), wxConvUTF8)); } 00071 #endif 00072 00073 inline bool operator!=(const char * other) const { return !IsSameAs(wxString(other, wxConvUTF8)); } 00074 #if wxUSE_UNICODE 00075 inline bool operator!=(const wchar_t * other) const { return !IsSameAs(other); } 00076 #endif 00077 inline bool operator!=(const wxString & other) const { return !IsSameAs(other); } 00078 inline bool operator!=(const PString & other) const { return !IsSameAs(wxString((const char *)other, wxConvUTF8)); } 00079 inline bool operator!=(const PwxString & other) const { return !IsSameAs(other); } 00080 #ifdef OPAL_OPAL_MEDIAFMT_H 00081 inline bool operator!=(const OpalMediaFormat & other) const { return !IsSameAs(wxString((const char *)other.GetName(), wxConvUTF8)); } 00082 #endif 00083 00084 #if wxUSE_UNICODE 00085 inline PString p_str() const { return ToUTF8().data(); } 00086 inline operator PString() const { return ToUTF8().data(); } 00087 inline operator PFilePath() const { return ToUTF8().data(); } 00088 #if defined(PTLIB_PURL_H) && defined(P_URL) 00089 inline operator PURL() const { return ToUTF8().data(); } 00090 #endif 00091 #if defined(PTLIB_IPSOCKET_H) 00092 inline operator PIPSocket::Address() const { return PString(ToUTF8().data()); } 00093 #endif 00094 inline friend ostream & operator<<(ostream & stream, const PwxString & string) { return stream << string.ToUTF8(); } 00095 inline friend wostream & operator<<(wostream & stream, const PwxString & string) { return stream << string.c_str(); } 00096 #else 00097 inline PString p_str() const { return c_str(); } 00098 inline operator PString() const { return c_str(); } 00099 inline operator PFilePath() const { return c_str(); } 00100 #if defined(PTLIB_PURL_H) && defined(P_URL) 00101 inline operator PURL() const { return c_str(); } 00102 #endif 00103 #if defined(PTLIB_IPSOCKET_H) 00104 inline operator PIPSocket::Address() const { return c_str(); } 00105 #endif 00106 inline friend ostream & operator<<(ostream & stream, const PwxString & string) { return stream << string.c_str(); } 00107 inline friend wostream & operator<<(wostream & stream, const PwxString & string) { return stream << string.c_str(); } 00108 #endif 00109 }; 00110 00111 __inline bool wxFromString(wxString & s1, PwxString * & s2) { *s2 = s1; return true; } 00112 __inline wxString wxToString(const PwxString & str) { return str; } 00113 00114 #endif // PTLIB_WXSTRING_H 00115 00116 00117 // End Of File ///////////////////////////////////////////////////////////////