46 #ifndef AI_METADATA_H_INC
47 #define AI_METADATA_H_INC
50 #pragma GCC system_header
53 #if defined(_MSC_VER) && (_MSC_VER <= 1500)
54 #include "Compiler/pstdint.h"
131 return AI_AIVECTOR3D;
134 return AI_AIMETADATA;
137 #endif // __cplusplus
172 for (
size_t i = 0; i < static_cast<size_t>(
mNumProperties); ++i) {
176 for (
size_t i = 0; i < static_cast<size_t>(
mNumProperties); ++i) {
178 switch (rhs.
mValues[i].mType) {
185 ::memcpy(&v, rhs.
mValues[i].mData,
sizeof(int32_t));
186 mValues[i].mData =
new int32_t(v);
190 ::memcpy(&v, rhs.
mValues[i].mData,
sizeof(uint64_t));
191 mValues[i].mData =
new uint64_t(v);
195 ::memcpy(&v, rhs.
mValues[i].mData,
sizeof(
float));
196 mValues[i].mData =
new float(v);
200 ::memcpy(&v, rhs.
mValues[i].mData,
sizeof(
double));
201 mValues[i].mData =
new double(v);
208 case AI_AIVECTOR3D: {
213 case AI_AIMETADATA: {
247 delete static_cast<bool *
>(data);
250 delete static_cast<int32_t *
>(data);
253 delete static_cast<uint64_t *
>(data);
256 delete static_cast<float *
>(data);
259 delete static_cast<double *
>(data);
262 delete static_cast<aiString *
>(data);
288 static inline aiMetadata *Alloc(
unsigned int numProperties) {
289 if (0 == numProperties) {
304 static inline void Dealloc(
aiMetadata *metadata) {
308 template <
typename T>
309 inline void Add(
const std::string &key,
const T &value) {
314 new_keys[i] =
mKeys[i];
329 template <
typename T>
330 inline bool Set(
unsigned index,
const std::string &key,
const T &value) {
345 mValues[index].mType = GetAiType(value);
348 if (
nullptr !=
mValues[index].mData && AI_AIMETADATA !=
mValues[index].mType) {
349 ::memcpy(
mValues[index].mData, &value,
sizeof(T));
350 }
else if (
nullptr !=
mValues[index].mData && AI_AIMETADATA ==
mValues[index].mType) {
351 *
static_cast<T *
>(
mValues[index].mData) = value;
353 mValues[index].mData =
new T(value);
359 template <
typename T>
360 inline bool Set(
const std::string &key,
const T &value) {
367 if (key ==
mKeys[i].C_Str()) {
377 template <
typename T>
378 inline bool Get(
unsigned index, T &value)
const {
386 if (GetAiType(value) !=
mValues[index].mType) {
397 template <
typename T>
398 inline bool Get(
const aiString &key, T &value)
const {
401 if (
mKeys[i] == key) {
402 return Get(i, value);
408 template <
typename T>
409 inline bool Get(
const std::string &key, T &value)
const {
431 inline bool HasKey(
const char *key) {
432 if (
nullptr == key) {
438 if (0 == strncmp(
mKeys[i].C_Str(), key,
mKeys[i].length)) {
468 switch (lhs.
mValues[i].mType) {
470 if (*
static_cast<bool *
>(lhs.
mValues[i].mData) != *
static_cast<bool *
>(rhs.
mValues[i].mData)) {
475 if (*
static_cast<int32_t *
>(lhs.
mValues[i].mData) != *
static_cast<int32_t *
>(rhs.
mValues[i].mData)) {
480 if (*
static_cast<uint64_t *
>(lhs.
mValues[i].mData) != *
static_cast<uint64_t *
>(rhs.
mValues[i].mData)) {
485 if (*
static_cast<float *
>(lhs.
mValues[i].mData) != *
static_cast<float *
>(rhs.
mValues[i].mData)) {
490 if (*
static_cast<double *
>(lhs.
mValues[i].mData) != *
static_cast<double *
>(rhs.
mValues[i].mData)) {
499 case AI_AIVECTOR3D: {
504 case AI_AIMETADATA: {
521 return CompareKeys(lhs, rhs) && CompareValues(lhs, rhs);
525 return !(lhs == rhs);
528 #endif // __cplusplus
531 #endif // AI_METADATA_H_INC