Mercurial > projects > qtd
comparison d2/qt/core/QString.d @ 311:8674fd5f34f4 lifetime
Added d1/d2 top directories
author | maxter <spambox@d-coding.com> |
---|---|
date | Wed, 23 Dec 2009 16:17:22 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
310:5bcfe9e7db7f | 311:8674fd5f34f4 |
---|---|
1 module qt.core.QString; | |
2 | |
3 import qt.QGlobal; | |
4 | |
5 version (Tango) | |
6 { | |
7 public import tango.text.convert.Utf : toUTF8 = toString; | |
8 } | |
9 else | |
10 { | |
11 public import std.utf : toUTF8; | |
12 } | |
13 | |
14 struct QString | |
15 { | |
16 public static QString opCall(void* ptr, bool proxy) { | |
17 QString str; | |
18 str.native_id = ptr; | |
19 return str; | |
20 } | |
21 | |
22 private void* native_id; | |
23 | |
24 public static final string toNativeString(void* qstring) { | |
25 wchar* arr = __qtd_QString_utf16(qstring); | |
26 int size = __qtd_QString_size(qstring); | |
27 return .toUTF8(arr[0..size]); | |
28 } | |
29 | |
30 public final string toNativeString() { | |
31 return toNativeString(native_id); | |
32 } | |
33 | |
34 public void assign(string text) { | |
35 __qtd_QString_operatorAssign(native_id, text); | |
36 } | |
37 | |
38 public static string fromUtf8(string source) { | |
39 return source; | |
40 } | |
41 /* | |
42 public static string fromUtf16(wstring src) { | |
43 version(Tango) | |
44 }*/ | |
45 } | |
46 | |
47 private extern (C) wchar* __qtd_QString_utf16(void* __this_nativeId); | |
48 private extern (C) int __qtd_QString_size(void* __this_nativeId); | |
49 private extern (C) void __qtd_QString_operatorAssign(void* __this_nativeId, string text); |