3#include "Utilities/Strings.h"
5#include "Foundation/Memory/MemoryBuffer.h"
16 enum struct PropertyType
21 Bool = FirstInlineType,
46 PropertyType type = PropertyType::Unknown;
56 uint32_t uint2Value[2];
77 static constexpr uint32_t NoProperty =
static_cast<uint32_t
>(-1);
79 PropertyStore(MemBlockType memType = MemBlockType::PropertyStore);
85 bool getProperty(
StringView key,
bool defaultValue);
86 float getProperty(
StringView key,
float defaultValue);
87 int getProperty(
StringView key,
int defaultValue);
88 uint32_t getProperty(
StringView key, uint32_t defaultValue);
91 std::span<const float> getProperty(
StringView key, std::span<const float> defaultValue);
92 glm::vec3 getProperty(
StringView key, glm::vec3 defaultValue);
94 uint32_t addProperty(
StringView key,
bool value);
95 uint32_t addProperty(
StringView key, int32_t value);
96 uint32_t addProperty(
StringView key, uint32_t value);
97 uint32_t addProperty(
StringView key,
float value);
98 uint32_t addProperty(
StringView key,
double value);
99 uint32_t addProperty(
StringView key,
const char * value) {
return addProperty(key,
StringView(value)); }
100 uint32_t addProperty(
StringView key, StringRef value);
102 uint32_t addProperty(
StringView key, std::span<const float> values);
103 uint32_t addProperty(
StringView key, std::span<const double> values);
104 uint32_t addProperty(
StringView key, std::span<const int32_t> values);
105 uint32_t addProperty(
StringView key, std::span<const uint32_t> values);
106 uint32_t addProperty(
StringView key,
const glm::vec3& values);
107 uint32_t addProperty(
const PropertyStore& other, uint32_t otherIndex);
110 PropertyInfo & getProperty(StringRef key);
111 PropertyInfo & getPropertyByIndex(uint32_t index);
112 const PropertyInfo & getPropertyByIndex(uint32_t index)
const;
115 uint32_t findProperty(uint32_t first, uint32_t count, StringRef key)
const;
116 bool hasProperty(
StringView key)
const {
return findProperty(key) != NoProperty; }
118 uint32_t size()
const {
return static_cast<uint32_t
>(headers.size()); }
120 StringView getKey(
const PropertyInfo & p)
const;
121 StringView getString(
const PropertyInfo & p)
const;
122 StringView getString(uint32_t index)
const;
124 std::span<float> getFloatArray(uint32_t index);
125 std::span<const float> getFloatArray(
const PropertyInfo& p)
const;
126 std::span<const float> getFloatArray(uint32_t index)
const;
128 std::span<const double> getDoubleArray(
const PropertyInfo& p)
const;
129 std::span<const double> getDoubleArray(uint32_t index)
const;
131 std::span<const int32_t> getIntArray(
const PropertyInfo& p)
const;
132 std::span<const int32_t> getIntArray(uint32_t index)
const;
134 std::span<const uint32_t> getUIntArray(
const PropertyInfo& p)
const;
135 std::span<const uint32_t> getUIntArray(uint32_t index)
const;
137 std::span<const PropertyInfo> getHeaders()
const {
return std::span<const PropertyInfo>(headers.begin(), headers.end()); }
138 const uint8_t * getData()
const {
return static_cast<const uint8_t*
>(data.data()); }
140 void copyProperties(
const PropertyStore & other, uint32_t offset, uint32_t count);
142 size_t currentByteSize()
const {
return headers.byteSize() + dataSize; }
143 size_t allocatedByteSize()
const {
return headers.byteSize() + data.size(); }
146 PropertyInfo & addProperty(StringView key, PropertyType type);
147 void addPropertyData(PropertyInfo & p,
const void * data,
size_t size);
148 uint8_t* getPropertyData(
const PropertyInfo& p);
149 const uint8_t* getPropertyData(
const PropertyInfo& p)
const;
168 uint32_t getPropertyIndex(
StringRef key)
const;
169 float getProperty(
StringRef key,
float defaultValue)
const;
170 int getProperty(
StringRef key,
int defaultValue)
const;
172 std::span<const float> getProperty(
StringRef key, std::span<const float> defaultValue)
const;
173 std::span<const uint32_t> getProperty(
StringRef key, std::span<const uint32_t> defaultValue)
const;
176 uint32_t firstProperty = 0;
177 uint32_t numProperties = 0;
Provides a weakly referenced view over the contents of a string.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....