~registry/dolphin-emu/triforce

« back to all changes in this revision

Viewing changes to Externals/wxWidgets3/include/wx/cocoa/string.h

  • Committer: Sérgio Benjamim
  • Date: 2015-02-13 05:54:40 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20150213055440-ey2rt3sjpy27km78
Dolphin Triforce branch from code.google, commit b957980 (4.0-315).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
// Copyright:   (c) 2003 David Elliott
 
8
// Licence:     wxWindows licence
 
9
///////////////////////////////////////////////////////////////////////////////
 
10
 
 
11
#ifndef __WX_COCOA_STRING_H__
 
12
#define __WX_COCOA_STRING_H__
 
13
 
 
14
#import <Foundation/NSString.h>
 
15
#include "wx/string.h"
 
16
 
 
17
// FIXME: In unicode mode we are doing the conversion twice.  wxString
 
18
// converts to UTF-8 and NSString converts from UTF-8.
 
19
// One possible optimization is to convert to the wxString internal
 
20
// representation which is an unsigned short (unichar) but unfortunately
 
21
// there is little documentation on which encoding it uses by default.
 
22
 
 
23
// Return an autoreleased NSString
 
24
inline NSString* wxNSStringWithWxString(const wxString &wxstring)
 
25
{
 
26
#if wxUSE_UNICODE
 
27
    return [NSString stringWithUTF8String: wxstring.utf8_str()];
 
28
#else
 
29
    return [NSString stringWithCString: wxstring.c_str() length:wxstring.Len()];
 
30
#endif // wxUSE_UNICODE
 
31
}
 
32
 
 
33
// Intialize an NSString which has already been allocated
 
34
inline NSString* wxInitNSStringWithWxString(NSString *nsstring, const wxString &wxstring)
 
35
{
 
36
#if wxUSE_UNICODE
 
37
    return [nsstring initWithUTF8String: wxstring.utf8_str()];
 
38
#else
 
39
    return [nsstring initWithCString: wxstring.c_str() length:wxstring.Len()];
 
40
#endif // wxUSE_UNICODE
 
41
}
 
42
 
 
43
inline wxString wxStringWithNSString(NSString *nsstring)
 
44
{
 
45
#if wxUSE_UNICODE
 
46
    return wxString::FromUTF8Unchecked([nsstring UTF8String]);
 
47
#else
 
48
    return wxString([nsstring lossyCString]);
 
49
#endif // wxUSE_UNICODE
 
50
}
 
51
 
 
52
#endif // __WX_COCOA_STRING_H__