Cesium for Unreal 2.13.2
Loading...
Searching...
No Matches
CesiumMetadataValue.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "CesiumGltf/PropertyTypeTraits.h"
8#include "Kismet/BlueprintFunctionLibrary.h"
9#include "UObject/ObjectMacros.h"
10#include <glm/glm.hpp>
11#include <optional>
12#include <swl/variant.hpp>
13
14#include "CesiumMetadataValue.generated.h"
15
16/**
17 * A Blueprint-accessible wrapper for a glTF metadata value.
18 */
19USTRUCT(BlueprintType)
20struct CESIUMRUNTIME_API FCesiumMetadataValue {
21 GENERATED_USTRUCT_BODY()
22
23private:
24#pragma region ValueType declaration
25 template <typename T> using ArrayView = CesiumGltf::PropertyArrayView<T>;
26 using ValueType = swl::variant<
27 swl::monostate,
28 int8_t,
29 uint8_t,
30 int16_t,
31 uint16_t,
32 int32_t,
33 uint32_t,
34 int64_t,
35 uint64_t,
36 float,
37 double,
38 bool,
39 std::string_view,
40 glm::vec<2, int8_t>,
41 glm::vec<2, uint8_t>,
42 glm::vec<2, int16_t>,
43 glm::vec<2, uint16_t>,
44 glm::vec<2, int32_t>,
45 glm::vec<2, uint32_t>,
46 glm::vec<2, int64_t>,
47 glm::vec<2, uint64_t>,
48 glm::vec<2, float>,
49 glm::vec<2, double>,
50 glm::vec<3, int8_t>,
51 glm::vec<3, uint8_t>,
52 glm::vec<3, int16_t>,
53 glm::vec<3, uint16_t>,
54 glm::vec<3, int32_t>,
55 glm::vec<3, uint32_t>,
56 glm::vec<3, int64_t>,
57 glm::vec<3, uint64_t>,
58 glm::vec<3, float>,
59 glm::vec<3, double>,
60 glm::vec<4, int8_t>,
61 glm::vec<4, uint8_t>,
62 glm::vec<4, int16_t>,
63 glm::vec<4, uint16_t>,
64 glm::vec<4, int32_t>,
65 glm::vec<4, uint32_t>,
66 glm::vec<4, int64_t>,
67 glm::vec<4, uint64_t>,
68 glm::vec<4, float>,
69 glm::vec<4, double>,
70 glm::mat<2, 2, int8_t>,
71 glm::mat<2, 2, uint8_t>,
72 glm::mat<2, 2, int16_t>,
73 glm::mat<2, 2, uint16_t>,
74 glm::mat<2, 2, int32_t>,
75 glm::mat<2, 2, uint32_t>,
76 glm::mat<2, 2, int64_t>,
77 glm::mat<2, 2, uint64_t>,
78 glm::mat<2, 2, float>,
79 glm::mat<2, 2, double>,
80 glm::mat<3, 3, int8_t>,
81 glm::mat<3, 3, uint8_t>,
82 glm::mat<3, 3, int16_t>,
83 glm::mat<3, 3, uint16_t>,
84 glm::mat<3, 3, int32_t>,
85 glm::mat<3, 3, uint32_t>,
86 glm::mat<3, 3, int64_t>,
87 glm::mat<3, 3, uint64_t>,
88 glm::mat<3, 3, float>,
89 glm::mat<3, 3, double>,
90 glm::mat<4, 4, int8_t>,
91 glm::mat<4, 4, uint8_t>,
92 glm::mat<4, 4, int16_t>,
93 glm::mat<4, 4, uint16_t>,
94 glm::mat<4, 4, int32_t>,
95 glm::mat<4, 4, uint32_t>,
96 glm::mat<4, 4, int64_t>,
97 glm::mat<4, 4, uint64_t>,
98 glm::mat<4, 4, float>,
99 glm::mat<4, 4, double>,
172#pragma endregion
173
174public:
175 /**
176 * Constructs an empty metadata value with unknown type.
177 */
178 FCesiumMetadataValue() : _value(swl::monostate{}), _valueType(), _storage() {}
179
180 /**
181 * Constructs a metadata value with the given input.
182 *
183 * @param Value The value to be stored in this struct.
184 */
185 template <typename T>
186 explicit FCesiumMetadataValue(const T& Value)
187 : _value(Value), _valueType(), _storage() {
189 ECesiumMetadataComponentType componentType;
190 bool isArray;
192 using ArrayType = typename CesiumGltf::MetadataArrayType<T>::type;
193 type =
195 componentType = ECesiumMetadataComponentType(
197 isArray = true;
198 } else {
200 componentType = ECesiumMetadataComponentType(
202 isArray = false;
203 }
204 _valueType = {type, componentType, isArray};
205 }
206
207 template <typename ArrayType>
210 : FCesiumMetadataValue(CesiumGltf::PropertyArrayCopy<ArrayType>(Copy)) {}
211
212 template <typename ArrayType>
214 : _value(), _valueType(), _storage() {
215 this->_value = std::move(Copy).toViewAndExternalBuffer(this->_storage);
216
221 bool isArray = true;
222 this->_valueType = {type, componentType, isArray};
223 }
224
225 /**
226 * Constructs a metadata value with the given optional input.
227 *
228 * @param MaybeValue The optional value to be stored in this struct.
229 */
230 template <typename T>
231 explicit FCesiumMetadataValue(const std::optional<T>& MaybeValue)
232 : _value(), _valueType(), _storage() {
233 if (!MaybeValue) {
234 return;
235 }
236
237 FCesiumMetadataValue temp(*MaybeValue);
238 this->_value = std::move(temp._value);
239 this->_valueType = std::move(temp._valueType);
240 this->_storage = std::move(temp._storage);
241 }
242
247
248private:
249 ValueType _value;
250 FCesiumMetadataValueType _valueType;
251 std::vector<std::byte> _storage;
252
254};
255
256UCLASS()
258 : public UBlueprintFunctionLibrary {
259 GENERATED_BODY()
260
261public:
262 /**
263 * Gets the best-fitting Blueprints type for this value. For the most precise
264 * representation of the value possible from Blueprints, you should retrieve
265 * it using this type.
266 */
267 UFUNCTION(
268 BlueprintCallable,
269 BlueprintPure,
270 Category = "Cesium|Metadata|Value")
272 GetBlueprintType(UPARAM(ref) const FCesiumMetadataValue& Value);
273
274 /**
275 * Gets the best-fitting Blueprints type for the elements of this array value.
276 * If the given value is not of an array type, this returns None.
277 */
278 UFUNCTION(
279 BlueprintCallable,
280 BlueprintPure,
281 Category = "Cesium|Metadata|Value")
284
285 /**
286 * Gets the type of the metadata value as defined in the
287 * EXT_structural_metadata extension. Many of these types are not accessible
288 * from Blueprints, but can be converted to a Blueprint-accessible type.
289 */
290 UFUNCTION(
291 BlueprintCallable,
292 BlueprintPure,
293 Category = "Cesium|Metadata|Value")
295 GetValueType(UPARAM(ref) const FCesiumMetadataValue& Value);
296
297 PRAGMA_DISABLE_DEPRECATION_WARNINGS
298 /**
299 * Gets true type of the value. Many of these types are not accessible
300 * from Blueprints, but can be converted to a Blueprint-accessible type.
301 */
302 UFUNCTION(
303 BlueprintCallable,
304 BlueprintPure,
305 Meta =
306 (DeprecatedFunction,
307 DeprecationMessage =
308 "CesiumMetadataTrueType is deprecated. Use GetValueType to get the CesiumMetadataValueType instead."))
310 GetTrueType(UPARAM(ref) const FCesiumMetadataValue& Value);
311
312 /**
313 * Gets true type of the elements in the array. If this value is not an array,
314 * the component type will be None. Many of these types are not accessible
315 * from Blueprints, but can be converted to a Blueprint-accessible type.
316 */
317 UFUNCTION(
318 BlueprintCallable,
319 BlueprintPure,
320 Meta =
321 (DeprecatedFunction,
322 DeprecationMessage =
323 "CesiumMetadataTrueType is deprecated. Use GetValueType to get the CesiumMetadataValueType instead."))
326
327 PRAGMA_ENABLE_DEPRECATION_WARNINGS
328
329 /**
330 * Attempts to retrieve the value as a boolean.
331 *
332 * If the value is a boolean, it is returned as-is.
333 *
334 * If the value is a scalar, zero is converted to false, while any other
335 * value is converted to true.
336 *
337 * If the value is a string, "0", "false", and "no" (case-insensitive) are
338 * converted to false, while "1", "true", and "yes" are converted to true.
339 * All other strings, including strings that can be converted to numbers,
340 * will return the default value.
341 *
342 * All other types return the default value.
343 *
344 * @param value The metadata value to retrieve.
345 * @param DefaultValue The default value to use if the given value cannot
346 * be converted to a Boolean.
347 * @return The value as a Boolean.
348 */
349 UFUNCTION(
350 BlueprintCallable,
351 BlueprintPure,
352 Category = "Cesium|Metadata|Value")
353 static bool
354 GetBoolean(UPARAM(ref) const FCesiumMetadataValue& value, bool DefaultValue);
355
356 /**
357 * Attempts to retrieve the value as an unsigned 8-bit integer.
358 *
359 * If the value is an integer between 0 and 255, it is returned
360 * as-is.
361 *
362 * If the value is a floating-point number in the aforementioned range, it is
363 * truncated (rounded toward zero) and returned.
364 *
365 * If the value is a boolean, 1 is returned for true and 0 for false.
366 *
367 * If the value is a string and the entire string can be parsed as an
368 * integer between 0 and 255, the parsed value is returned. The string is
369 * parsed in a locale-independent way and does not support the use of commas
370 * or other delimiters to group digits together.
371 *
372 * In all other cases, the default value is returned.
373 *
374 * @param Value The metadata value to retrieve.
375 * @param DefaultValue The default value to use if the given value cannot
376 * be converted to a Byte.
377 * @return The value as a Byte.
378 */
379 UFUNCTION(
380 BlueprintCallable,
381 BlueprintPure,
382 Category = "Cesium|Metadata|Value")
383 static uint8
384 GetByte(UPARAM(ref) const FCesiumMetadataValue& Value, uint8 DefaultValue);
385
386 /**
387 * Attempts to retrieve the value as a signed 32-bit integer.
388 *
389 * If the value is an integer between -2,147,483,648 and 2,147,483,647,
390 * it is returned as-is.
391 *
392 * If the value is a floating-point number in the aforementioned range, it is
393 * truncated (rounded toward zero) and returned;
394 *
395 * If the value is a boolean, 1 is returned for true and 0 for false.
396 *
397 * If the value is a string and the entire string can be parsed as an
398 * integer in the valid range, the parsed value is returned. If it can be
399 * parsed as a floating-point number, the parsed value is truncated (rounded
400 * toward zero). In either case, the string is parsed in a locale-independent
401 * way and does not support the use of commas or other delimiters to group
402 * digits together.
403 *
404 * In all other cases, the default value is returned.
405 *
406 * @param Value The metadata value to retrieve.
407 * @param DefaultValue The default value to use if the given value cannot
408 * be converted to an Integer.
409 * @return The value as an Integer.
410 */
411 UFUNCTION(
412 BlueprintCallable,
413 BlueprintPure,
414 Category = "Cesium|Metadata|Value")
415 static int32
416 GetInteger(UPARAM(ref) const FCesiumMetadataValue& Value, int32 DefaultValue);
417
418 /**
419 * Attempts to retrieve the value as a signed 64-bit integer.
420 *
421 * If the value is an integer and between -2^63 and (2^63 - 1),
422 * it is returned as-is.
423 *
424 * If the value is a floating-point number in the aforementioned range, it
425 * is truncated (rounded toward zero) and returned;
426 *
427 * If the value is a boolean, 1 is returned for true and 0 for false.
428 *
429 * If the value is a string and the entire string can be parsed as an
430 * integer in the valid range, the parsed value is returned. If it can be
431 * parsed as a floating-point number, the parsed value is truncated (rounded
432 * toward zero). In either case, the string is parsed in a locale-independent
433 * way and does not support the use of commas or other delimiters to group
434 * digits together.
435 *
436 * In all other cases, the default value is returned.
437 *
438 * @param Value The metadata value to retrieve.
439 * @param DefaultValue The default value to use if the given value cannot
440 * be converted to an Integer64.
441 * @return The value as an Integer64.
442 */
443 UFUNCTION(
444 BlueprintCallable,
445 BlueprintPure,
446 Category = "Cesium|Metadata|Value")
447 static int64 GetInteger64(
448 UPARAM(ref) const FCesiumMetadataValue& Value,
449 int64 DefaultValue);
450
451 /**
452 * Attempts to retrieve the value as a single-precision floating-point number.
453 *
454 * If the value is already a single-precision floating-point number, it is
455 * returned as-is.
456 *
457 * If the value is a scalar of any other type within the range of values that
458 * a single-precision float can represent, it is converted to its closest
459 * representation as a single-precision float and returned.
460 *
461 * If the value is a boolean, 1.0f is returned for true and 0.0f for false.
462 *
463 * If the value is a string, and the entire string can be parsed as a
464 * number, the parsed value is returned. The string is parsed in a
465 * locale-independent way and does not support the use of a comma or other
466 * delimiter to group digits togther.
467 *
468 * In all other cases, the default value is returned.
469 *
470 * @param Value The metadata value to retrieve.
471 * @param DefaultValue The default value to use if the given value cannot
472 * be converted to a Float.
473 * @return The value as a Float.
474 */
475 UFUNCTION(
476 BlueprintCallable,
477 BlueprintPure,
478 Category = "Cesium|Metadata|Value")
479 static float
480 GetFloat(UPARAM(ref) const FCesiumMetadataValue& Value, float DefaultValue);
481
482 /**
483 * Attempts to retrieve the value as a double-precision floating-point number.
484 *
485 * If the value is a single- or double-precision floating-point number, it is
486 * returned as-is.
487 *
488 * If the value is an integer, it is converted to the closest representable
489 * double-precision floating-point number.
490 *
491 * If the value is a boolean, 1.0 is returned for true and 0.0 for false.
492 *
493 * If the value is a string and the entire string can be parsed as a
494 * number, the parsed value is returned. The string is parsed in a
495 * locale-independent way and does not support the use of commas or other
496 * delimiters to group digits together.
497 *
498 * In all other cases, the default value is returned.
499 *
500 * @param Value The metadata value to retrieve.
501 * @param DefaultValue The default value to use if the given value cannot
502 * be converted to a Float64.
503 * @return The value as a Float64.
504 */
505 UFUNCTION(
506 BlueprintCallable,
507 BlueprintPure,
508 Category = "Cesium|Metadata|Value")
509 static double GetFloat64(
510 UPARAM(ref) const FCesiumMetadataValue& Value,
511 double DefaultValue);
512
513 /**
514 * Attempts to retrieve the value as a FIntPoint.
515 *
516 * If the value is a 2-dimensional vector, its components will be converted to
517 * 32-bit signed integers if possible.
518 *
519 * If the value is a 3- or 4-dimensional vector, it will use the first two
520 * components to construct the FIntPoint.
521 *
522 * If the value is a scalar that can be converted to a 32-bit signed integer,
523 * the resulting FIntPoint will have this value in both of its components.
524 *
525 * If the value is a boolean, (1, 1) is returned for true, while (0, 0) is
526 * returned for false.
527 *
528 * If the value is a string that can be parsed as a FIntPoint, the parsed
529 * value is returned. The string must be formatted as "X=... Y=...".
530 *
531 * In all other cases, the default value is returned. In all vector cases, if
532 * any of the relevant components cannot be represented as a 32-bit signed,
533 * the default value is returned.
534 *
535 * @param Value The metadata value to retrieve.
536 * @param DefaultValue The default value to use if the given value cannot
537 * be converted to a FIntPoint.
538 * @return The value as a FIntPoint.
539 */
540 UFUNCTION(
541 BlueprintCallable,
542 BlueprintPure,
543 Category = "Cesium|Metadata|Value")
544 static FIntPoint GetIntPoint(
545 UPARAM(ref) const FCesiumMetadataValue& Value,
546 const FIntPoint& DefaultValue);
547
548 /**
549 * Attempts to retrieve the value as a FVector2D.
550 *
551 * If the value is a 2-dimensional vector, its components will be converted to
552 * double-precision floating-point numbers.
553 *
554 * If the value is a 3- or 4-dimensional vector, it will use the first two
555 * components to construct the FVector2D.
556 *
557 * If the value is a scalar, the resulting FVector2D will have this value in
558 * both of its components.
559 *
560 * If the value is a boolean, (1.0, 1.0) is returned for true, while (0.0,
561 * 0.0) is returned for false.
562 *
563 * If the value is a string that can be parsed as a FVector2D, the parsed
564 * value is returned. The string must be formatted as "X=... Y=...".
565 *
566 * In all other cases, the default value is returned.
567 *
568 * @param Value The metadata value to retrieve.
569 * @param DefaultValue The default value to use if the given value cannot
570 * be converted to a FIntPoint.
571 * @return The value as a FIntPoint.
572 */
573 UFUNCTION(
574 BlueprintCallable,
575 BlueprintPure,
576 Category = "Cesium|Metadata|Value")
577 static FVector2D GetVector2D(
578 UPARAM(ref) const FCesiumMetadataValue& Value,
579 const FVector2D& DefaultValue);
580
581 /**
582 * Attempts to retrieve the value as a FIntVector.
583 *
584 * If the value is a 3-dimensional vector, its components will be converted to
585 * 32-bit signed integers if possible.
586 *
587 * If the value is a 4-dimensional vector, it will use the first three
588 * components to construct the FIntVector.
589 *
590 * If the value is a 2-dimensional vector, it will become the XY-components of
591 * the FIntVector. The Z component will be set to zero.
592 *
593 * If the value is a scalar that can be converted to a 32-bit signed integer,
594 * the resulting FIntVector will have this value in all of its components.
595 *
596 * If the value is a boolean, (1, 1, 1) is returned for true, while (0, 0, 0)
597 * is returned for false.
598 *
599 * If the value is a string that can be parsed as a FIntVector, the parsed
600 * value is returned. The string must be formatted as "X=... Y=... Z=".
601 *
602 * In all other cases, the default value is returned. In all vector cases, if
603 * any of the relevant components cannot be represented as a 32-bit signed
604 * integer, the default value is returned.
605 *
606 * @param Value The metadata value to retrieve.
607 * @param DefaultValue The default value to use if the given value cannot
608 * be converted to a FIntVector.
609 * @return The value as a FIntVector.
610 */
611 UFUNCTION(
612 BlueprintCallable,
613 BlueprintPure,
614 Category = "Cesium|Metadata|Value")
615 static FIntVector GetIntVector(
616 UPARAM(ref) const FCesiumMetadataValue& Value,
617 const FIntVector& DefaultValue);
618
619 /**
620 * Attempts to retrieve the value as a FVector3f.
621 *
622 * If the value is a 3-dimensional vector, its components will be converted to
623 * the closest representable single-precision floats, if possible.
624 *
625 * If the value is a 4-dimensional vector, a FVector3f containing the first
626 * three components will be returned.
627 *
628 * If the value is a 2-dimensional vector, it will become the XY-components of
629 * the FVector3f. The Z-component will be set to zero.
630 *
631 * If the value is a scalar that can be converted to a single-precision
632 * floating-point number, then the resulting FVector3f will have this value in
633 * all of its components.
634 *
635 * If the value is a boolean, (1.0f, 1.0f, 1.0f) is returned for true, while
636 * (0.0f, 0.0f, 0.0f) is returned for false.
637 *
638 * If the value is a string that can be parsed as a FVector3f, the parsed
639 * value is returned. The string must be formatted as "X=... Y=... Z=".
640 *
641 * In all other cases, the default value is returned. In all vector cases, if
642 * any of the relevant components cannot be represented as a single-precision
643 * float, the default value is returned.
644 *
645 * @param Value The metadata value to retrieve.
646 * @param DefaultValue The default value to use if the given value cannot
647 * be converted to a FVector3f.
648 * @return The value as a FVector3f.
649 */
650 UFUNCTION(
651 BlueprintCallable,
652 BlueprintPure,
653 Category = "Cesium|Metadata|Value")
654 static FVector3f GetVector3f(
655 UPARAM(ref) const FCesiumMetadataValue& Value,
656 const FVector3f& DefaultValue);
657
658 /**
659 * Attempts to retrieve the value as a FVector.
660 *
661 * If the value is a 3-dimensional vector, its components will be converted to
662 * double-precision floating-point numbers.
663 *
664 * If the value is a 4-dimensional vector, a FVector containing the first
665 * three components will be returned.
666 *
667 * If the value is a 2-dimensional vector, it will become the XY-components of
668 * the FVector. The Z-component will be set to zero.
669 *
670 * If the value is a scalar, then the resulting FVector will have this value
671 * as a double-precision floating-point number in all of its components.
672 *
673 * If the value is a boolean, (1.0, 1.0, 1.0) is returned for true, while
674 * (0.0, 0.0, 0.0) is returned for false.
675 *
676 * If the value is a string that can be parsed as a FVector, the parsed
677 * value is returned. The string must be formatted as "X=... Y=... Z=".
678 *
679 * In all other cases, the default value is returned.
680 *
681 * @param Value The metadata value to retrieve.
682 * @param DefaultValue The default value to use if the given value cannot
683 * be converted to a FVector.
684 * @return The value as a FVector.
685 */
686 UFUNCTION(
687 BlueprintCallable,
688 BlueprintPure,
689 Category = "Cesium|Metadata|Value")
690 static FVector GetVector(
691 UPARAM(ref) const FCesiumMetadataValue& Value,
692 const FVector& DefaultValue);
693
694 /**
695 * Attempts to retrieve the value as a FVector4.
696 *
697 * If the value is a 4-dimensional vector, its components will be converted to
698 * double-precision floating-point numbers.
699 *
700 * If the value is a 3-dimensional vector, it will become the XYZ-components
701 * of the FVector4. The W-component will be set to zero.
702 *
703 * If the value is a 2-dimensional vector, it will become the XY-components of
704 * the FVector4. The Z- and W-components will be set to zero.
705 *
706 * If the value is a scalar, then the resulting FVector4 will have this value
707 * as a double-precision floating-point number in all of its components.
708 *
709 * If the value is a boolean, (1.0, 1.0, 1.0, 1.0) is returned for true, while
710 * (0.0, 0.0, 0.0, 0.0) is returned for false.
711 *
712 * If the value is a string that can be parsed as a FVector4, the parsed
713 * value is returned. This follows the rules of FVector4::InitFromString. The
714 * string must be formatted as "X=... Y=... Z=... W=...". The W-component is
715 * optional; if absent, it will be set to 1.0.
716 *
717 * In all other cases, the default value is returned.
718 *
719 * @param Value The metadata value to retrieve.
720 * @param DefaultValue The default value to use if the given value cannot
721 * be converted to a FVector4.
722 * @return The value as a FVector4.
723 */
724 UFUNCTION(
725 BlueprintCallable,
726 BlueprintPure,
727 Category = "Cesium|Metadata|Value")
728 static FVector4 GetVector4(
729 UPARAM(ref) const FCesiumMetadataValue& Value,
730 const FVector4& DefaultValue);
731
732 /**
733 * Attempts to retrieve the value as a FMatrix.
734 *
735 * If the value is a 4-by-4 matrix, its components will be converted to
736 * double-precision floating-point numbers.
737 *
738 * If the value is a 3-by-3 matrix, it will initialize the corresponding
739 * entries of the FMatrix, while all other entries are set to zero. In other
740 * words, the 3-by-3 matrix is returned in an FMatrix where the fourth row and
741 * column are filled with zeroes.
742 *
743 * If the value is a 2-by-2 matrix, it will initialize the corresponding
744 * entries of the FMatrix, while all other entries are set to zero. In other
745 * words, the 2-by-2 matrix is returned in an FMatrix where the third and
746 * fourth rows / columns are filled with zeroes.
747 *
748 * If the value is a scalar, then the resulting FMatrix will have this value
749 * along its diagonal, including the very last component. All other entries
750 * will be zero.
751 *
752 * If the value is a boolean, it is converted to 1.0 for true and 0.0 for
753 * false. Then, the resulting FMatrix will have this value along its diagonal,
754 * including the very last component. All other entries will be zero.
755 *
756 * In all other cases, the default value is returned.
757 *
758 * @param Value The metadata value to retrieve.
759 * @param DefaultValue The default value to use if the given value cannot
760 * be converted to a FMatrix.
761 * @return The value as a FMatrix.
762 */
763 UFUNCTION(
764 BlueprintCallable,
765 BlueprintPure,
766 Category = "Cesium|Metadata|Value")
767 static FMatrix GetMatrix(
768 UPARAM(ref) const FCesiumMetadataValue& Value,
769 const FMatrix& DefaultValue);
770
771 /**
772 * Attempts to retrieve the value as a FString.
773 *
774 * String properties are returned as-is.
775 *
776 * Scalar values are converted to a string with `std::to_string`.
777 *
778 * Boolean properties are converted to "true" or "false".
779 *
780 * Vector properties are returned as strings in the format "X=... Y=... Z=...
781 * W=..." depending on how many components they have.
782 *
783 * Matrix properties are returned as strings row-by-row, where each row's
784 * values are printed between square brackets. For example, a 2-by-2 matrix
785 * will be printed out as "[A B] [C D]".
786 *
787 * Array properties return the default value.
788 *
789 * @param Value The metadata value to retrieve.
790 * @param DefaultValue The default value to use if the given value cannot
791 * be converted to a FString.
792 * @return The value as a FString.
793 */
794 UFUNCTION(
795 BlueprintCallable,
796 BlueprintPure,
797 Category = "Cesium|Metadata|Value")
798 static FString GetString(
799 UPARAM(ref) const FCesiumMetadataValue& Value,
800 const FString& DefaultValue);
801
802 /**
803 * Attempts to retrieve the value as a FCesiumPropertyArray. If the property
804 * is not an array type, this returns an empty array.
805 *
806 * @param Value The metadata value to retrieve.
807 * @return The value as a FCesiumPropertyArray.
808 */
809 UFUNCTION(
810 BlueprintCallable,
811 BlueprintPure,
812 Category = "Cesium|Metadata|Value")
814 const FCesiumMetadataValue& Value);
815
816 /**
817 * Whether the value is empty, i.e., whether it does not actually represent
818 * any data. An empty value functions as a null value, and can be compared to
819 * a std::nullopt in C++. For example, when the raw value of a property
820 * matches the property's specified "no data" value, it will return an empty
821 * FCesiumMetadataValue.
822 *
823 * @param Value The metadata value to retrieve.
824 * @return Whether the value is empty.
825 */
826 UFUNCTION(
827 BlueprintCallable,
828 BlueprintPure,
829 Category = "Cesium|Metadata|Value")
830 static bool IsEmpty(UPARAM(ref) const FCesiumMetadataValue& Value);
831
832 /**
833 * Gets the given map of metadata values as a new map of strings, mapped by
834 * name. This is useful for displaying the values from a property table or
835 * property texture as strings in a user interface.
836 *
837 * Array properties cannot be converted to strings, so empty strings
838 * will be returned for their values.
839 */
840 UFUNCTION(
841 BlueprintCallable,
842 BlueprintPure,
843 Category = "Cesium|Metadata|Value")
844 static TMap<FString, FString>
845 GetValuesAsStrings(const TMap<FString, FCesiumMetadataValue>& Values);
846};
ECesiumMetadataComponentType
The component type of a metadata property in EXT_structural_metadata.
ECesiumMetadataTrueType_DEPRECATED
The type of a metadata property in EXT_feature_metadata.
ECesiumMetadataBlueprintType
The Blueprint type that can losslessly represent values of a given property.
ECesiumMetadataType
The type of a metadata property in EXT_structural_metadata.
static PRAGMA_DISABLE_DEPRECATION_WARNINGS ECesiumMetadataTrueType_DEPRECATED GetTrueType(UPARAM(ref) const FCesiumMetadataValue &Value)
Gets true type of the value.
static FVector3f GetVector3f(UPARAM(ref) const FCesiumMetadataValue &Value, const FVector3f &DefaultValue)
Attempts to retrieve the value as a FVector3f.
static double GetFloat64(UPARAM(ref) const FCesiumMetadataValue &Value, double DefaultValue)
Attempts to retrieve the value as a double-precision floating-point number.
static FVector4 GetVector4(UPARAM(ref) const FCesiumMetadataValue &Value, const FVector4 &DefaultValue)
Attempts to retrieve the value as a FVector4.
static bool IsEmpty(UPARAM(ref) const FCesiumMetadataValue &Value)
Whether the value is empty, i.e., whether it does not actually represent any data.
static FIntVector GetIntVector(UPARAM(ref) const FCesiumMetadataValue &Value, const FIntVector &DefaultValue)
Attempts to retrieve the value as a FIntVector.
static ECesiumMetadataBlueprintType GetBlueprintType(UPARAM(ref) const FCesiumMetadataValue &Value)
Gets the best-fitting Blueprints type for this value.
static int64 GetInteger64(UPARAM(ref) const FCesiumMetadataValue &Value, int64 DefaultValue)
Attempts to retrieve the value as a signed 64-bit integer.
static int32 GetInteger(UPARAM(ref) const FCesiumMetadataValue &Value, int32 DefaultValue)
Attempts to retrieve the value as a signed 32-bit integer.
static FMatrix GetMatrix(UPARAM(ref) const FCesiumMetadataValue &Value, const FMatrix &DefaultValue)
Attempts to retrieve the value as a FMatrix.
static TMap< FString, FString > GetValuesAsStrings(const TMap< FString, FCesiumMetadataValue > &Values)
Gets the given map of metadata values as a new map of strings, mapped by name.
static FString GetString(UPARAM(ref) const FCesiumMetadataValue &Value, const FString &DefaultValue)
Attempts to retrieve the value as a FString.
static ECesiumMetadataTrueType_DEPRECATED GetTrueComponentType(UPARAM(ref) const FCesiumMetadataValue &Value)
Gets true type of the elements in the array.
static FVector GetVector(UPARAM(ref) const FCesiumMetadataValue &Value, const FVector &DefaultValue)
Attempts to retrieve the value as a FVector.
static FVector2D GetVector2D(UPARAM(ref) const FCesiumMetadataValue &Value, const FVector2D &DefaultValue)
Attempts to retrieve the value as a FVector2D.
static float GetFloat(UPARAM(ref) const FCesiumMetadataValue &Value, float DefaultValue)
Attempts to retrieve the value as a single-precision floating-point number.
static ECesiumMetadataBlueprintType GetArrayElementBlueprintType(UPARAM(ref) const FCesiumMetadataValue &Value)
Gets the best-fitting Blueprints type for the elements of this array value.
static FIntPoint GetIntPoint(UPARAM(ref) const FCesiumMetadataValue &Value, const FIntPoint &DefaultValue)
Attempts to retrieve the value as a FIntPoint.
static FCesiumMetadataValueType GetValueType(UPARAM(ref) const FCesiumMetadataValue &Value)
Gets the type of the metadata value as defined in the EXT_structural_metadata extension.
static PRAGMA_ENABLE_DEPRECATION_WARNINGS bool GetBoolean(UPARAM(ref) const FCesiumMetadataValue &value, bool DefaultValue)
Attempts to retrieve the value as a boolean.
static FCesiumPropertyArray GetArray(UPARAM(ref) const FCesiumMetadataValue &Value)
Attempts to retrieve the value as a FCesiumPropertyArray.
static uint8 GetByte(UPARAM(ref) const FCesiumMetadataValue &Value, uint8 DefaultValue)
Attempts to retrieve the value as an unsigned 8-bit integer.
Represents the true value type of a metadata value, akin to the property types in EXT_structural_meta...
A Blueprint-accessible wrapper for a glTF metadata value.
FCesiumMetadataValue()
Constructs an empty metadata value with unknown type.
FCesiumMetadataValue & operator=(FCesiumMetadataValue &&rhs)
FCesiumMetadataValue & operator=(const FCesiumMetadataValue &rhs)
FCesiumMetadataValue(const std::optional< T > &MaybeValue)
Constructs a metadata value with the given optional input.
FCesiumMetadataValue(const FCesiumMetadataValue &rhs)
FCesiumMetadataValue(const T &Value)
Constructs a metadata value with the given input.
FCesiumMetadataValue(CesiumGltf::PropertyArrayCopy< ArrayType > &&Copy)
FCesiumMetadataValue(const CesiumGltf::PropertyArrayCopy< ArrayType > &Copy)
FCesiumMetadataValue(FCesiumMetadataValue &&rhs)
A Blueprint-accessible wrapper for an array property in glTF metadata.