3#include <CesiumGltf/ClassProperty.h>
4#include <CesiumGltf/Enum.h>
5#include <CesiumGltf/PropertyAttributeProperty.h>
6#include <CesiumGltf/PropertyTableProperty.h>
7#include <CesiumGltf/PropertyTextureProperty.h>
8#include <CesiumGltf/PropertyType.h>
9#include <CesiumGltf/PropertyTypeTraits.h>
146 const bool hasEnumDefinition = pEnumDefinition !=
nullptr;
147 if (isEnum != hasEnumDefinition) {
154 if (expectedComponentType !=
171 if (classProperty.
array) {
203 const bool hasEnumDefinition = pEnumDefinition !=
nullptr;
204 if (isEnum != hasEnumDefinition) {
211 if (expectedComponentType !=
228 if (!classProperty.
array) {
256template <
typename VecType>
257static std::optional<VecType>
264 constexpr glm::length_t N = VecType::length();
265 if (array.size() != N) {
269 using T =
typename VecType::value_type;
272 for (glm::length_t i = 0; i < N; i++) {
273 std::optional<T> value = getScalar<T>(array[
static_cast<size_t>(i)]);
294template <
typename MatType>
295static std::optional<MatType>
302 constexpr glm::length_t N = MatType::length();
303 if (array.size() !=
static_cast<size_t>(N * N)) {
307 using T =
typename MatType::value_type;
310 for (glm::length_t i = 0; i < N; i++) {
312 for (glm::length_t j = 0; j < N; j++) {
313 std::optional<T> value =
314 getScalar<T>(array[
static_cast<size_t>(i * N + j)]);
319 result[i][j] = *value;
335template <
typename ElementType>
336int64_t
getCount(std::optional<std::vector<std::byte>>& buffer) {
341 return static_cast<int64_t
>(buffer->size() /
sizeof(ElementType));
336int64_t
getCount(std::optional<std::vector<std::byte>>& buffer) {
…}
347template <
typename ElementType,
bool Normalized = false>
class PropertyView;
361template <
typename ElementType>
class PropertyView<ElementType, false> {
369 _semantic(
std::nullopt),
370 _description(
std::nullopt),
371 _offset(
std::nullopt),
372 _scale(
std::nullopt),
376 _noData(
std::nullopt),
377 _defaultValue(
std::nullopt),
395 _name(classProperty.name),
396 _semantic(classProperty.semantic),
397 _description(classProperty.description),
398 _offset(
std::nullopt),
399 _scale(
std::nullopt),
402 _required(classProperty.required),
403 _noData(
std::nullopt),
404 _defaultValue(
std::nullopt),
411 _status = PropertyViewStatus::ErrorNormalizationMismatch;
416 getNumericPropertyValues(classProperty);
423 if (classProperty.
noData) {
424 if (!_required && _propertyType == PropertyType::Enum) {
425 CESIUM_ASSERT(pEnumDefinition != nullptr);
426 if constexpr (IsMetadataInteger<ElementType>::value) {
428 _noData = getEnumValue(*classProperty.noData, *pEnumDefinition);
431 _noData = getValue(*classProperty.
noData);
441 if (classProperty.defaultProperty) {
442 if (!_required && _propertyType == PropertyType::Enum) {
443 CESIUM_ASSERT(pEnumDefinition != nullptr);
444 if constexpr (IsMetadataInteger<ElementType>::value) {
447 getEnumValue(*classProperty.defaultProperty, *pEnumDefinition);
450 _defaultValue = getValue(*classProperty.defaultProperty);
453 if (!_defaultValue) {
471 _semantic(
std::nullopt),
472 _description(
std::nullopt),
473 _offset(
std::nullopt),
474 _scale(
std::nullopt),
478 _noData(
std::nullopt),
479 _defaultValue(
std::nullopt),
491 if (_status != PropertyViewStatus::Valid) {
496 if (classProperty.
type != ClassProperty::Type::ENUM) {
497 getNumericPropertyValues(property);
510 if (_status != PropertyViewStatus::Valid) {
514 if (classProperty.
type != ClassProperty::Type::ENUM) {
515 getNumericPropertyValues(property);
528 if (_status != PropertyViewStatus::Valid) {
533 if (classProperty.
type != ClassProperty::Type::ENUM) {
534 getNumericPropertyValues(property);
551 const std::optional<std::string>&
name() const noexcept {
return _name; }
559 const std::optional<std::string>&
semantic() const noexcept {
559 const std::optional<std::string>&
semantic() const noexcept {
…}
591 std::optional<ElementType>
offset() const noexcept {
return _offset; }
600 std::optional<ElementType>
scale() const noexcept {
return _scale; }
611 std::optional<ElementType>
max() const noexcept {
return _max; }
622 std::optional<ElementType>
min() const noexcept {
return _min; }
629 bool required() const noexcept {
return _required; }
640 std::optional<ElementType>
noData() const noexcept {
return _noData; }
651 return _defaultValue;
665 std::optional<std::string> _name;
666 std::optional<std::string> _semantic;
667 std::optional<std::string> _description;
669 std::optional<ElementType> _offset;
670 std::optional<ElementType> _scale;
671 std::optional<ElementType> _max;
672 std::optional<ElementType> _min;
675 std::optional<ElementType> _noData;
676 std::optional<ElementType> _defaultValue;
689 static std::optional<ElementType>
692 return getScalar<ElementType>(jsonValue);
696 return getVecN<ElementType>(jsonValue);
700 return getMatN<ElementType>(jsonValue);
704 static std::optional<ElementType> getEnumValue(
712 const auto foundValue = std::find_if(
713 enumDefinition.
values.begin(),
714 enumDefinition.
values.end(),
716 return enumValue.name == valueStr;
719 if (foundValue == enumDefinition.
values.end()) {
723 return static_cast<ElementType
>(foundValue->value);
726 using PropertyDefinitionType = std::variant<
728 PropertyTableProperty,
729 PropertyTextureProperty,
730 PropertyAttributeProperty>;
736 void getNumericPropertyValues(
const PropertyDefinitionType& inProperty) {
738 [
this](
auto property) {
739 if (property.offset) {
741 switch (TypeToPropertyType<ElementType>::component) {
742 case PropertyComponentType::Float32:
743 case PropertyComponentType::Float64:
744 this->_offset = getValue(*property.offset);
751 this->_status = PropertyViewStatus::ErrorInvalidOffset;
756 if (property.scale) {
758 switch (TypeToPropertyType<ElementType>::component) {
759 case PropertyComponentType::Float32:
760 case PropertyComponentType::Float64:
761 this->_scale = getValue(*property.scale);
768 this->_status = PropertyViewStatus::ErrorInvalidScale;
774 this->_max = getValue(*property.max);
777 this->_status = PropertyViewStatus::ErrorInvalidMax;
783 this->_min = getValue(*property.min);
786 this->_status = PropertyViewStatus::ErrorInvalidMin;
819 _semantic(
std::nullopt),
820 _description(
std::nullopt),
821 _offset(
std::nullopt),
822 _scale(
std::nullopt),
826 _noData(
std::nullopt),
827 _defaultValue(
std::nullopt),
835 _name(classProperty.name),
836 _semantic(classProperty.semantic),
837 _description(classProperty.description),
838 _offset(
std::nullopt),
839 _scale(
std::nullopt),
842 _required(classProperty.required),
843 _noData(
std::nullopt),
844 _defaultValue(
std::nullopt),
846 if (_status != PropertyViewStatus::Valid) {
851 _status = PropertyViewStatus::ErrorNormalizationMismatch;
854 getNumericPropertyValues(classProperty);
855 if (_status != PropertyViewStatus::Valid) {
859 if (classProperty.
noData) {
862 _noData = getValue<ElementType>(*classProperty.noData);
866 _status = PropertyViewStatus::ErrorInvalidNoDataValue;
871 if (classProperty.defaultProperty) {
875 getValue<NormalizedType>(*classProperty.defaultProperty);
877 if (!_defaultValue) {
879 _status = PropertyViewStatus::ErrorInvalidDefaultValue;
894 _semantic(
std::nullopt),
895 _description(
std::nullopt),
896 _offset(
std::nullopt),
897 _scale(
std::nullopt),
901 _noData(
std::nullopt),
902 _defaultValue(
std::nullopt),
913 if (_status != PropertyViewStatus::Valid) {
918 getNumericPropertyValues(property);
929 if (_status != PropertyViewStatus::Valid) {
934 getNumericPropertyValues(property);
945 if (_status != PropertyViewStatus::Valid) {
950 getNumericPropertyValues(property);
962 const std::optional<std::string>&
name() const noexcept {
return _name; }
967 const std::optional<std::string>&
semantic() const noexcept {
967 const std::optional<std::string>&
semantic() const noexcept {
…}
991 std::optional<NormalizedType>
offset() const noexcept {
return _offset; }
996 std::optional<NormalizedType>
scale() const noexcept {
return _scale; }
1001 std::optional<NormalizedType>
max() const noexcept {
return _max; }
1006 std::optional<NormalizedType>
min() const noexcept {
return _min; }
1016 std::optional<ElementType>
noData() const noexcept {
return _noData; }
1022 return _defaultValue;
1036 std::optional<std::string> _name;
1037 std::optional<std::string> _semantic;
1038 std::optional<std::string> _description;
1040 std::optional<NormalizedType> _offset;
1041 std::optional<NormalizedType> _scale;
1042 std::optional<NormalizedType> _max;
1043 std::optional<NormalizedType> _min;
1046 std::optional<ElementType> _noData;
1047 std::optional<NormalizedType> _defaultValue;
1059 template <
typename T>
1062 return getScalar<T>(jsonValue);
1066 return getVecN<T>(jsonValue);
1070 return getMatN<T>(jsonValue);
1074 using PropertyDefinitionType = std::variant<
1084 void getNumericPropertyValues(
const PropertyDefinitionType& inProperty) {
1086 [
this](
auto property) {
1087 if (property.offset) {
1088 _offset = getValue<NormalizedType>(*property.offset);
1091 _status = PropertyViewStatus::ErrorInvalidOffset;
1096 if (property.scale) {
1097 _scale = getValue<NormalizedType>(*property.scale);
1100 _status = PropertyViewStatus::ErrorInvalidScale;
1106 _max = getValue<NormalizedType>(*property.max);
1109 _status = PropertyViewStatus::ErrorInvalidMax;
1115 _min = getValue<NormalizedType>(*property.min);
1118 _status = PropertyViewStatus::ErrorInvalidMin;
1138 _name(
std::nullopt),
1139 _semantic(
std::nullopt),
1140 _description(
std::nullopt),
1142 _defaultValue(
std::nullopt) {}
1149 _name(classProperty.name),
1150 _semantic(classProperty.semantic),
1151 _description(classProperty.description),
1152 _required(classProperty.required),
1153 _defaultValue(
std::nullopt) {
1154 if (_status != PropertyViewStatus::Valid) {
1160 _defaultValue = getBooleanValue(*classProperty.defaultProperty);
1163 if (!_defaultValue) {
1165 _status = PropertyViewStatus::ErrorInvalidDefaultValue;
1179 _name(
std::nullopt),
1180 _semantic(
std::nullopt),
1181 _description(
std::nullopt),
1183 _defaultValue(
std::nullopt) {}
1204 const std::optional<std::string>&
name() const noexcept {
return _name; }
1209 const std::optional<std::string>&
semantic() const noexcept {
1209 const std::optional<std::string>&
semantic() const noexcept {
…}
1217 return _description;
1233 std::optional<bool>
offset() const noexcept {
return std::nullopt; }
1238 std::optional<bool>
scale() const noexcept {
return std::nullopt; }
1243 std::optional<bool>
max() const noexcept {
return std::nullopt; }
1248 std::optional<bool>
min() const noexcept {
return std::nullopt; }
1258 std::optional<bool>
noData() const noexcept {
return std::nullopt; }
1263 std::optional<bool>
defaultValue() const noexcept {
return _defaultValue; }
1276 std::optional<std::string> _name;
1277 std::optional<std::string> _semantic;
1278 std::optional<std::string> _description;
1281 std::optional<bool> _defaultValue;
1283 static std::optional<bool>
1286 return std::nullopt;
1304 _name(
std::nullopt),
1305 _semantic(
std::nullopt),
1306 _description(
std::nullopt),
1308 _noData(
std::nullopt),
1309 _defaultValue(
std::nullopt) {}
1316 _name(classProperty.name),
1317 _semantic(classProperty.semantic),
1318 _description(classProperty.description),
1319 _required(classProperty.required),
1320 _noData(
std::nullopt),
1321 _defaultValue(
std::nullopt) {
1322 if (_status != PropertyViewStatus::Valid) {
1326 if (classProperty.
noData) {
1328 _noData = getStringValue(*classProperty.noData);
1333 _status = PropertyViewStatus::ErrorInvalidNoDataValue;
1338 if (classProperty.defaultProperty) {
1340 _defaultValue = getStringValue(*classProperty.defaultProperty);
1343 if (!_defaultValue) {
1345 _status = PropertyViewStatus::ErrorInvalidDefaultValue;
1359 _name(
std::nullopt),
1360 _semantic(
std::nullopt),
1361 _description(
std::nullopt),
1363 _noData(
std::nullopt),
1364 _defaultValue(
std::nullopt) {}
1385 const std::optional<std::string>&
name() const noexcept {
return _name; }
1390 const std::optional<std::string>&
semantic() const noexcept {
1390 const std::optional<std::string>&
semantic() const noexcept {
…}
1398 return _description;
1414 std::optional<std::string_view>
offset() const noexcept {
1415 return std::nullopt;
1414 std::optional<std::string_view>
offset() const noexcept {
…}
1421 std::optional<std::string_view>
scale() const noexcept {
1422 return std::nullopt;
1421 std::optional<std::string_view>
scale() const noexcept {
…}
1428 std::optional<std::string_view>
max() const noexcept {
return std::nullopt; }
1433 std::optional<std::string_view>
min() const noexcept {
return std::nullopt; }
1443 std::optional<std::string_view>
noData() const noexcept {
1445 return std::string_view(*_noData);
1447 return std::nullopt;
1443 std::optional<std::string_view>
noData() const noexcept {
…}
1455 return std::string_view(*_defaultValue);
1457 return std::nullopt;
1471 std::optional<std::string> _name;
1472 std::optional<std::string> _semantic;
1473 std::optional<std::string> _description;
1476 std::optional<std::string> _noData;
1477 std::optional<std::string> _defaultValue;
1479 static std::optional<std::string>
1482 return std::nullopt;
1485 return std::string(value.
getString().c_str());
1502template <
typename ElementType>
1510 _name(
std::nullopt),
1511 _semantic(
std::nullopt),
1512 _description(
std::nullopt),
1514 _offset(
std::nullopt),
1515 _scale(
std::nullopt),
1519 _noData(
std::nullopt),
1520 _defaultValue(
std::nullopt),
1539 _name(classProperty.name),
1540 _semantic(classProperty.semantic),
1541 _description(classProperty.description),
1542 _count(classProperty.count ? *classProperty.count : 0),
1543 _offset(
std::nullopt),
1544 _scale(
std::nullopt),
1547 _required(classProperty.required),
1548 _noData(
std::nullopt),
1549 _defaultValue(
std::nullopt),
1551 if (_status != PropertyViewStatus::Valid) {
1556 _status = PropertyViewStatus::ErrorNormalizationMismatch;
1560 if (classProperty.
type != ClassProperty::Type::ENUM) {
1561 getNumericPropertyValues(classProperty);
1564 if (_status != PropertyViewStatus::Valid) {
1568 if (classProperty.
noData) {
1569 if (!_required && _propertyType == PropertyType::Enum) {
1570 CESIUM_ASSERT(pEnumDefinition != nullptr);
1571 if constexpr (IsMetadataInteger<ElementType>::value) {
1572 _noData = getEnumArrayValue(*classProperty.noData, *pEnumDefinition);
1574 }
else if (!_required && _propertyType != PropertyType::Enum) {
1575 _noData = getArrayValue(*classProperty.
noData);
1579 _status = PropertyViewStatus::ErrorInvalidNoDataValue;
1584 if (classProperty.defaultProperty) {
1585 if (!_required && _propertyType == PropertyType::Enum) {
1586 CESIUM_ASSERT(pEnumDefinition != nullptr);
1587 if constexpr (IsMetadataInteger<ElementType>::value) {
1588 _defaultValue = getEnumArrayValue(
1589 *classProperty.defaultProperty,
1592 }
else if (!_required && _propertyType != PropertyType::Enum) {
1593 _defaultValue = getArrayValue(*classProperty.defaultProperty);
1596 if (!_defaultValue) {
1598 _status = PropertyViewStatus::ErrorInvalidDefaultValue;
1612 _name(
std::nullopt),
1613 _semantic(
std::nullopt),
1614 _description(
std::nullopt),
1616 _offset(
std::nullopt),
1617 _scale(
std::nullopt),
1621 _noData(
std::nullopt),
1622 _defaultValue(
std::nullopt),
1634 if (_status != PropertyViewStatus::Valid) {
1639 if (classProperty.
type != ClassProperty::Type::ENUM) {
1640 getNumericPropertyValues(property);
1653 if (_status != PropertyViewStatus::Valid) {
1658 if (classProperty.
type != ClassProperty::Type::ENUM) {
1659 getNumericPropertyValues(property);
1672 const std::optional<std::string>&
name() const noexcept {
return _name; }
1677 const std::optional<std::string>&
semantic() const noexcept {
1677 const std::optional<std::string>&
semantic() const noexcept {
…}
1685 return _description;
1701 std::optional<PropertyArrayView<ElementType>>
offset() const noexcept {
1703 return std::nullopt;
1707 std::span<const std::byte>(_offset->data(), _offset->size()));
1701 std::optional<PropertyArrayView<ElementType>>
offset() const noexcept {
…}
1713 std::optional<PropertyArrayView<ElementType>>
scale() const noexcept {
1715 return std::nullopt;
1719 std::span<const std::byte>(_scale->data(), _scale->size()));
1713 std::optional<PropertyArrayView<ElementType>>
scale() const noexcept {
…}
1725 std::optional<PropertyArrayView<ElementType>>
max() const noexcept {
1727 return std::nullopt;
1731 std::span<const std::byte>(_max->data(), _max->size()));
1725 std::optional<PropertyArrayView<ElementType>>
max() const noexcept {
…}
1737 std::optional<PropertyArrayView<ElementType>>
min() const noexcept {
1739 return std::nullopt;
1743 std::span<const std::byte>(_min->data(), _min->size()));
1737 std::optional<PropertyArrayView<ElementType>>
min() const noexcept {
…}
1754 std::optional<PropertyArrayView<ElementType>>
noData() const noexcept {
1756 return std::nullopt;
1760 std::span<const std::byte>(_noData->data(), _noData->size()));
1754 std::optional<PropertyArrayView<ElementType>>
noData() const noexcept {
…}
1766 std::optional<PropertyArrayView<ElementType>>
defaultValue() const noexcept {
1767 if (!_defaultValue) {
1768 return std::nullopt;
1772 _defaultValue->data(),
1773 _defaultValue->size()));
1787 std::optional<std::string> _name;
1788 std::optional<std::string> _semantic;
1789 std::optional<std::string> _description;
1793 std::optional<std::vector<std::byte>> _offset;
1794 std::optional<std::vector<std::byte>> _scale;
1795 std::optional<std::vector<std::byte>> _max;
1796 std::optional<std::vector<std::byte>> _min;
1799 std::optional<std::vector<std::byte>> _noData;
1800 std::optional<std::vector<std::byte>> _defaultValue;
1803 using PropertyDefinitionType = std::
1804 variant<ClassProperty, PropertyTableProperty, PropertyTextureProperty>;
1805 void getNumericPropertyValues(
const PropertyDefinitionType& inProperty) {
1807 [
this](
auto property) {
1808 if (property.offset) {
1811 case PropertyComponentType::Float32:
1812 case PropertyComponentType::Float64:
1813 if (this->_count > 0) {
1814 this->_offset = getArrayValue(*property.offset);
1816 if (this->_offset &&
1817 getCount<ElementType>(this->_offset) == this->_count) {
1823 this->_status = PropertyViewStatus::ErrorInvalidOffset;
1828 if (property.scale) {
1831 case PropertyComponentType::Float32:
1832 case PropertyComponentType::Float64:
1834 this->_scale = getArrayValue(*property.scale);
1837 getCount<ElementType>(this->_scale) == this->_count) {
1843 this->_status = PropertyViewStatus::ErrorInvalidScale;
1849 if (this->_count > 0) {
1850 this->_max = getArrayValue(*property.max);
1853 getCount<ElementType>(this->_max) != this->_count) {
1855 this->_status = PropertyViewStatus::ErrorInvalidMax;
1861 if (this->_count > 0) {
1862 this->_min = getArrayValue(*property.min);
1865 getCount<ElementType>(this->_min) != this->_count) {
1867 this->_status = PropertyViewStatus::ErrorInvalidMin;
1875 static std::optional<std::vector<std::byte>>
1878 return std::nullopt;
1882 std::vector<ElementType> values;
1883 values.reserve(array.size());
1885 if constexpr (IsMetadataScalar<ElementType>::value) {
1886 for (
size_t i = 0; i < array.size(); i++) {
1887 std::optional<ElementType> element = getScalar<ElementType>(array[i]);
1889 return std::nullopt;
1892 values.push_back(*element);
1895 if constexpr (IsMetadataVecN<ElementType>::value) {
1896 for (
size_t i = 0; i < array.size(); i++) {
1897 std::optional<ElementType> element = getVecN<ElementType>(array[i]);
1899 return std::nullopt;
1902 values.push_back(*element);
1906 if constexpr (IsMetadataMatN<ElementType>::value) {
1907 for (
size_t i = 0; i < array.size(); i++) {
1908 std::optional<ElementType> element = getMatN<ElementType>(array[i]);
1910 return std::nullopt;
1913 values.push_back(*element);
1917 std::vector<std::byte> result(values.size() *
sizeof(ElementType));
1918 std::memcpy(result.data(), values.data(), result.size());
1923 static std::optional<std::vector<std::byte>> getEnumArrayValue(
1927 return std::nullopt;
1931 std::vector<ElementType> values;
1932 values.reserve(array.size());
1934 for (
size_t i = 0; i < array.size(); i++) {
1935 if (!array[i].isString()) {
1936 return std::nullopt;
1942 auto foundValue = std::find_if(
1943 enumDefinition.
values.begin(),
1944 enumDefinition.
values.end(),
1946 return enumValue.name == str;
1949 if (foundValue == enumDefinition.
values.end()) {
1950 return std::nullopt;
1953 values.push_back(
static_cast<ElementType
>(foundValue->value));
1956 std::vector<std::byte> result(values.size() *
sizeof(ElementType));
1957 std::memcpy(result.data(), values.data(), result.size());
1975template <
typename ElementType>
1986 _name(
std::nullopt),
1987 _semantic(
std::nullopt),
1988 _description(
std::nullopt),
1990 _offset(
std::nullopt),
1991 _scale(
std::nullopt),
1995 _noData(
std::nullopt),
1996 _defaultValue(
std::nullopt),
2005 _name(classProperty.name),
2006 _semantic(classProperty.semantic),
2007 _description(classProperty.description),
2008 _count(classProperty.count ? *classProperty.count : 0),
2009 _offset(
std::nullopt),
2010 _scale(
std::nullopt),
2013 _required(classProperty.required),
2014 _noData(
std::nullopt),
2015 _defaultValue(
std::nullopt),
2017 if (_status != PropertyViewStatus::Valid) {
2022 _status = PropertyViewStatus::ErrorNormalizationMismatch;
2026 getNumericPropertyValues(classProperty);
2027 if (_status != PropertyViewStatus::Valid) {
2031 if (classProperty.
noData) {
2033 _noData = getArrayValue<ElementType>(*classProperty.noData);
2037 _status = PropertyViewStatus::ErrorInvalidNoDataValue;
2042 if (classProperty.defaultProperty) {
2045 getArrayValue<NormalizedType>(*classProperty.defaultProperty);
2048 if (!_defaultValue) {
2049 _status = PropertyViewStatus::ErrorInvalidDefaultValue;
2063 _name(
std::nullopt),
2064 _semantic(
std::nullopt),
2065 _description(
std::nullopt),
2067 _offset(
std::nullopt),
2068 _scale(
std::nullopt),
2072 _noData(
std::nullopt),
2073 _defaultValue(
std::nullopt),
2084 if (_status != PropertyViewStatus::Valid) {
2089 getNumericPropertyValues(property);
2100 if (_status != PropertyViewStatus::Valid) {
2105 getNumericPropertyValues(property);
2117 const std::optional<std::string>&
name() const noexcept {
return _name; }
2122 const std::optional<std::string>&
semantic() const noexcept {
2122 const std::optional<std::string>&
semantic() const noexcept {
…}
2130 return _description;
2146 std::optional<PropertyArrayView<NormalizedType>>
offset() const noexcept {
2148 return std::nullopt;
2152 std::span<const std::byte>(_offset->data(), _offset->size()));
2146 std::optional<PropertyArrayView<NormalizedType>>
offset() const noexcept {
…}
2158 std::optional<PropertyArrayView<NormalizedType>>
scale() const noexcept {
2160 return std::nullopt;
2164 std::span<const std::byte>(_scale->data(), _scale->size()));
2158 std::optional<PropertyArrayView<NormalizedType>>
scale() const noexcept {
…}
2170 std::optional<PropertyArrayView<NormalizedType>>
max() const noexcept {
2172 return std::nullopt;
2176 std::span<const std::byte>(_max->data(), _max->size()));
2170 std::optional<PropertyArrayView<NormalizedType>>
max() const noexcept {
…}
2182 std::optional<PropertyArrayView<NormalizedType>>
min() const noexcept {
2184 return std::nullopt;
2188 std::span<const std::byte>(_min->data(), _min->size()));
2182 std::optional<PropertyArrayView<NormalizedType>>
min() const noexcept {
…}
2199 std::optional<PropertyArrayView<ElementType>>
noData() const noexcept {
2201 return std::nullopt;
2205 std::span<const std::byte>(_noData->data(), _noData->size()));
2199 std::optional<PropertyArrayView<ElementType>>
noData() const noexcept {
…}
2211 std::optional<PropertyArrayView<NormalizedType>>
2213 if (!_defaultValue) {
2214 return std::nullopt;
2218 _defaultValue->data(),
2219 _defaultValue->size()));
2233 std::optional<std::string> _name;
2234 std::optional<std::string> _semantic;
2235 std::optional<std::string> _description;
2239 std::optional<std::vector<std::byte>> _offset;
2240 std::optional<std::vector<std::byte>> _scale;
2241 std::optional<std::vector<std::byte>> _max;
2242 std::optional<std::vector<std::byte>> _min;
2245 std::optional<std::vector<std::byte>> _noData;
2246 std::optional<std::vector<std::byte>> _defaultValue;
2249 using PropertyDefinitionType = std::
2250 variant<ClassProperty, PropertyTableProperty, PropertyTextureProperty>;
2251 void getNumericPropertyValues(
const PropertyDefinitionType& inProperty) {
2253 [
this](
auto property) {
2254 if (property.offset) {
2256 _offset = getArrayValue<NormalizedType>(*property.offset);
2258 if (!_offset || getCount<NormalizedType>(_offset) != _count) {
2260 _status = PropertyViewStatus::ErrorInvalidOffset;
2265 if (property.scale) {
2267 _scale = getArrayValue<NormalizedType>(*property.scale);
2269 if (!_scale || getCount<NormalizedType>(_scale) != _count) {
2271 _status = PropertyViewStatus::ErrorInvalidScale;
2278 _max = getArrayValue<NormalizedType>(*property.max);
2280 if (!_max || getCount<NormalizedType>(_max) != _count) {
2282 _status = PropertyViewStatus::ErrorInvalidMax;
2289 _min = getArrayValue<NormalizedType>(*property.min);
2291 if (!_min || getCount<NormalizedType>(_min) != _count) {
2293 _status = PropertyViewStatus::ErrorInvalidMin;
2301 template <
typename T>
2302 static std::optional<std::vector<std::byte>>
2305 return std::nullopt;
2309 std::vector<T> values;
2310 values.reserve(array.size());
2312 if constexpr (IsMetadataScalar<T>::value) {
2313 for (
size_t i = 0; i < array.size(); i++) {
2314 std::optional<T> element = getScalar<T>(array[i]);
2316 return std::nullopt;
2319 values.push_back(*element);
2323 if constexpr (IsMetadataVecN<T>::value) {
2324 for (
size_t i = 0; i < array.size(); i++) {
2325 std::optional<T> element = getVecN<T>(array[i]);
2327 return std::nullopt;
2330 values.push_back(*element);
2334 if constexpr (IsMetadataMatN<T>::value) {
2335 for (
size_t i = 0; i < array.size(); i++) {
2336 std::optional<T> element = getMatN<T>(array[i]);
2338 return std::nullopt;
2341 values.push_back(*element);
2345 std::vector<std::byte> result(values.size() *
sizeof(T));
2346 std::memcpy(result.data(), values.data(), result.size());
2363 _name(
std::nullopt),
2364 _semantic(
std::nullopt),
2365 _description(
std::nullopt),
2377 _name(classProperty.name),
2378 _semantic(classProperty.semantic),
2379 _description(classProperty.description),
2380 _count(classProperty.count ? *classProperty.count : 0),
2381 _required(classProperty.required),
2384 if (_status != PropertyViewStatus::Valid) {
2391 getBooleanArrayValue(*classProperty.defaultProperty, _size);
2394 if (_size == 0 || (_count > 0 && _size != _count)) {
2395 _status = PropertyViewStatus::ErrorInvalidDefaultValue;
2409 _name(
std::nullopt),
2410 _semantic(
std::nullopt),
2411 _description(
std::nullopt),
2436 const std::optional<std::string>&
name() const noexcept {
return _name; }
2441 const std::optional<std::string>&
semantic() const noexcept {
2441 const std::optional<std::string>&
semantic() const noexcept {
…}
2449 return _description;
2465 std::optional<PropertyArrayView<bool>>
offset() const noexcept {
2466 return std::nullopt;
2465 std::optional<PropertyArrayView<bool>>
offset() const noexcept {
…}
2472 std::optional<PropertyArrayView<bool>>
scale() const noexcept {
2473 return std::nullopt;
2472 std::optional<PropertyArrayView<bool>>
scale() const noexcept {
…}
2479 std::optional<PropertyArrayView<bool>>
max() const noexcept {
2480 return std::nullopt;
2479 std::optional<PropertyArrayView<bool>>
max() const noexcept {
…}
2486 std::optional<PropertyArrayView<bool>>
min() const noexcept {
2487 return std::nullopt;
2486 std::optional<PropertyArrayView<bool>>
min() const noexcept {
…}
2498 std::optional<PropertyArrayView<bool>>
noData() const noexcept {
2499 return std::nullopt;
2498 std::optional<PropertyArrayView<bool>>
noData() const noexcept {
…}
2508 std::span<const std::byte>(
2509 _defaultValue.data(),
2510 _defaultValue.size()),
2515 return std::nullopt;
2529 std::optional<std::string> _name;
2530 std::optional<std::string> _semantic;
2531 std::optional<std::string> _description;
2536 std::vector<std::byte> _defaultValue;
2539 static std::vector<std::byte> getBooleanArrayValue(
2543 return std::vector<std::byte>();
2547 std::vector<std::byte> values;
2548 values.reserve((array.size() / 8) + 1);
2550 size_t byteIndex = 0;
2551 uint8_t bitIndex = 0;
2553 for (
size_t i = 0; i < array.size(); i++, size++) {
2554 if (!array[i].isBool()) {
2559 if (values.size() < byteIndex - 1) {
2560 values.push_back(std::byte(0));
2563 std::byte value = std::byte(array[i].getBool() ? 1 : 0);
2564 value = value << bitIndex;
2566 values[byteIndex] |= value;
2590 _name(
std::nullopt),
2591 _semantic(
std::nullopt),
2592 _description(
std::nullopt),
2604 _name(classProperty.name),
2605 _semantic(classProperty.semantic),
2606 _description(classProperty.description),
2607 _count(classProperty.count ? *classProperty.count : 0),
2608 _required(classProperty.required),
2611 if (_status != PropertyViewStatus::Valid) {
2615 if (classProperty.
noData) {
2617 _noData = getStringArrayValue(*classProperty.noData);
2620 if (_noData.size == 0 || (_count > 0 && _noData.size != _count)) {
2621 _status = PropertyViewStatus::ErrorInvalidNoDataValue;
2626 if (classProperty.defaultProperty) {
2628 _defaultValue = getStringArrayValue(*classProperty.defaultProperty);
2631 if (_defaultValue.size == 0 ||
2632 (_count > 0 && _defaultValue.size != _count)) {
2634 _status = PropertyViewStatus::ErrorInvalidDefaultValue;
2648 _name(
std::nullopt),
2649 _semantic(
std::nullopt),
2650 _description(
std::nullopt),
2675 const std::optional<std::string>&
name() const noexcept {
return _name; }
2680 const std::optional<std::string>&
semantic() const noexcept {
2680 const std::optional<std::string>&
semantic() const noexcept {
…}
2688 return _description;
2704 std::optional<PropertyArrayView<std::string_view>>
offset() const noexcept {
2705 return std::nullopt;
2704 std::optional<PropertyArrayView<std::string_view>>
offset() const noexcept {
…}
2711 std::optional<PropertyArrayView<std::string_view>>
scale() const noexcept {
2712 return std::nullopt;
2711 std::optional<PropertyArrayView<std::string_view>>
scale() const noexcept {
…}
2718 std::optional<PropertyArrayView<std::string_view>>
max() const noexcept {
2719 return std::nullopt;
2718 std::optional<PropertyArrayView<std::string_view>>
max() const noexcept {
…}
2725 std::optional<PropertyArrayView<std::string_view>>
min() const noexcept {
2726 return std::nullopt;
2725 std::optional<PropertyArrayView<std::string_view>>
min() const noexcept {
…}
2737 std::optional<PropertyArrayView<std::string_view>>
noData() const noexcept {
2738 if (_noData.size > 0) {
2740 std::span<const std::byte>(_noData.data.data(), _noData.data.size()),
2741 std::span<const std::byte>(
2742 _noData.offsets.data(),
2743 _noData.offsets.size()),
2748 return std::nullopt;
2737 std::optional<PropertyArrayView<std::string_view>>
noData() const noexcept {
…}
2754 std::optional<PropertyArrayView<std::string_view>>
2756 if (_defaultValue.size > 0) {
2758 std::span<const std::byte>(
2759 _defaultValue.data.data(),
2760 _defaultValue.data.size()),
2761 std::span<const std::byte>(
2762 _defaultValue.offsets.data(),
2763 _defaultValue.offsets.size()),
2764 _defaultValue.offsetType,
2765 _defaultValue.size);
2768 return std::nullopt;
2782 std::optional<std::string> _name;
2783 std::optional<std::string> _semantic;
2784 std::optional<std::string> _description;
2789 struct StringArrayValue {
2790 std::vector<std::byte> data;
2791 std::vector<std::byte> offsets;
2796 StringArrayValue _noData;
2797 StringArrayValue _defaultValue;
2799 static StringArrayValue
2801 StringArrayValue result;
2806 std::vector<std::string> strings;
2807 std::vector<uint64_t> stringOffsets;
2809 const auto& array = jsonValue.
getArray();
2810 strings.reserve(array.size());
2811 stringOffsets.reserve(array.size() + 1);
2812 stringOffsets.push_back(
static_cast<uint64_t
>(0));
2814 for (
size_t i = 0; i < array.size(); i++) {
2815 if (!array[i].isString()) {
2820 const std::string&
string = array[i].getString();
2821 strings.push_back(
string);
2822 stringOffsets.push_back(stringOffsets[i] +
string.size());
2825 uint64_t totalLength = stringOffsets.back();
2826 result.data.resize(totalLength);
2827 for (
size_t i = 0; i < strings.size(); ++i) {
2829 result.data.data() + stringOffsets[i],
2834 if (totalLength <= std::numeric_limits<uint8_t>::max()) {
2835 result.offsets = narrowOffsetsBuffer<uint8_t>(stringOffsets);
2836 result.offsetType = PropertyComponentType::Uint8;
2837 }
else if (totalLength <= std::numeric_limits<uint16_t>::max()) {
2838 result.offsets = narrowOffsetsBuffer<uint16_t>(stringOffsets);
2839 result.offsetType = PropertyComponentType::Uint16;
2840 }
else if (totalLength <= std::numeric_limits<uint32_t>::max()) {
2841 result.offsets = narrowOffsetsBuffer<uint32_t>(stringOffsets);
2842 result.offsetType = PropertyComponentType::Uint32;
2844 result.offsets.resize(stringOffsets.size() *
sizeof(uint64_t));
2846 result.offsets.data(),
2847 stringOffsets.data(),
2848 result.offsets.size());
2849 result.offsetType = PropertyComponentType::Uint64;
2852 result.size =
static_cast<int64_t
>(strings.size());
2857 template <
typename T>
2858 static std::vector<std::byte>
2859 narrowOffsetsBuffer(std::vector<uint64_t> offsets) {
2860 std::vector<std::byte> result(offsets.size() *
sizeof(T));
2861 size_t bufferOffset = 0;
2862 for (
size_t i = 0; i < offsets.size(); i++, bufferOffset +=
sizeof(T)) {
2863 T offset =
static_cast<T
>(offsets[i]);
2864 std::memcpy(result.data() + bufferOffset, &offset,
sizeof(T));
A view on an array element of a PropertyTableProperty or PropertyTextureProperty.
Indicates the status of a property view.
static const PropertyViewStatusType ErrorTypeMismatch
This property view's type does not match what is specified in ClassProperty::type.
static const PropertyViewStatusType ErrorInvalidDefaultValue
The property provided an invalid default value.
static const PropertyViewStatusType ErrorInvalidMin
The property provided an invalid minimum value.
static const PropertyViewStatusType ErrorInvalidMax
The property provided an invalid maximum value.
static const PropertyViewStatusType ErrorInvalidOffset
The property provided an invalid offset value.
static const PropertyViewStatusType Valid
This property view is valid and ready to use.
static const PropertyViewStatusType ErrorNonexistentProperty
This property view is trying to view a property that does not exist.
static const PropertyViewStatusType ErrorInvalidNormalization
This property says it is normalized, but it does not have an integer component type.
static const PropertyViewStatusType ErrorArrayTypeMismatch
This property view differs from what is specified in ClassProperty::array.
static const PropertyViewStatusType ErrorInvalidNoDataValue
The property provided an invalid "no data" value.
static const PropertyViewStatusType ErrorNormalizationMismatch
This property view's normalization differs from what is specified in ClassProperty::normalized.
static const PropertyViewStatusType ErrorInvalidEnum
The property provided an invalid enum value.
static const PropertyViewStatusType EmptyPropertyWithDefault
This property view does not contain any data, but specifies a default value. This happens when a clas...
static const PropertyViewStatusType ErrorInvalidScale
The property provided an invalid scale value.
static const PropertyViewStatusType ErrorComponentTypeMismatch
This property view's component type does not match what is specified in ClassProperty::componentType.
std::optional< ElementType > offset() const noexcept
Gets the offset to apply to property values. Only applicable to SCALAR, VECN, and MATN types when the...
std::optional< ElementType > scale() const noexcept
Gets the scale to apply to property values. Only applicable to SCALAR, VECN, and MATN types when the ...
bool required() const noexcept
Whether the property must be present in every entity conforming to the class. If not required,...
PropertyView(const ClassProperty &classProperty, const PropertyTableProperty &property, const CesiumGltf::Enum *pEnumDefinition=nullptr)
Constructs a property instance from a property table property and its class definition,...
std::optional< ElementType > defaultValue() const noexcept
Gets the default value to use when encountering a "no data" value or an omitted property....
PropertyView(const ClassProperty &classProperty, const PropertyTextureProperty &property, const CesiumGltf::Enum *pEnumDefinition=nullptr)
Constructs a property instance from a property texture property, class definition,...
PropertyView(const ClassProperty &classProperty, const PropertyAttributeProperty &property, const CesiumGltf::Enum *pEnumDefinition=nullptr)
Constructs a property instance from a property attribute property and its class definition,...
const std::optional< std::string > & name() const noexcept
Gets the name of the property being viewed. Returns std::nullopt if no name was specified.
PropertyViewStatusType _status
Indicates the status of a property view.
const std::optional< std::string > & semantic() const noexcept
Gets the semantic of the property being viewed. The semantic is an identifier that describes how this...
bool normalized() const noexcept
Whether this property has a normalized integer type.
PropertyView(const ClassProperty &classProperty)
Constructs a property instance from a class definition only.
int64_t arrayCount() const noexcept
Get the element count of the fixed-length arrays in this property. Only applicable when the property ...
PropertyViewStatusType status() const noexcept
Gets the status of this property view, indicating whether an error occurred.
std::optional< ElementType > noData() const noexcept
Gets the "no data" value, i.e., the value representing missing data in the property wherever it appea...
std::optional< ElementType > min() const noexcept
Gets the minimum allowed value for the property. Only applicable to SCALAR, VECN, and MATN types....
PropertyType propertyType() const noexcept
Returns the PropertyType of the property this view is accessing.
std::optional< ElementType > max() const noexcept
Gets the maximum allowed value for the property. Only applicable to SCALAR, VECN, and MATN types....
PropertyView(PropertyViewStatusType status)
Constructs an invalid instance for an erroneous property.
PropertyView(const ClassProperty &classProperty, const CesiumGltf::Enum *pEnumDefinition)
Constructs a property instance from a class definition and enum definition.
const std::optional< std::string > & description() const noexcept
Gets the description of the property being viewed. Returns std::nullopt if no description was specifi...
PropertyView()
Constructs an empty property instance.
PropertyView(const ClassProperty &classProperty, const PropertyTableProperty &property)
Constructs a property instance from a property table property and its class definition.
std::optional< ElementType > noData() const noexcept
Constructs an empty property instance. false>noData
const std::optional< std::string > & semantic() const noexcept
Constructs an empty property instance. false>semantic
std::optional< NormalizedType > max() const noexcept
Constructs an empty property instance. false>max
PropertyView(PropertyViewStatusType status)
Constructs an invalid instance for an erroneous property.
const std::optional< std::string > & description() const noexcept
Constructs an empty property instance. false>description
PropertyView(const ClassProperty &classProperty, const PropertyTextureProperty &property)
Constructs a property instance from a property texture property and its class definition.
PropertyView(const ClassProperty &classProperty, const PropertyAttributeProperty &property)
Constructs a property instance from a property attribute property and its class definition.
PropertyViewStatusType _status
Indicates the status of a property view.
std::optional< NormalizedType > scale() const noexcept
Constructs an empty property instance. false>scale
bool normalized() const noexcept
Constructs an empty property instance. false>normalized
PropertyView()
Constructs an empty property instance.
std::optional< NormalizedType > defaultValue() const noexcept
Constructs an empty property instance. false>defaultValue
PropertyViewStatusType status() const noexcept
Constructs an empty property instance. false>status
bool required() const noexcept
Constructs an empty property instance. false>required
PropertyView(const ClassProperty &classProperty)
Constructs a property instance from a class definition only.
std::optional< NormalizedType > offset() const noexcept
Constructs an empty property instance. false>offset
int64_t arrayCount() const noexcept
Constructs an empty property instance. false>arrayCount
std::optional< NormalizedType > min() const noexcept
Constructs an empty property instance. false>min
const std::optional< std::string > & name() const noexcept
Constructs an empty property instance. false>name
PropertyType propertyType() const noexcept
Returns the PropertyType of the property this view is accessing.
PropertyViewStatusType status() const noexcept
Constructs an empty property instance. false>status
PropertyView(const ClassProperty &classProperty, const PropertyTextureProperty &property, const CesiumGltf::Enum *pEnumDefinition=nullptr)
Constructs a property instance from a property texture property, its class definition,...
std::optional< PropertyArrayView< ElementType > > noData() const noexcept
Constructs an empty property instance. false>noData
PropertyView(const ClassProperty &classProperty)
Constructs a property instance from a class definition only.
int64_t arrayCount() const noexcept
Constructs an empty property instance. false>arrayCount
std::optional< PropertyArrayView< ElementType > > offset() const noexcept
Constructs an empty property instance. false>offset
std::optional< PropertyArrayView< ElementType > > max() const noexcept
Constructs an empty property instance. false>max
std::optional< PropertyArrayView< ElementType > > defaultValue() const noexcept
Constructs an empty property instance. false>defaultValue
std::optional< PropertyArrayView< ElementType > > min() const noexcept
Constructs an empty property instance. false>min
bool normalized() const noexcept
Constructs an empty property instance. false>normalized
PropertyView(PropertyViewStatusType status)
Constructs an invalid instance for an erroneous property.
PropertyView(const ClassProperty &classProperty, const CesiumGltf::Enum *pEnumDefinition)
Constructs a property instance from a class definition and enum definition.
const std::optional< std::string > & description() const noexcept
Constructs an empty property instance. false>description
PropertyView()
Constructs an empty property instance.
PropertyType propertyType() const noexcept
Returns the PropertyType of the property that this view is accessing.
const std::optional< std::string > & name() const noexcept
Constructs an empty property instance. false>name
bool required() const noexcept
Constructs an empty property instance. false>required
PropertyView(const ClassProperty &classProperty, const PropertyTableProperty &property, const CesiumGltf::Enum *pEnumDefinition=nullptr)
Constructs a property instance from a property table property, its class definition,...
const std::optional< std::string > & semantic() const noexcept
Constructs an empty property instance. false>semantic
std::optional< PropertyArrayView< ElementType > > scale() const noexcept
Constructs an empty property instance. false>scale
PropertyViewStatusType _status
Indicates the status of a property view.
PropertyViewStatusType status() const noexcept
Constructs an empty property instance. false>status
std::optional< PropertyArrayView< NormalizedType > > max() const noexcept
Constructs an empty property instance. false>max
PropertyViewStatusType _status
Indicates the status of a property view.
std::optional< PropertyArrayView< NormalizedType > > scale() const noexcept
Constructs an empty property instance. false>scale
std::optional< PropertyArrayView< ElementType > > noData() const noexcept
Constructs an empty property instance. false>noData
PropertyView()
Constructs an empty property instance.
std::optional< PropertyArrayView< NormalizedType > > min() const noexcept
Constructs an empty property instance. false>min
PropertyView(const ClassProperty &classProperty, const PropertyTextureProperty &property)
Constructs a property instance from a property texture property and its class definition.
std::optional< PropertyArrayView< NormalizedType > > offset() const noexcept
Constructs an empty property instance. false>offset
PropertyView(const ClassProperty &classProperty, const PropertyTableProperty &property)
Constructs a property instance from a property table property and its class definition.
PropertyView(PropertyViewStatusType status)
Constructs an invalid instance for an erroneous property.
const std::optional< std::string > & description() const noexcept
Constructs an empty property instance. false>description
PropertyView(const ClassProperty &classProperty)
Constructs a property instance from a class definition only.
std::optional< PropertyArrayView< NormalizedType > > defaultValue() const noexcept
Constructs an empty property instance. false>defaultValue
const std::optional< std::string > & semantic() const noexcept
Constructs an empty property instance. false>semantic
int64_t arrayCount() const noexcept
Constructs an empty property instance. false>arrayCount
const std::optional< std::string > & name() const noexcept
Constructs an empty property instance. false>name
bool required() const noexcept
Constructs an empty property instance. false>required
PropertyType propertyType() const noexcept
Returns the PropertyType of the property this view is accessing.
bool normalized() const noexcept
Constructs an empty property instance. false>normalized
std::optional< PropertyArrayView< bool > > min() const noexcept
Constructs an empty property instance. false>min
int64_t arrayCount() const noexcept
Constructs an empty property instance. false>arrayCount
const std::optional< std::string > & description() const noexcept
Constructs an empty property instance. false>description
const std::optional< std::string > & semantic() const noexcept
Constructs an empty property instance. false>semantic
std::optional< PropertyArrayView< bool > > max() const noexcept
Constructs an empty property instance. false>max
std::optional< PropertyArrayView< bool > > defaultValue() const noexcept
Constructs an empty property instance. false>defaultValue
PropertyView()
Constructs an empty property instance.
PropertyView(const ClassProperty &classProperty, const PropertyTableProperty &, const CesiumGltf::Enum *)
Constructs a property instance from a property table property and its class definition.
PropertyViewStatusType _status
Indicates the status of a property view.
PropertyType propertyType() const noexcept
Returns the PropertyType of the property this view is accessing.
bool required() const noexcept
Constructs an empty property instance. false>required
std::optional< PropertyArrayView< bool > > offset() const noexcept
Constructs an empty property instance. false>offset
PropertyView(const ClassProperty &classProperty)
Constructs a property instance from a class definition only.
PropertyView(PropertyViewStatusType status)
Constructs an invalid instance for an erroneous property.
std::optional< PropertyArrayView< bool > > scale() const noexcept
Constructs an empty property instance. false>scale
std::optional< PropertyArrayView< bool > > noData() const noexcept
Constructs an empty property instance. false>noData
PropertyViewStatusType status() const noexcept
Constructs an empty property instance. false>status
const std::optional< std::string > & name() const noexcept
Constructs an empty property instance. false>name
bool normalized() const noexcept
Constructs an empty property instance. false>normalized
std::optional< PropertyArrayView< std::string_view > > max() const noexcept
Constructs an empty property instance. false>max
PropertyView(const ClassProperty &classProperty)
Constructs a property instance from a class definition only.
const std::optional< std::string > & semantic() const noexcept
Constructs an empty property instance. false>semantic
PropertyViewStatusType status() const noexcept
Constructs an empty property instance. false>status
PropertyView()
Constructs an empty property instance.
const std::optional< std::string > & name() const noexcept
Constructs an empty property instance. false>name
std::optional< PropertyArrayView< std::string_view > > offset() const noexcept
Constructs an empty property instance. false>offset
PropertyViewStatusType _status
Indicates the status of a property view.
int64_t arrayCount() const noexcept
Constructs an empty property instance. false>arrayCount
std::optional< PropertyArrayView< std::string_view > > min() const noexcept
Constructs an empty property instance. false>min
const std::optional< std::string > & description() const noexcept
Constructs an empty property instance. false>description
std::optional< PropertyArrayView< std::string_view > > noData() const noexcept
Constructs an empty property instance. false>noData
bool required() const noexcept
Constructs an empty property instance. false>required
PropertyType propertyType() const noexcept
Returns the PropertyType of the property this view is accessing.
PropertyView(const ClassProperty &classProperty, const PropertyTableProperty &, const CesiumGltf::Enum *)
Constructs a property instance from a property table property and its class definition.
bool normalized() const noexcept
Constructs an empty property instance. false>normalized
PropertyView(PropertyViewStatusType status)
Constructs an invalid instance for an erroneous property.
std::optional< PropertyArrayView< std::string_view > > defaultValue() const noexcept
Constructs an empty property instance. false>defaultValue
std::optional< PropertyArrayView< std::string_view > > scale() const noexcept
Constructs an empty property instance. false>scale
PropertyViewStatusType status() const noexcept
Constructs an empty property instance. false>status
std::optional< bool > min() const noexcept
Constructs an empty property instance. false>min
std::optional< bool > noData() const noexcept
Constructs an empty property instance. false>noData
const std::optional< std::string > & name() const noexcept
Constructs an empty property instance. false>name
bool required() const noexcept
Constructs an empty property instance. false>required
int64_t arrayCount() const noexcept
Constructs an empty property instance. false>arrayCount
const std::optional< std::string > & description() const noexcept
Constructs an empty property instance. false>description
std::optional< bool > scale() const noexcept
Constructs an empty property instance. false>scale
const std::optional< std::string > & semantic() const noexcept
Constructs an empty property instance. false>semantic
PropertyView(const ClassProperty &classProperty, const PropertyTableProperty &, const CesiumGltf::Enum *)
Constructs a property instance from a property table property and its class definition.
PropertyView(const ClassProperty &classProperty)
Constructs a property instance from a class definition only.
bool normalized() const noexcept
Constructs an empty property instance. false>normalized
PropertyViewStatusType _status
Indicates the status of a property view.
PropertyView()
Constructs an empty property instance.
std::optional< bool > defaultValue() const noexcept
Constructs an empty property instance. false>defaultValue
std::optional< bool > offset() const noexcept
Constructs an empty property instance. false>offset
PropertyView(PropertyViewStatusType status)
Constructs an invalid instance for an erroneous property.
std::optional< bool > max() const noexcept
Constructs an empty property instance. false>max
PropertyType propertyType() const noexcept
Returns the PropertyType of the property this view is accessing.
bool required() const noexcept
Constructs an empty property instance. false>required
const std::optional< std::string > & name() const noexcept
Constructs an empty property instance. false>name
PropertyView()
Constructs an empty property instance.
std::optional< std::string_view > min() const noexcept
Constructs an empty property instance. false>min
std::optional< std::string_view > offset() const noexcept
Constructs an empty property instance. false>offset
PropertyViewStatusType _status
Indicates the status of a property view.
PropertyView(const ClassProperty &classProperty)
Constructs a property instance from a class definition only.
std::optional< std::string_view > scale() const noexcept
Constructs an empty property instance. false>scale
const std::optional< std::string > & description() const noexcept
Constructs an empty property instance. false>description
PropertyView(const ClassProperty &classProperty, const PropertyTableProperty &, const CesiumGltf::Enum *)
Constructs a property instance from a property table property and its class definition.
std::optional< std::string_view > defaultValue() const noexcept
Constructs an empty property instance. false>defaultValue
PropertyType propertyType() const noexcept
Returns the PropertyType of the property this view is accessing.
int64_t arrayCount() const noexcept
Constructs an empty property instance. false>arrayCount
PropertyView(PropertyViewStatusType status)
Constructs an invalid instance for an erroneous property.
std::optional< std::string_view > noData() const noexcept
Constructs an empty property instance. false>noData
std::optional< std::string_view > max() const noexcept
Constructs an empty property instance. false>max
const std::optional< std::string > & semantic() const noexcept
Constructs an empty property instance. false>semantic
bool normalized() const noexcept
Constructs an empty property instance. false>normalized
PropertyViewStatusType status() const noexcept
Constructs an empty property instance. false>status
Represents a metadata property in EXT_structural_metadata.
A generic implementation of a value in a JSON structure.
bool getBool() const
Gets the bool from the value.
const JsonValue::String & getString() const
Gets the string from the value.
std::vector< JsonValue > Array
The type to represent an Array JSON value.
bool isBool() const noexcept
Returns whether this value is a Bool value.
std::string String
The type to represent a String JSON value.
bool isArray() const noexcept
Returns whether this value is an Array value.
bool isString() const noexcept
Returns whether this value is a String value.
std::optional< To > getSafeNumber() const
Gets the numerical quantity from the value casted to the To type. This function should be used over g...
const JsonValue::Array & getArray() const
Gets the array from the value.
Classes for working with glTF models.
PropertyComponentType
The possible types of a property component.
PropertyComponentType convertStringToPropertyComponentType(const std::string &str)
Converts a string into a PropertyComponentType.
PropertyViewStatusType validatePropertyType(const ClassProperty &classProperty, const CesiumGltf::Enum *pEnumDefinition=nullptr)
Validates a ClassProperty representing a property, checking for any type mismatches.
PropertyViewStatusType validateArrayPropertyType(const ClassProperty &classProperty, const CesiumGltf::Enum *pEnumDefinition=nullptr)
Validates a ClassProperty representing an array of values, checking for any type mismatches.
bool canRepresentPropertyType(PropertyType type)
Returns whether the type T can represent the given PropertyType.
int64_t getCount(std::optional< std::vector< std::byte > > &buffer)
Obtains the number of values of type ElementType that could fit in the buffer.
PropertyType convertStringToPropertyType(const std::string &str)
Converts a string into a PropertyType.
PropertyType
The possible types of a property in a PropertyTableView.
@ Invalid
An invalid property type.
int32_t PropertyViewStatusType
The type used for fields of PropertyViewStatus.
static const std::string ENUM
ENUM
bool normalized
Specifies whether integer values are normalized. Only applicable to SCALAR, VECN, and MATN types with...
std::optional< std::string > componentType
The datatype of the element's components. Only applicable to SCALAR, VECN, and MATN types.
bool array
Whether the property is an array. When count is defined the property is a fixed-length array....
std::optional< CesiumUtility::JsonValue > noData
A noData value represents missing data — also known as a sentinel value — wherever it appears....
std::string type
The element type.
std::optional< CesiumUtility::JsonValue > defaultProperty
A default value to use when encountering a noData value or an omitted property. The value is given in...
std::vector< CesiumGltf::EnumValue > values
An array of enum values. Duplicate names or duplicate integer values are not allowed.
This class is not meant to be instantiated directly. Use Enum instead.
An attribute containing property values.
An array of binary property values.
A texture containing property values.
Convert an integer numeric type to the corresponding representation as a double type....
Infer the best-fitting PropertyType and PropertyComponentType for a C++ type.