26 static const
KyUInt32 Type_Unset = 0;
27 static const
KyUInt32 Type_KyUInt32 = 1;
28 static const
KyUInt32 Type_KyInt32 = 2;
29 static const
KyUInt32 Type_KyFloat32 = 3;
33 BlobField32() : m_type(Type_Unset), m_value(0) {}
35 KyUInt32& ValueAsUInt32() {
return m_value; }
37 KyFloat32& ValueAsFloat32() {
char* value = (
char*)&m_value;
return *(
KyFloat32*)value; }
40 BlobArray<char> m_name;
46 SwapEndianness(e,
self.m_name);
47 SwapEndianness(e,
self.m_type);
48 SwapEndianness(e,
self.m_value);
52 class BlobField32Mapping
56 BlobField32Mapping() : m_type(BlobField32::Type_Unset), m_name(
nullptr), m_value(
nullptr) {}
58 BlobField32Mapping(
KyUInt32 type,
const char* name,
bool* value) : m_type(type), m_name(name), m_value((char*)value) {}
59 BlobField32Mapping(
KyUInt32 type,
const char* name,
KyUInt32* value) : m_type(type), m_name(name), m_value((char*)value) {}
60 BlobField32Mapping(
KyUInt32 type,
const char* name,
KyInt32* value) : m_type(type), m_name(name), m_value((char*)value) {}
61 BlobField32Mapping(
KyUInt32 type,
const char* name,
KyFloat32* value) : m_type(type), m_name(name), m_value((char*)value) {}
63 bool& ValueAsBool() {
return *((
bool*)m_value); }
68 bool GetValueAsBool() {
return *((
bool*)m_value); }
73 void SetValueAsBool(
bool value) { *((
bool*)m_value) = value; }
75 void SetValueAsInt32(
KyInt32 value) { *((
KyInt32*)m_value) = value; }
78 void SetValueFromBlobValue32(
KyUInt32 blobValue32)
80 if (m_type == BlobField32::Type_Bool)
81 *((
bool*)m_value) = (blobValue32 != 1);
93 template <
class OSTREAM>
94 inline OSTREAM& operator<<(OSTREAM& os, BlobField32Mapping& mapping)
96 os << mapping.m_name <<
" : ";
98 switch(mapping.m_type)
100 case BlobField32::Type_KyUInt32 : os <<(*(
KyUInt32*) (mapping.m_value));
break;
101 case BlobField32::Type_KyInt32 : os <<(*(
KyInt32*) (mapping.m_value));
break;
102 case BlobField32::Type_KyFloat32 : os <<(*(
KyFloat32*)(mapping.m_value));
break;
103 case BlobField32::Type_Bool : os <<(*(
bool*) (mapping.m_value));
break;
110 class BlobField32Builder :
public BaseBlobBuilder<BlobField32>
113 BlobField32Builder(BlobField32Mapping& mapping) : m_mapping(&mapping) {}
116 virtual void DoBuild()
123 BlobField32Mapping* m_mapping;
129 class BlobMultiField32
133 BlobMultiField32() : m_valueType(BlobField32::Type_Unset) {}
135 KyUInt32 GetCount()
const {
return m_values.GetCount(); }
137 const KyUInt32& ValueAsUInt32(
KyUInt32 idx)
const {
return m_values.GetValues()[idx]; }
138 const KyInt32& ValueAsInt32(
KyUInt32 idx)
const {
char* v = (
char*)(&m_values.GetValues()[idx]);
return *(
KyInt32*)v; }
141 KyUInt32 GetValueAsUInt32(
KyUInt32 idx)
const {
return m_values.GetValues()[idx]; }
142 KyInt32 GetValueAsInt32(
KyUInt32 idx)
const {
char* v = (
char*)(&m_values.GetValues()[idx]);
return *(
KyInt32*)v; }
145 void SetValueAsUInt32(
KyUInt32 idx,
KyUInt32 value) { m_values.GetValues()[idx] = value; }
146 void SetValueAsInt32(
KyUInt32 idx,
KyInt32 value) {
char* v = (
char*)&value; m_values.GetValues()[idx] = *((
KyUInt32*)v); }
147 void SetValueAsFloat32(
KyUInt32 idx,
KyFloat32 value) {
char* v = (
char*)&value; m_values.GetValues()[idx] = *((
KyUInt32*)v); }
150 BlobArray<char> m_name;
151 BlobArray<char> m_category;
153 BlobArray<KyUInt32> m_values;
157 SwapEndianness(e,
self.m_name);
158 SwapEndianness(e,
self.m_category);
159 SwapEndianness(e,
self.m_valueType);
160 SwapEndianness(e,
self.m_values);
164 class BlobMultiField32Mapping
168 BlobMultiField32Mapping()
169 : m_valueType(BlobField32::Type_Unset), m_name(
nullptr), m_category(
nullptr) {}
171 BlobMultiField32Mapping(
KyUInt32 type,
const char* name,
const char* category,
KyUInt32 size)
172 : m_valueType(type), m_name(name), m_category(category), m_values(size) {}
175 KyUInt32 GetCount()
const {
return m_values.GetCount(); }
177 void MapUInt32(
KyUInt32 index,
const KyUInt32& value) { m_values[index] = (
char*)&value; }
178 void MapInt32(
KyUInt32 index,
const KyInt32& value) { m_values[index] = (
char*)&value; }
179 void MapFloat32(
KyUInt32 index,
const KyFloat32& value) { m_values[index] = (
char*)&value; }
187 if (m_valueType == BlobField32::Type_Bool)
188 *((
bool*)m_values[index]) = (blobValue32 != 1);
190 *((
KyUInt32*)m_values[index]) = blobValue32;
196 const char* m_category;
197 KyArrayPOD<char*> m_values;
201 template <
class OSTREAM>
202 inline OSTREAM& operator<<(OSTREAM& os, BlobMultiField32Mapping& mapping)
204 os << mapping.m_name <<
"(" << mapping.m_category <<
") : ";
206 for (
KyUInt32 idx = 0; idx < mapping.GetCount(); ++idx)
208 switch(mapping.m_valueType)
210 case BlobField32::Type_KyUInt32 : os << ((
KyUInt32) (mapping.ValueAsUInt32(idx)));
break;
211 case BlobField32::Type_KyInt32 : os << ((
KyInt32) (mapping.ValueAsInt32(idx)));
break;
212 case BlobField32::Type_KyFloat32 : os << ((
KyFloat32)(mapping.ValueAsFloat32(idx)));
break;
223 class BlobMultiField32Builder :
public BaseBlobBuilder<BlobMultiField32>
226 BlobMultiField32Builder(BlobMultiField32Mapping& mapping) : m_mapping(&mapping) {}
229 virtual void DoBuild()
235 KyUInt32 count = m_mapping->GetCount();
239 for (
KyUInt32 idx = 0; idx < count; ++idx)
241 blobValues[idx] = m_mapping->ValueAsUInt32(idx);
246 BlobMultiField32Mapping* m_mapping;
#define BLOB_SET(blob, value)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:130
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
BlobField32 * m_blob
The blob maintained by this builder. Only modify using the macros listed under DoBuild().
Definition: baseblobbuilder.h:113
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
bool IsWriteMode()
Indicates whether the builder is operating in COUNT mode or in WRITE mode.
Definition: baseblobbuilder.h:43
#define BLOB_STRING(str, src)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:166
std::int32_t KyInt32
int32_t
Definition: types.h:24
#define BLOB_ARRAY(blobArray, count)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:139
float KyFloat32
float
Definition: types.h:32