wxstring.h

Go to the documentation of this file.
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: 22403 $
00027  * $Author: rjongbloed $
00028  * $Date: 2009-04-07 05:13:31 -0500 (Tue, 07 Apr 2009) $
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(str, wxConvUTF8 ) { }
00046     PwxString(const PFilePath & fn) : wxString(fn, wxConvUTF8 ) { }
00047     PwxString(const char * str) : wxString(str, wxConvUTF8) { }
00048     PwxString(const OpalMediaFormat & fmt) : wxString(fmt, wxConvUTF8) { }
00049 #if wxUSE_UNICODE
00050     PwxString(const wchar_t * wstr) : wxString(wstr) { }
00051 #endif
00052 
00053     inline PwxString & operator=(const char * str)     { *this = wxString::wxString(str, wxConvUTF8); return *this; }
00054 #if wxUSE_UNICODE
00055     inline PwxString & operator=(const wchar_t * wstr) { wxString::operator=(wstr); return *this; }
00056 #endif
00057     inline PwxString & operator=(const wxString & str) { wxString::operator=(str); return *this; }
00058     inline PwxString & operator=(const PString & str)  { *this = wxString::wxString(str, wxConvUTF8); return *this; }
00059 
00060     inline bool operator==(const char * other)            const { return IsSameAs(wxString(other, wxConvUTF8)); }
00061 #if wxUSE_UNICODE
00062     inline bool operator==(const wchar_t * other)         const { return IsSameAs(other); }
00063 #endif
00064     inline bool operator==(const wxString & other)        const { return IsSameAs(other); }
00065     inline bool operator==(const PString & other)         const { return IsSameAs(wxString(other, wxConvUTF8)); }
00066     inline bool operator==(const PwxString & other)       const { return IsSameAs(other); }
00067     inline bool operator==(const OpalMediaFormat & other) const { return IsSameAs(wxString(other, wxConvUTF8)); }
00068 
00069     inline bool operator!=(const char * other)            const { return !IsSameAs(wxString(other, wxConvUTF8)); }
00070 #if wxUSE_UNICODE
00071     inline bool operator!=(const wchar_t * other)         const { return !IsSameAs(other); }
00072 #endif
00073     inline bool operator!=(const wxString & other)        const { return !IsSameAs(other); }
00074     inline bool operator!=(const PString & other)         const { return !IsSameAs(wxString(other, wxConvUTF8)); }
00075     inline bool operator!=(const PwxString & other)       const { return !IsSameAs(other); }
00076     inline bool operator!=(const OpalMediaFormat & other) const { return !IsSameAs(wxString(other, wxConvUTF8)); }
00077 
00078 #if wxUSE_UNICODE
00079     inline PString p_str() const { return ToUTF8().data(); }
00080     inline operator PString() const { return ToUTF8().data(); }
00081     inline operator PFilePath() const { return ToUTF8().data(); }
00082     inline operator PIPSocket::Address() const { return PString(ToUTF8().data()); }
00083     inline friend ostream & operator<<(ostream & stream, const PwxString & string) { return stream << string.ToUTF8(); }
00084     inline friend wostream & operator<<(wostream & stream, const PwxString & string) { return stream << string.c_str(); }
00085 #else
00086     inline PString p_str() const { return c_str(); }
00087     inline operator PString() const { return c_str(); }
00088     inline operator PFilePath() const { return c_str(); }
00089     inline operator PIPSocket::Address() const { return c_str(); }
00090     inline friend ostream & operator<<(ostream & stream, const PwxString & string) { return stream << string.c_str(); }
00091     inline friend wostream & operator<<(wostream & stream, const PwxString & string) { return stream << string.c_str(); }
00092 #endif
00093 };
00094 
00095 
00096 #endif // PTLIB_WXSTRING_H
00097 
00098 
00099 // End Of File ///////////////////////////////////////////////////////////////

Generated on Fri Oct 14 01:44:10 2011 for PTLib by  doxygen 1.4.7