_attributeVector[index]._publicationType = publicationType;
}
-HLADataElement::IndexPathPair
-HLAObjectClass::getIndexPathPair(const HLADataElement::StringPathPair& stringPathPair) const
+bool
+HLAObjectClass::getDataElementIndex(HLADataElementIndex& dataElementIndex, const std::string& path) const
{
- unsigned index = getAttributeIndex(stringPathPair.first);
+ if (path.empty()) {
+ SG_LOG(SG_NETWORK, SG_ALERT, "HLAObjectClass: failed to parse empty element path!");
+ return false;
+ }
+ std::string::size_type len = std::min(path.find_first_of("[."), path.size());
+ unsigned index = 0;
+ while (index < getNumAttributes()) {
+ if (path.compare(0, len, getAttributeName(index)) == 0)
+ break;
+ ++index;
+ }
if (getNumAttributes() <= index) {
- SG_LOG(SG_NETWORK, SG_ALERT, "HLAObjectClass::getIndexPathPair(\""
- << HLADataElement::toString(stringPathPair)
- << "\"): Could not resolve attribute \"" << stringPathPair.first
- << "\" for object class \"" << getName() << "\"!");
+ SG_LOG(SG_NETWORK, SG_ALERT, "HLAObjectClass: faild to parse data element index \"" << path << "\":\n"
+ << "Attribute \"" << path.substr(0, len) << "\" not found in object class \""
+ << getName() << "\"!");
+ return false;
+ }
+ if (!getAttributeDataType(index)) {
+ SG_LOG(SG_NETWORK, SG_ALERT, "HLAObjectClass: faild to parse data element index \"" << path << "\":\n"
+ << "Undefined attribute data type in variant record data type \""
+ << getAttributeName(index) << "\"!");
+ return false;
}
- return HLADataElement::IndexPathPair(index, stringPathPair.second);
+ dataElementIndex.push_back(index);
+ return getAttributeDataType(index)->getDataElementIndex(dataElementIndex, path, len);
}
-HLADataElement::IndexPathPair
-HLAObjectClass::getIndexPathPair(const std::string& path) const
+HLADataElementIndex
+HLAObjectClass::getDataElementIndex(const std::string& path) const
{
- return getIndexPathPair(HLADataElement::toStringPathPair(path));
+ HLADataElementIndex dataElementIndex;
+ getDataElementIndex(dataElementIndex, path);
+ return dataElementIndex;
}
bool