PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
wxstring.h
Go to the documentation of this file.
1 /*
2 * wxstring.h
3 *
4 * Adapter class for WX Widgets strings.
5 *
6 * Portable Tools Library
7 *
8 * Copyright (c) 2009 Vox Lucida
9 *
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
14 *
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * The Original Code is Portable Windows Library.
21 *
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23 *
24 * Contributor(s): ______________________________________.
25 *
26 * $Revision: 29745 $
27 * $Author: rjongbloed $
28 * $Date: 2013-05-20 13:52:54 +1000 (Mon, 20 May 2013) $
29 */
30
31 #ifndef PTLIB_WXSTRING_H
32 #define PTLIB_WXSTRING_H
33
34 #ifdef P_USE_PRAGMA
35 #pragma interface
36 #endif
37
40 class PwxString : public wxString
41 {
42 public:
43 PwxString() { }
44 PwxString(const wxString & str) : wxString(str) { }
45 PwxString(const char * str) : wxString( str, wxConvUTF8) { }
46 PwxString(const PString & str) : wxString((const char *)str, wxConvUTF8) { }
47 PwxString(const PFilePath & fn) : wxString((const char *)fn, wxConvUTF8) { }
48 #ifdef OPAL_OPAL_MEDIAFMT_H
49 PwxString(const OpalMediaFormat & fmt) : wxString((const char *)fmt.GetName(), wxConvUTF8) { }
50 #endif
51 #if wxUSE_UNICODE
52 PwxString(const wchar_t * wstr) : wxString(wstr) { }
53 #endif
54
55 inline PwxString & operator=(const char * str) { *this = wxString(str, wxConvUTF8); return *this; }
56 #if wxUSE_UNICODE
57 inline PwxString & operator=(const wchar_t * wstr) { wxString::operator=(wstr); return *this; }
58 #endif
59 inline PwxString & operator=(const wxString & str) { wxString::operator=(str); return *this; }
60 inline PwxString & operator=(const PString & str) { *this = wxString((const char *)str, wxConvUTF8); return *this; }
61
62 inline bool operator==(const char * other) const { return IsSameAs(wxString(other, wxConvUTF8)); }
63 #if wxUSE_UNICODE
64 inline bool operator==(const wchar_t * other) const { return IsSameAs(other); }
65 #endif
66 inline bool operator==(const wxString & other) const { return IsSameAs(other); }
67 inline bool operator==(const PString & other) const { return IsSameAs(wxString((const char *)other, wxConvUTF8)); }
68 inline bool operator==(const PwxString & other) const { return IsSameAs(other); }
69 #ifdef OPAL_OPAL_MEDIAFMT_H
70 inline bool operator==(const OpalMediaFormat & other) const { return IsSameAs(wxString((const char *)other.GetName(), wxConvUTF8)); }
71 #endif
72
73 inline bool operator!=(const char * other) const { return !IsSameAs(wxString(other, wxConvUTF8)); }
74 #if wxUSE_UNICODE
75 inline bool operator!=(const wchar_t * other) const { return !IsSameAs(other); }
76 #endif
77 inline bool operator!=(const wxString & other) const { return !IsSameAs(other); }
78 inline bool operator!=(const PString & other) const { return !IsSameAs(wxString((const char *)other, wxConvUTF8)); }
79 inline bool operator!=(const PwxString & other) const { return !IsSameAs(other); }
80 #ifdef OPAL_OPAL_MEDIAFMT_H
81 inline bool operator!=(const OpalMediaFormat & other) const { return !IsSameAs(wxString((const char *)other.GetName(), wxConvUTF8)); }
82 #endif
83
84 #if wxUSE_UNICODE
85 inline PString p_str() const { return ToUTF8().data(); }
86 inline operator PString() const { return ToUTF8().data(); }
87 inline operator PFilePath() const { return ToUTF8().data(); }
88 #if defined(PTLIB_PURL_H) && defined(P_URL)
89 inline operator PURL() const { return ToUTF8().data(); }
90 #endif
91 #if defined(PTLIB_IPSOCKET_H)
92 inline operator PIPSocket::Address() const { return PIPSocket::Address(PString(ToUTF8().data())); }
93 #endif
94 inline friend ostream & operator<<(ostream & stream, const PwxString & string) { return stream << string.ToUTF8(); }
95 inline friend wostream & operator<<(wostream & stream, const PwxString & string) { return stream << string.c_str(); }
96 #else
97 inline PString p_str() const { return c_str(); }
98 inline operator PString() const { return c_str(); }
99 inline operator PFilePath() const { return c_str(); }
100 #if defined(PTLIB_PURL_H) && defined(P_URL)
101 inline operator PURL() const { return c_str(); }
102 #endif
103 #if defined(PTLIB_IPSOCKET_H)
104 inline operator PIPSocket::Address() const { return c_str(); }
105 #endif
106 inline friend ostream & operator<<(ostream & stream, const PwxString & string) { return stream << string.c_str(); }
107 inline friend wostream & operator<<(wostream & stream, const PwxString & string) { return stream << string.c_str(); }
108 #endif
109
110 #if !wxCHECK_VERSION(2,9,2)
111 PwxString & operator<<(const char * str) { *this += wxString( str, wxConvUTF8); return *this; }
112 PwxString & operator<<(const PString & str) { *this += wxString((const char *)str, wxConvUTF8); return *this; }
113 #endif
114 };
115
116 __inline bool wxFromString(wxString & s1, PwxString * & s2) { *s2 = s1; return true; }
117 __inline wxString wxToString(const PwxString & str) { return str; }
118
119 #endif // PTLIB_WXSTRING_H
120
121
122 // End Of File ///////////////////////////////////////////////////////////////