Mercurial > projects > qtd
comparison d2/qt/core/QString.d @ 344:96a75b1e5b26
project structure changes
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Fri, 14 May 2010 12:14:37 +0300 |
parents | qt/core/QString.d@55ee4603365d |
children |
comparison
equal
deleted
inserted
replaced
343:552647ec0f82 | 344:96a75b1e5b26 |
---|---|
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() | |
17 { | |
18 QString str; | |
19 qtd_QString_placed_ctor(&str); | |
20 return str; | |
21 } | |
22 | |
23 ~this() | |
24 { | |
25 qtd_QString_call_destructor(&this); | |
26 } | |
27 | |
28 void opAssign(string str) | |
29 { | |
30 qtd_QString_assign_fromUtf8(&this, str); | |
31 } | |
32 | |
33 this(string str) | |
34 { | |
35 qtd_QString_new_fromUtf8_at(&this, str); | |
36 } | |
37 | |
38 public static void __constructPlacedQString(void* place, string source) { | |
39 qtd_QString_new_fromUtf8_at(place, source); | |
40 } | |
41 | |
42 // service stuff | |
43 static void* __constructNativeCopy(const void* orig) { | |
44 return qtd_QString_QString_QString(cast(void*)orig); | |
45 } | |
46 | |
47 static void* __constructPlacedNativeCopy(const void* orig, void* place) { | |
48 return qtd_QString_placed_copy(orig, place); | |
49 } | |
50 | |
51 public static void __deleteNativeObject(void* ptr) { | |
52 qtd_QString_destructor(ptr); | |
53 } | |
54 | |
55 public static void __callNativeDestructor(void* ptr) { | |
56 qtd_QString_call_destructor(ptr); | |
57 } | |
58 struct QTypeInfo | |
59 { | |
60 enum bool isComplex = true; | |
61 enum bool isStatic = false; | |
62 enum bool isLarge = false; | |
63 enum bool isPointer = false; | |
64 enum bool isDummy = false; | |
65 } | |
66 | |
67 private: | |
68 void *dummy; // sizeof(QString) == sizeof(void*) | |
69 } | |
70 | |
71 struct QStringUtil | |
72 { | |
73 public static final string toNativeString(void* qstring) { | |
74 wchar* arr = qtd_QString_utf16(qstring); | |
75 int size = qtd_QString_size(qstring); | |
76 return .toUTF8(arr[0..size]); | |
77 } | |
78 | |
79 public static string fromUtf8(string source) { | |
80 return source; | |
81 } | |
82 | |
83 public static QStringUtil opCall(void* ptr, bool proxy) { | |
84 QStringUtil str; | |
85 str.__nativeId = ptr; | |
86 return str; | |
87 } | |
88 | |
89 public void* __nativeId; | |
90 | |
91 public final string toNativeString() { | |
92 return QStringUtil.toNativeString(__nativeId); | |
93 } | |
94 | |
95 public void assign(string text) { | |
96 qtd_QString_operatorAssign(__nativeId, text); | |
97 } | |
98 } | |
99 private extern(C) void* qtd_QString_placed_copy(const void* orig, void* place); | |
100 | |
101 private extern (C) void qtd_QString_destructor(void* __this_nativeId); | |
102 private extern (C) void qtd_QString_call_destructor(void *ptr); | |
103 | |
104 private extern (C) void* qtd_QString_QString_QString(void* orig); | |
105 | |
106 private extern (C) wchar* qtd_QString_utf16(void* __this_nativeId); | |
107 private extern (C) int qtd_QString_size(void* __this_nativeId); | |
108 private extern (C) void qtd_QString_operatorAssign(void* __this_nativeId, string text); | |
109 private extern (C) void* qtd_QString_new_fromUtf8_at(void* place, string text); | |
110 | |
111 private extern (C) void qtd_QString_placed_ctor(void* place); | |
112 private extern (C) void qtd_QString_assign_fromUtf8(QString *__qt_this, string text); |