]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/string.h
Include wx/image.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / include / wx / cocoa / string.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/string.h
3 // Purpose: String conversion methods
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/04/13
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __WX_COCOA_STRING_H__
13 #define __WX_COCOA_STRING_H__
14
15 #import <Foundation/NSString.h>
16 #include "wx/string.h"
17
18 // FIXME: In unicode mode we are doing the conversion twice. wxString
19 // converts to UTF-8 and NSString converts from UTF-8.
20 // One possible optimization is to convert to the wxString internal
21 // representation which is an unsigned short (unichar) but unfortunately
22 // there is little documentation on which encoding it uses by default.
23
24 // Return an autoreleased NSString
25 inline NSString* wxNSStringWithWxString(const wxString &wxstring)
26 {
27 #if wxUSE_UNICODE
28 return [NSString stringWithUTF8String: wxstring.mb_str(wxConvUTF8)];
29 #else
30 return [NSString stringWithCString: wxstring.c_str() length:wxstring.Len()];
31 #endif // wxUSE_UNICODE
32 }
33
34 // Intialize an NSString which has already been allocated
35 inline NSString* wxInitNSStringWithWxString(NSString *nsstring, const wxString &wxstring)
36 {
37 #if wxUSE_UNICODE
38 return [nsstring initWithUTF8String: wxstring.mb_str(wxConvUTF8)];
39 #else
40 return [nsstring initWithCString: wxstring.c_str() length:wxstring.Len()];
41 #endif // wxUSE_UNICODE
42 }
43
44 inline wxString wxStringWithNSString(NSString *nsstring)
45 {
46 #if wxUSE_UNICODE
47 return wxString([nsstring UTF8String], wxConvUTF8);
48 #else
49 return wxString([nsstring lossyCString]);
50 #endif // wxUSE_UNICODE
51 }
52
53 #endif // __WX_COCOA_STRING_H__