@@ -158,3 +158,286 @@ CesiumMetadataValueTypeToTrueType(FCesiumMetadataValueType ValueType) {
158
158
159
159
return ECesiumMetadataTrueType_DEPRECATED::None_DEPRECATED;
160
160
}
161
+
162
+ // bool CesiumMetadataConversions<bool, std::string_view>::convert(
163
+ // const std::string_view& from,
164
+ // bool defaultValue) noexcept {
165
+ // FString f(from.size(), from.data());
166
+ //
167
+ // if (f.Compare("1", ESearchCase::IgnoreCase) == 0 ||
168
+ // f.Compare("true", ESearchCase::IgnoreCase) == 0 ||
169
+ // f.Compare("yes", ESearchCase::IgnoreCase) == 0) {
170
+ // return true;
171
+ // }
172
+ //
173
+ // if (f.Compare("0", ESearchCase::IgnoreCase) == 0 ||
174
+ // f.Compare("false", ESearchCase::IgnoreCase) == 0 ||
175
+ // f.Compare("no", ESearchCase::IgnoreCase) == 0) {
176
+ // return false;
177
+ // }
178
+ //
179
+ // return defaultValue;
180
+ // }
181
+ //
182
+ // template <typename TTo, typename TFrom>
183
+ // TTo CesiumMetadataConversions<
184
+ // TTo,
185
+ // TFrom,
186
+ // std::enable_if_t<
187
+ // CesiumGltf::IsMetadataInteger<TTo>::value &&
188
+ // CesiumGltf::IsMetadataInteger<TFrom>::value &&
189
+ // !std::is_same_v<TTo, TFrom>>>::
190
+ // convert(TFrom from, TTo defaultValue) noexcept {
191
+ // return CesiumUtility::losslessNarrowOrDefault(from, defaultValue);
192
+ // }
193
+ //
194
+ // template struct CesiumMetadataConversions<int8_t, uint8_t, void>;
195
+ // template struct CesiumMetadataConversions<int8_t, int16_t, void>;
196
+ // template struct CesiumMetadataConversions<int8_t, uint16_t, void>;
197
+ // template struct CesiumMetadataConversions<int8_t, int32_t, void>;
198
+ // template struct CesiumMetadataConversions<int8_t, uint32_t, void>;
199
+ // template struct CesiumMetadataConversions<int8_t, int64_t, void>;
200
+ // template struct CesiumMetadataConversions<int8_t, uint64_t, void>;
201
+ //
202
+ // template struct CesiumMetadataConversions<uint8_t, int8_t, void>;
203
+ // template struct CesiumMetadataConversions<uint8_t, int16_t, void>;
204
+ // template struct CesiumMetadataConversions<uint8_t, uint16_t, void>;
205
+ // template struct CesiumMetadataConversions<uint8_t, int32_t, void>;
206
+ // template struct CesiumMetadataConversions<uint8_t, uint32_t, void>;
207
+ // template struct CesiumMetadataConversions<uint8_t, int64_t, void>;
208
+ // template struct CesiumMetadataConversions<uint8_t, uint64_t, void>;
209
+ //
210
+ // template struct CesiumMetadataConversions<int16_t, int8_t, void>;
211
+ // template struct CesiumMetadataConversions<int16_t, uint8_t, void>;
212
+ // template struct CesiumMetadataConversions<int16_t, uint16_t, void>;
213
+ // template struct CesiumMetadataConversions<int16_t, int32_t, void>;
214
+ // template struct CesiumMetadataConversions<int16_t, uint32_t, void>;
215
+ // template struct CesiumMetadataConversions<int16_t, int64_t, void>;
216
+ // template struct CesiumMetadataConversions<int16_t, uint64_t, void>;
217
+ //
218
+ // template struct CesiumMetadataConversions<uint16_t, int8_t, void>;
219
+ // template struct CesiumMetadataConversions<uint16_t, uint8_t, void>;
220
+ // template struct CesiumMetadataConversions<uint16_t, int16_t, void>;
221
+ // template struct CesiumMetadataConversions<uint16_t, int32_t, void>;
222
+ // template struct CesiumMetadataConversions<uint16_t, uint32_t, void>;
223
+ // template struct CesiumMetadataConversions<uint16_t, int64_t, void>;
224
+ // template struct CesiumMetadataConversions<uint16_t, uint64_t, void>;
225
+ //
226
+ // template struct CesiumMetadataConversions<int32_t, int8_t, void>;
227
+ // template struct CesiumMetadataConversions<int32_t, uint8_t, void>;
228
+ // template struct CesiumMetadataConversions<int32_t, int16_t, void>;
229
+ // template struct CesiumMetadataConversions<int32_t, uint16_t, void>;
230
+ // template struct CesiumMetadataConversions<int32_t, uint32_t, void>;
231
+ // template struct CesiumMetadataConversions<int32_t, int64_t, void>;
232
+ // template struct CesiumMetadataConversions<int32_t, uint64_t, void>;
233
+ //
234
+ // template struct CesiumMetadataConversions<uint32_t, int8_t, void>;
235
+ // template struct CesiumMetadataConversions<uint32_t, uint8_t, void>;
236
+ // template struct CesiumMetadataConversions<uint32_t, int16_t, void>;
237
+ // template struct CesiumMetadataConversions<uint32_t, uint16_t, void>;
238
+ // template struct CesiumMetadataConversions<uint32_t, int32_t, void>;
239
+ // template struct CesiumMetadataConversions<uint32_t, int64_t, void>;
240
+ // template struct CesiumMetadataConversions<uint32_t, uint64_t, void>;
241
+ //
242
+ // template struct CesiumMetadataConversions<int64_t, int8_t, void>;
243
+ // template struct CesiumMetadataConversions<int64_t, uint8_t, void>;
244
+ // template struct CesiumMetadataConversions<int64_t, int16_t, void>;
245
+ // template struct CesiumMetadataConversions<int64_t, uint16_t, void>;
246
+ // template struct CesiumMetadataConversions<int64_t, int32_t, void>;
247
+ // template struct CesiumMetadataConversions<int64_t, uint32_t, void>;
248
+ // template struct CesiumMetadataConversions<int64_t, uint64_t, void>;
249
+ //
250
+ // template struct CesiumMetadataConversions<uint64_t, int8_t, void>;
251
+ // template struct CesiumMetadataConversions<uint64_t, uint8_t, void>;
252
+ // template struct CesiumMetadataConversions<uint64_t, int16_t, void>;
253
+ // template struct CesiumMetadataConversions<uint64_t, uint16_t, void>;
254
+ // template struct CesiumMetadataConversions<uint64_t, int32_t, void>;
255
+ // template struct CesiumMetadataConversions<uint64_t, uint32_t, void>;
256
+ // template struct CesiumMetadataConversions<uint64_t, int64_t, void>;
257
+ //
258
+ // template <typename TTo, typename TFrom>
259
+ // TTo CesiumMetadataConversions<
260
+ // TTo,
261
+ // TFrom,
262
+ // std::enable_if_t<
263
+ // CesiumGltf::IsMetadataInteger<TTo>::value &&
264
+ // CesiumGltf::IsMetadataFloating<TFrom>::value>>::
265
+ // convert(TFrom from, TTo defaultValue) noexcept {
266
+ // if (double(std::numeric_limits<TTo>::max()) < from ||
267
+ // double(std::numeric_limits<TTo>::lowest()) > from) {
268
+ // // Floating-point number is outside the range of this integer type.
269
+ // return defaultValue;
270
+ // }
271
+ //
272
+ // return static_cast<TTo>(from);
273
+ // }
274
+ //
275
+ // template struct CesiumMetadataConversions<int8_t, float, void>;
276
+ // template struct CesiumMetadataConversions<uint8_t, float, void>;
277
+ // template struct CesiumMetadataConversions<int16_t, float, void>;
278
+ // template struct CesiumMetadataConversions<uint16_t, float, void>;
279
+ // template struct CesiumMetadataConversions<int32_t, float, void>;
280
+ // template struct CesiumMetadataConversions<uint32_t, float, void>;
281
+ // template struct CesiumMetadataConversions<int64_t, float, void>;
282
+ // template struct CesiumMetadataConversions<uint64_t, float, void>;
283
+ //
284
+ // template struct CesiumMetadataConversions<int8_t, double, void>;
285
+ // template struct CesiumMetadataConversions<uint8_t, double, void>;
286
+ // template struct CesiumMetadataConversions<int16_t, double, void>;
287
+ // template struct CesiumMetadataConversions<uint16_t, double, void>;
288
+ // template struct CesiumMetadataConversions<int32_t, double, void>;
289
+ // template struct CesiumMetadataConversions<uint32_t, double, void>;
290
+ // template struct CesiumMetadataConversions<int64_t, double, void>;
291
+ // template struct CesiumMetadataConversions<uint64_t, double, void>;
292
+ //
293
+ // template <typename TTo>
294
+ // TTo CesiumMetadataConversions<
295
+ // TTo,
296
+ // std::string_view,
297
+ // std::enable_if_t<
298
+ // CesiumGltf::IsMetadataInteger<TTo>::value && std::is_signed_v<TTo>>>::
299
+ // convert(const std::string_view& from, TTo defaultValue) noexcept {
300
+ // // Amazingly, C++ has no* string parsing functions that work with strings
301
+ // // that might not be null-terminated. So we have to copy to a std::string
302
+ // // (which _is_ guaranteed to be null terminated) before parsing.
303
+ // // * except std::from_chars, but compiler/library support for the
304
+ // // floating-point version of that method is spotty at best.
305
+ // std::string temp(from);
306
+ //
307
+ // char* pLastUsed;
308
+ // int64_t parsedValue = std::strtoll(temp.c_str(), &pLastUsed, 10);
309
+ // if (pLastUsed == temp.c_str() + temp.size()) {
310
+ // // Successfully parsed the entire string as an integer of this type.
311
+ // return CesiumUtility::losslessNarrowOrDefault(parsedValue, defaultValue);
312
+ // }
313
+ //
314
+ // // Failed to parse as an integer. Maybe we can parse as a double and
315
+ // // truncate it?
316
+ // double parsedDouble = std::strtod(temp.c_str(), &pLastUsed);
317
+ // if (pLastUsed == temp.c_str() + temp.size()) {
318
+ // // Successfully parsed the entire string as a double.
319
+ // // Convert it to an integer if we can.
320
+ // double truncated = glm::trunc(parsedDouble);
321
+ //
322
+ // int64_t asInteger = static_cast<int64_t>(truncated);
323
+ // double roundTrip = static_cast<double>(asInteger);
324
+ // if (roundTrip == truncated) {
325
+ // return CesiumUtility::losslessNarrowOrDefault(asInteger, defaultValue);
326
+ // }
327
+ // }
328
+ //
329
+ // return defaultValue;
330
+ // }
331
+ //
332
+ // template struct CesiumMetadataConversions<int8_t, std::string_view, void>;
333
+ // template struct CesiumMetadataConversions<int16_t, std::string_view, void>;
334
+ // template struct CesiumMetadataConversions<int32_t, std::string_view, void>;
335
+ // template struct CesiumMetadataConversions<int64_t, std::string_view, void>;
336
+ //
337
+ // template <typename TTo>
338
+ // TTo CesiumMetadataConversions<
339
+ // TTo,
340
+ // std::string_view,
341
+ // std::enable_if_t<
342
+ // CesiumGltf::IsMetadataInteger<TTo>::value && !std::is_signed_v<TTo>>>::
343
+ // convert(const std::string_view& from, TTo defaultValue) noexcept {
344
+ // // Amazingly, C++ has no* string parsing functions that work with strings
345
+ // // that might not be null-terminated. So we have to copy to a std::string
346
+ // // (which _is_ guaranteed to be null terminated) before parsing.
347
+ // // * except std::from_chars, but compiler/library support for the
348
+ // // floating-point version of that method is spotty at best.
349
+ // std::string temp(from);
350
+ //
351
+ // char* pLastUsed;
352
+ // uint64_t parsedValue = std::strtoull(temp.c_str(), &pLastUsed, 10);
353
+ // if (pLastUsed == temp.c_str() + temp.size()) {
354
+ // // Successfully parsed the entire string as an integer of this type.
355
+ // return CesiumUtility::losslessNarrowOrDefault(parsedValue, defaultValue);
356
+ // }
357
+ //
358
+ // // Failed to parse as an integer. Maybe we can parse as a double and
359
+ // // truncate it?
360
+ // double parsedDouble = std::strtod(temp.c_str(), &pLastUsed);
361
+ // if (pLastUsed == temp.c_str() + temp.size()) {
362
+ // // Successfully parsed the entire string as a double.
363
+ // // Convert it to an integer if we can.
364
+ // double truncated = glm::trunc(parsedDouble);
365
+ //
366
+ // uint64_t asInteger = static_cast<uint64_t>(truncated);
367
+ // double roundTrip = static_cast<double>(asInteger);
368
+ // if (roundTrip == truncated) {
369
+ // return CesiumUtility::losslessNarrowOrDefault(asInteger, defaultValue);
370
+ // }
371
+ // }
372
+ //
373
+ // return defaultValue;
374
+ // }
375
+ //
376
+ // template struct CesiumMetadataConversions<uint8_t, std::string_view, void>;
377
+ // template struct CesiumMetadataConversions<uint16_t, std::string_view, void>;
378
+ // template struct CesiumMetadataConversions<uint32_t, std::string_view, void>;
379
+ // template struct CesiumMetadataConversions<uint64_t, std::string_view, void>;
380
+ //
381
+ // float CesiumMetadataConversions<float, std::string_view>::convert(
382
+ // const std::string_view& from,
383
+ // float defaultValue) noexcept {
384
+ // // Amazingly, C++ has no* string parsing functions that work with strings
385
+ // // that might not be null-terminated. So we have to copy to a std::string
386
+ // // (which _is_ guaranteed to be null terminated) before parsing.
387
+ // // * except std::from_chars, but compiler/library support for the
388
+ // // floating-point version of that method is spotty at best.
389
+ // std::string temp(from);
390
+ //
391
+ // char* pLastUsed;
392
+ // float parsedValue = std::strtof(temp.c_str(), &pLastUsed);
393
+ // if (pLastUsed == temp.c_str() + temp.size() && !std::isinf(parsedValue)) {
394
+ // // Successfully parsed the entire string as a float.
395
+ // return parsedValue;
396
+ // }
397
+ // return defaultValue;
398
+ // }
399
+ //
400
+ // double CesiumMetadataConversions<double, std::string_view>::convert(
401
+ // const std::string_view& from,
402
+ // double defaultValue) noexcept {
403
+ // // Amazingly, C++ has no* string parsing functions that work with strings
404
+ // // that might not be null-terminated. So we have to copy to a std::string
405
+ // // (which _is_ guaranteed to be null terminated) before parsing.
406
+ // // * except std::from_chars, but compiler/library support for the
407
+ // // floating-point version of that method is spotty at best.
408
+ // std::string temp(from);
409
+ //
410
+ // char* pLastUsed;
411
+ // double parsedValue = std::strtod(temp.c_str(), &pLastUsed);
412
+ // if (pLastUsed == temp.c_str() + temp.size() && !std::isinf(parsedValue)) {
413
+ // // Successfully parsed the entire string as a double.
414
+ // return parsedValue;
415
+ // }
416
+ // return defaultValue;
417
+ // }
418
+ //
419
+ // FString CesiumMetadataConversions<FString, bool>::convert(
420
+ // bool from,
421
+ // const FString& defaultValue) noexcept {
422
+ // return from ? "true" : "false";
423
+ // }
424
+ //
425
+ // template <typename TFrom>
426
+ // FString CesiumMetadataConversions<
427
+ // FString,
428
+ // TFrom,
429
+ // std::enable_if_t<CesiumGltf::IsMetadataScalar<TFrom>::value>>::
430
+ // convert(TFrom from, const FString& defaultValue) noexcept {
431
+ // return FString(std::to_string(from).c_str());
432
+ // }
433
+ //
434
+ // template struct CesiumMetadataConversions<FString, int8_t, void>;
435
+ // template struct CesiumMetadataConversions<FString, uint8_t, void>;
436
+ // template struct CesiumMetadataConversions<FString, int16_t, void>;
437
+ // template struct CesiumMetadataConversions<FString, uint16_t, void>;
438
+ // template struct CesiumMetadataConversions<FString, int32_t, void>;
439
+ // template struct CesiumMetadataConversions<FString, uint32_t, void>;
440
+ // template struct CesiumMetadataConversions<FString, int64_t, void>;
441
+ // template struct CesiumMetadataConversions<FString, uint64_t, void>;
442
+ // template struct CesiumMetadataConversions<FString, float, void>;
443
+ // template struct CesiumMetadataConversions<FString, double, void>;
0 commit comments