bool ItemAttributes::hasAttribute(itemAttrTypes type) const { if(!validateIntAttrType(type)) return false; Attribute* attr = getAttrConst(type); if(attr){ return true; } return false; }
uint32_t ItemAttributes::getIntAttr(itemAttrTypes type) const { if (!validateIntAttrType(type)) { return 0; } Attribute* attr = getAttrConst(type); if (attr) { return static_cast<uint32_t>(0xFFFFFFFF & reinterpret_cast<ptrdiff_t>(attr->value)); } else { return 0; } }
const std::string& ItemAttributes::getStrAttr(itemAttrTypes type) const { if (!validateStrAttrType(type)) { return emptyString; } Attribute* attr = getAttrConst(type); if (attr) { return *(std::string*)attr->value; } else { return emptyString; } }
const std::string& ItemAttributes::getStrAttr(itemAttrTypes type) const { if(!validateStrAttrType(type)) return emptyString; //this will *NOT* create the attribute if it does not exist Attribute* attr = getAttrConst(type); if(attr){ return *(std::string*)attr->value; } else{ return emptyString; } }
const std::string& ItemAttributes::getStrAttr(const itemAttrTypes& type) const { static const std::string EMPTY_STRING; if (!validateStrAttrType(type)) { return EMPTY_STRING; } //this will *NOT* create the attribute if it does not exist Attribute* attr = getAttrConst(type); if (attr) { return *(std::string*)attr->value; } else { return EMPTY_STRING; } }