@@ -62,28 +62,6 @@ namespace WinUWP
62
62
buffer_ = freeBuffer_;
63
63
}
64
64
65
- #ifdef __cplusplus_winrt
66
-
67
- // ---------------------------------------------------------------------------
68
- StringConvertToUTF8::StringConvertToUTF8 (Platform::String ^str)
69
- {
70
- if (!str) return ;
71
-
72
- auto count = str->Length ();
73
- auto len8 = WideCharToMultiByte (CP_UTF8, 0 , str->Data (), count, NULL , 0 , NULL , NULL );
74
-
75
- if (len8 < 1 ) return ;
76
- freeBuffer_ = (char *)malloc ((len8 + 1 ) * sizeof (char )); // callee must free
77
- memset (freeBuffer_, 0 , (len8 + 1 ) * sizeof (char ));
78
-
79
- auto result = WideCharToMultiByte (CP_UTF8, 0 , str->Data (), count, freeBuffer_, len8, NULL , NULL );
80
- if (0 == result) return ;
81
- length_ = static_cast <decltype (length_)>(len8);
82
- buffer_ = freeBuffer_;
83
- }
84
-
85
- #endif // __cplusplus_winrt
86
-
87
65
// ---------------------------------------------------------------------------
88
66
StringConvertToUTF8::~StringConvertToUTF8 ()
89
67
{
@@ -141,25 +119,6 @@ namespace WinUWP
141
119
buffer_ = freeBuffer_;
142
120
}
143
121
144
- #ifdef __cplusplus_winrt
145
-
146
- // ---------------------------------------------------------------------------
147
- StringConvertToUTF16::StringConvertToUTF16 (Platform::String ^str)
148
- {
149
- if (!str) return ;
150
- if (!str->Data ()) return ;
151
-
152
- auto count = str->Length ();
153
- freeBuffer_ = (wchar_t *)malloc ((count + 1 ) * sizeof (wchar_t ));
154
- memset (freeBuffer_, 0 , (count + 1 ) * sizeof (wchar_t ));
155
-
156
- memcpy (freeBuffer_, str->Data (), count * sizeof (wchar_t ));
157
- length_ = static_cast <decltype (length_)>(count);
158
- buffer_ = freeBuffer_;
159
- }
160
-
161
- #endif // __cplusplus_winrt
162
-
163
122
// ---------------------------------------------------------------------------
164
123
StringConvertToUTF16::~StringConvertToUTF16 ()
165
124
{
@@ -196,140 +155,6 @@ namespace WinUWP
196
155
// ---------------------------------------------------------------------------
197
156
// ---------------------------------------------------------------------------
198
157
199
- #ifdef __cplusplus_winrt
200
-
201
- // ---------------------------------------------------------------------------
202
- StringConvertToPlatformString::StringConvertToPlatformString (const char *str)
203
- {
204
- if (NULL == str) return ;
205
-
206
- StringConvertToUTF16 wstr (str);
207
- auto result = wstr.result ();
208
- if (!result) return ;
209
-
210
- buffer_ = ref new Platform::String (result);
211
- }
212
-
213
- // ---------------------------------------------------------------------------
214
- StringConvertToPlatformString::StringConvertToPlatformString (const wchar_t *str)
215
- {
216
- if (NULL == str) return ;
217
- buffer_ = ref new Platform::String (str);
218
- }
219
-
220
- // ---------------------------------------------------------------------------
221
- StringConvertToPlatformString::~StringConvertToPlatformString ()
222
- {
223
- }
224
-
225
- // ---------------------------------------------------------------------------
226
- Platform::String ^StringConvertToPlatformString::result() const
227
- {
228
- return buffer_;
229
- }
230
-
231
- // ---------------------------------------------------------------------------
232
- // ---------------------------------------------------------------------------
233
- // ---------------------------------------------------------------------------
234
- // ---------------------------------------------------------------------------
235
-
236
- // ---------------------------------------------------------------------------
237
- MainConvertToUTF8::MainConvertToUTF8 (Platform::Array<Platform::String^>^ args)
238
- {
239
- if (!args) return ;
240
-
241
- size_t length = static_cast <decltype (length)>(args->Length );
242
-
243
- argv_ = (char_type **)malloc ((length+1 )*sizeof (char_type *));
244
- memset (argv_, 0 , (length+1 )*sizeof (char_type *));
245
-
246
- for (decltype (length) iter = 0 ; iter < length; ++iter) {
247
- auto value = args->get (static_cast <unsigned int >(iter));
248
- if (!value) continue ;
249
- auto data = value->Data ();
250
- if (!data) continue ;
251
-
252
- StringConvertToUTF8 conv (value);
253
- auto result = conv.result ();
254
- if (!result) continue ;
255
-
256
- auto slen = conv.length ();
257
- argv_[iter] = (char_type *)malloc ((slen+1 )*sizeof (char_type));
258
- memset (argv_[iter], 0 , (slen+1 )*sizeof (char_type));
259
-
260
- memcpy (argv_[iter], result, slen);
261
- }
262
- }
263
-
264
- // ---------------------------------------------------------------------------
265
- MainConvertToUTF8::~MainConvertToUTF8 ()
266
- {
267
- if (NULL == argv_) return ;
268
-
269
- for (int iter = 0 ; iter < argc_; ++iter) {
270
- if (NULL == argv_[iter]) continue ;
271
- free (argv_[iter]);
272
- argv_[iter] = NULL ;
273
- }
274
- free (argv_);
275
- argv_ = NULL ;
276
- }
277
-
278
-
279
- // ---------------------------------------------------------------------------
280
- // ---------------------------------------------------------------------------
281
- // ---------------------------------------------------------------------------
282
- // ---------------------------------------------------------------------------
283
-
284
- // ---------------------------------------------------------------------------
285
- MainConvertToUTF16::MainConvertToUTF16 (Platform::Array<Platform::String^>^ args)
286
- {
287
- if (!args) return ;
288
-
289
- size_t length = static_cast <decltype (length)>(args->Length );
290
-
291
- argv_ = (char_type **)malloc ((length+1 )*sizeof (char_type *));
292
- memset (argv_, 0 , (length+1 )*sizeof (char_type *));
293
-
294
- for (decltype (length) iter = 0 ; iter < length; ++iter) {
295
- auto value = args->get (static_cast <unsigned int >(iter));
296
- if (!value) continue ;
297
- auto data = value->Data ();
298
- if (!data) continue ;
299
-
300
- StringConvertToUTF16 conv (value);
301
- auto result = conv.result ();
302
- if (!result) continue ;
303
-
304
- auto slen = conv.length ();
305
- argv_[iter] = (char_type *)malloc ((slen+1 )*sizeof (char_type));
306
- memset (argv_[iter], 0 , (slen+1 )*sizeof (char_type));
307
-
308
- memcpy (argv_[iter], result, slen);
309
- }
310
- }
311
-
312
- // ---------------------------------------------------------------------------
313
- MainConvertToUTF16::~MainConvertToUTF16 ()
314
- {
315
- if (NULL == argv_) return ;
316
-
317
- for (int iter = 0 ; iter < argc_; ++iter) {
318
- if (NULL == argv_[iter]) continue ;
319
- free (argv_[iter]);
320
- argv_[iter] = NULL ;
321
- }
322
- free (argv_);
323
- argv_ = NULL ;
324
- }
325
-
326
- #endif // __cplusplus_winrt
327
-
328
- // ---------------------------------------------------------------------------
329
- // ---------------------------------------------------------------------------
330
- // ---------------------------------------------------------------------------
331
- // ---------------------------------------------------------------------------
332
-
333
158
// ---------------------------------------------------------------------------
334
159
Environment::Environment ()
335
160
{
0 commit comments