comparison dwtx/dwtxhelper/mangoicu/UMessageFormat.d @ 91:11e8159caf7a

make the mango icu fork work.
author Frank Benoit <benoit@tionex.de>
date Mon, 07 Jul 2008 15:53:07 +0200
parents 040da1cb0d76
children f05207c07a98
comparison
equal deleted inserted replaced
90:7ffeace6c47f 91:11e8159caf7a
80 All trademarks and registered trademarks mentioned herein are the 80 All trademarks and registered trademarks mentioned herein are the
81 property of their respective owners. 81 property of their respective owners.
82 82
83 *******************************************************************************/ 83 *******************************************************************************/
84 84
85 module dwtx.dwthelper.mangoicu.UMessageFormat; 85 module dwtx.dwtxhelper.mangoicu.UMessageFormat;
86 86
87 private import dwtx.dwthelper.mangoicu.ICU, 87 private import dwtx.dwtxhelper.mangoicu.ICU,
88 dwtx.dwthelper.mangoicu.UString; 88 dwtx.dwtxhelper.mangoicu.UString;
89 89
90 public import dwtx.dwthelper.mangoicu.ULocale; 90 public import dwtx.dwtxhelper.mangoicu.ULocale;
91 91
92 /******************************************************************************* 92 /*******************************************************************************
93 93
94 Provides means to produce concatenated messages in language-neutral 94 Provides means to produce concatenated messages in language-neutral
95 way. Use this for all concatenations that show up to end users. Takes 95 way. Use this for all concatenations that show up to end users. Takes
112 112
113 ***********************************************************************/ 113 ***********************************************************************/
114 114
115 this (wchar[] pattern, inout ULocale locale = ULocale.Default) 115 this (wchar[] pattern, inout ULocale locale = ULocale.Default)
116 { 116 {
117 Error e; 117 UErrorCode e;
118 118
119 handle = umsg_open (pattern.ptr, pattern.length, toString(locale.name), null, e); 119 handle = umsg_open (pattern.ptr, pattern.length, toString(locale.name), null, e);
120 testError (e, "failed to open message formatter"); 120 testError (e, "failed to open message formatter");
121 } 121 }
122 122
125 Open a message formatter with given pattern and for the 125 Open a message formatter with given pattern and for the
126 given locale. 126 given locale.
127 127
128 ***********************************************************************/ 128 ***********************************************************************/
129 129
130 this (UText pattern, inout ULocale locale = ULocale.Default) 130 this (UStringView pattern, inout ULocale locale = ULocale.Default)
131 { 131 {
132 this (pattern.get, locale); 132 this (pattern.get, locale);
133 } 133 }
134 134
135 /*********************************************************************** 135 /***********************************************************************
173 173
174 Sets the pattern 174 Sets the pattern
175 175
176 ***********************************************************************/ 176 ***********************************************************************/
177 177
178 UMessageFormat setPattern (UText pattern) 178 UMessageFormat setPattern (UStringView pattern)
179 { 179 {
180 Error e; 180 UErrorCode e;
181 181
182 umsg_applyPattern (handle, pattern.get.ptr, pattern.len, null, e); 182 umsg_applyPattern (handle, pattern.get.ptr, pattern.len, null, e);
183 testError (e, "failed to set formatter pattern"); 183 testError (e, "failed to set formatter pattern");
184 return this; 184 return this;
185 } 185 }
190 190
191 ***********************************************************************/ 191 ***********************************************************************/
192 192
193 UMessageFormat getPattern (UString s) 193 UMessageFormat getPattern (UString s)
194 { 194 {
195 uint fmt (wchar* dst, uint length, inout Error e) 195 uint fmt (wchar* dst, uint length, inout UErrorCode e)
196 { 196 {
197 return umsg_toPattern (handle, dst, length, e); 197 return umsg_toPattern (handle, dst, length, e);
198 } 198 }
199 199
200 s.format (&fmt, "failed to get formatter pattern"); 200 s.format (&fmt, "failed to get formatter pattern");
210 210
211 ***********************************************************************/ 211 ***********************************************************************/
212 212
213 UMessageFormat format (UString s, Args* list) 213 UMessageFormat format (UString s, Args* list)
214 { 214 {
215 uint fmt (wchar* dst, uint length, inout Error e) 215 uint fmt (wchar* dst, uint length, inout UErrorCode e)
216 { 216 {
217 return umsg_vformat (handle, dst, length, list.args.ptr, e); 217 return umsg_vformat (handle, dst, length, list.args.ptr, e);
218 } 218 }
219 219
220 s.format (&fmt, "failed to format pattern"); 220 s.format (&fmt, "failed to format pattern");
272 272
273 /*************************************************************** 273 /***************************************************************
274 274
275 ***************************************************************/ 275 ***************************************************************/
276 276
277 Args* add (UText x) 277 Args* add (UStringView x)
278 { 278 {
279 args[index] = cast(uint) cast(wchar*) x.get(); 279 args[index] = cast(uint) cast(wchar*) x.get();
280 ++index; 280 ++index;
281 return this; 281 return this;
282 } 282 }
330 330
331 ***********************************************************************/ 331 ***********************************************************************/
332 332
333 private static extern (C) 333 private static extern (C)
334 { 334 {
335 Handle function (wchar*, uint, char*, void*, inout Error) umsg_open; 335 Handle function (wchar*, uint, char*, void*, inout UErrorCode) umsg_open;
336 void function (Handle) umsg_close; 336 void function (Handle) umsg_close;
337 void function (Handle, char*) umsg_setLocale; 337 void function (Handle, char*) umsg_setLocale;
338 char* function (Handle) umsg_getLocale; 338 char* function (Handle) umsg_getLocale;
339 uint function (Handle, wchar*, uint, inout Error) umsg_toPattern; 339 uint function (Handle, wchar*, uint, inout UErrorCode) umsg_toPattern;
340 void function (Handle, wchar*, uint, void*, inout Error) umsg_applyPattern; 340 void function (Handle, wchar*, uint, void*, inout UErrorCode) umsg_applyPattern;
341 uint function (Handle, wchar*, uint, void*, inout Error) umsg_vformat; 341 uint function (Handle, wchar*, uint, void*, inout UErrorCode) umsg_vformat;
342 } 342 }
343 343
344 /*********************************************************************** 344 /***********************************************************************
345 345
346 ***********************************************************************/ 346 ***********************************************************************/