Cesium for Unreal 2.12.0
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
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:
178 FCesiumMetadataValue() : _value(swl::monostate{}), _valueType(), _storage() {}
179
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
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:
267 UFUNCTION(
268 BlueprintCallable,
269 BlueprintPure,
270 Category = "Cesium|Metadata|Value")
272 GetBlueprintType(UPARAM(ref) const FCesiumMetadataValue& Value);
273
278 UFUNCTION(
279 BlueprintCallable,
280 BlueprintPure,
281 Category = "Cesium|Metadata|Value")
284
290 UFUNCTION(
291 BlueprintCallable,
292 BlueprintPure,
293 Category = "Cesium|Metadata|Value")
295 GetValueType(UPARAM(ref) const FCesiumMetadataValue& Value);
296
297 PRAGMA_DISABLE_DEPRECATION_WARNINGS
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
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
349 UFUNCTION(
350 BlueprintCallable,
351 BlueprintPure,
352 Category = "Cesium|Metadata|Value")
353 static bool
354 GetBoolean(UPARAM(ref) const FCesiumMetadataValue& value, bool DefaultValue);
355
379 UFUNCTION(
380 BlueprintCallable,
381 BlueprintPure,
382 Category = "Cesium|Metadata|Value")
383 static uint8
384 GetByte(UPARAM(ref) const FCesiumMetadataValue& Value, uint8 DefaultValue);
385
411 UFUNCTION(
412 BlueprintCallable,
413 BlueprintPure,
414 Category = "Cesium|Metadata|Value")
415 static int32
416 GetInteger(UPARAM(ref) const FCesiumMetadataValue& Value, int32 DefaultValue);
417
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
475 UFUNCTION(
476 BlueprintCallable,
477 BlueprintPure,
478 Category = "Cesium|Metadata|Value")
479 static float
480 GetFloat(UPARAM(ref) const FCesiumMetadataValue& Value, float DefaultValue);
481
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
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
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
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
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
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
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
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
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
809 UFUNCTION(
810 BlueprintCallable,
811 BlueprintPure,
812 Category = "Cesium|Metadata|Value")
814 const FCesiumMetadataValue& Value);
815
826 UFUNCTION(
827 BlueprintCallable,
828 BlueprintPure,
829 Category = "Cesium|Metadata|Value")
830 static bool IsEmpty(UPARAM(ref) const FCesiumMetadataValue& Value);
831
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.