11 #include <utility/dllexport.h>
48 if (mType != lhs.
mType)
52 if (mType == Type::ATTRIBUTE)
53 return strcmp(Attribute.Name, lhs.
Attribute.Name) == 0;
54 else if (mType == Type::ARRAY_ELEMENT)
66 return !(*
this == lhs);
69 Type mType = Type::INVALID;
101 mType(Type::ATTRIBUTE)
103 Attribute.Name = attributeName;
114 mType(Type::ATTRIBUTE)
116 mAttributeNameStorage = std::make_unique<std::string>(attributeName);
117 Attribute.Name = mAttributeNameStorage->data();
125 PathElement(
int arrayIndex) :
126 mType(Type::ARRAY_ELEMENT)
128 ArrayElement.Index = arrayIndex;
134 PathElement(
const PathElement& other)
142 PathElement& operator=(
const PathElement& other)
157 inline void copyFrom(
const PathElement& other)
160 if (mType == Type::ATTRIBUTE)
162 if (other.mAttributeNameStorage ==
nullptr)
164 Attribute.Name = other.Attribute.Name;
168 mAttributeNameStorage = std::make_unique<std::string>(*other.mAttributeNameStorage);
169 Attribute.Name = mAttributeNameStorage->data();
172 else if (mType == Type::ARRAY_ELEMENT)
174 ArrayElement.Index = other.ArrayElement.Index;
179 std::unique_ptr<std::string> mAttributeNameStorage;
217 initNonPOD(Root.Instance, instance);
218 initNonPOD(Root.Property, property);
228 mType(Type::ATTRIBUTE)
230 initNonPOD(Attribute.Variant, variant);
231 initNonPOD(Attribute.Property, property);
240 ResolvedRTTIPathElement(
const rtti::Variant& array,
int index) :
241 mType(Type::ARRAY_ELEMENT)
243 initNonPOD(ArrayElement.Array, array);
244 ArrayElement.Index = index;
250 ResolvedRTTIPathElement(
const ResolvedRTTIPathElement& other)
258 ~ResolvedRTTIPathElement()
266 ResolvedRTTIPathElement& operator=(
const ResolvedRTTIPathElement& other)
283 template <
typename T>
284 inline void initNonPOD(T& member,
const T& val)
286 new (&member) T(val);
292 inline void destroy()
295 if (mType == Type::ROOT)
297 Root.Instance.~instance();
298 Root.Property.~property();
300 else if (mType == Type::ATTRIBUTE)
302 Attribute.Variant.~variant();
303 Attribute.Property.~property();
305 else if (mType == Type::ARRAY_ELEMENT)
307 ArrayElement.Array.~variant();
314 inline void copyFrom(
const ResolvedRTTIPathElement& other)
317 if (mType == Type::ROOT)
319 initNonPOD(Root.Instance, other.Root.Instance);
320 initNonPOD(Root.Property, other.Root.Property);
322 else if (mType == Type::ATTRIBUTE)
324 initNonPOD(Attribute.Variant, other.Attribute.Variant);
325 initNonPOD(Attribute.Property, other.Attribute.Property);
327 else if (mType == Type::ARRAY_ELEMENT)
329 initNonPOD(ArrayElement.Array, other.ArrayElement.Array);
330 ArrayElement.Index = other.ArrayElement.Index;
420 assert(mLength < RTTIPATH_MAX_LENGTH);
433 assert(mLength < RTTIPATH_MAX_LENGTH);
444 assert(mLength < RTTIPATH_MAX_LENGTH);
475 assert(index < mLength);
476 return mElements[index];
484 if (mLength != lhs.mLength)
487 for (
int index = 0; index < mLength; ++index)
488 if (mElements[index] != lhs.mElements[index])
499 return !(*
this == lhs);
514 static const Path fromString(
const std::string& path);
529 static const int RTTIPATH_MAX_LENGTH = 16;
596 assert(mLength < RTTIPATH_MAX_LENGTH);
605 assert(mLength < RTTIPATH_MAX_LENGTH);
612 inline void pushArrayElement(
const rtti::Variant& array,
int index)
614 assert(mLength < RTTIPATH_MAX_LENGTH);
619 static const int RTTIPATH_MAX_LENGTH = 16;
620 ResolvedRTTIPathElement mElements[RTTIPATH_MAX_LENGTH];