//---------------------------------------------------------------------------------------------- std::string& CObjectAbstract::GetValueString(std::string &OutValue, bool bSaveAsExternal /*= false*/) const { typedef std::pair<std::string, std::string> TPairString; oes::rflex::AppClassTree &CTree = oes::rflex::GetClassTree(); std::map<std::string, std::string> ValueMap; ClassNode *pOwnClassNode = CTree.Find(GetType()); if (pOwnClassNode) { // prepare storage holder // Default block name ValueMap.insert(TPairString("Value", std::string("Name:") + GetName() + " ")); if (GetExternal()){ ValueMap.insert(TPairString("External", GetFilenameTag())); } // write down groups map ClassNode *pClassNode = pOwnClassNode; while (pClassNode) { // general properties const ClassNode::TVecProperties &VecProps = pClassNode->GetProperties(); ClassNode::TVecPropertyConstIterator IterProp = VecProps.begin(); while (IterProp != VecProps.end()) { if (ValueMap.find((*IterProp)->GetGroupName()) == ValueMap.end()) { ValueMap.insert(TPairString((*IterProp)->GetGroupName(), "")); } ++IterProp; } // Interfaces const ClassNode::TVecInterfaces &VecInterfaces = pClassNode->GetInterfaceProps(); ClassNode::TVecInterfaceConstIter IterIntf = VecInterfaces.begin(); while (IterIntf != VecInterfaces.end()) { ClassNode *pInfClass = CTree.FindInterface((*IterIntf)->strType); if (pInfClass) { const ClassNode::TVecProperties &IntfPropArray = pInfClass->GetProperties(); ClassNode::TVecPropertyConstIterator &IterPropIntf = IntfPropArray.begin(); while (IterPropIntf != IntfPropArray.end()) { if (ValueMap.find((*IterPropIntf)->GetGroupName()) == ValueMap.end()) { ValueMap.insert(TPairString((*IterPropIntf)->GetGroupName(), "")); } ++IterPropIntf; } } ++IterIntf; } pClassNode = pClassNode->GetRootNode(); } // write down values by group name std::map<std::string, std::string>::iterator IterGroup = ValueMap.begin(); while (IterGroup != ValueMap.end()) { if (IterGroup->first == "External"){ // already added skip IterGroup++; } ClassNode *pClassNode = pOwnClassNode; // write while (pClassNode) { const ClassNode::TVecProperties &PropsArray = pClassNode->GetProperties(); ClassNode::TVecPropertyConstIterator IterProp = PropsArray.begin(); while (IterProp != PropsArray.end()) { if (!bSaveAsExternal && (GetExternal() && !(*IterProp)->IsExternalProp())) { ++IterProp; continue; } if ((*IterProp)->IsSerializable() && IterGroup->first == (*IterProp)->GetGroupName()) { char Buff[1024] = {0}; char BuffDefault[1024] = {0}; (*IterProp)->GetProperty((BYTE*)this, Buff); if ((*IterProp)->GetDefaultValue(BuffDefault)) // check default value skip if necessary { if (!strcmp(Buff, BuffDefault)) { ++IterProp; continue; } } if (!(*IterProp)->IsCommonValue()) // common strategy format [Name:Value] { IterGroup->second += std::string((*IterProp)->GetName()) + ":" + std::string(Buff) + " "; } else // uninterrupted values purposes (string etc.) { IterGroup->second += Buff; } } ++IterProp; } //Interface Properties const ClassNode::TVecInterfaces &VecInterfaces = pClassNode->GetInterfaceProps(); ClassNode::TVecInterfaceConstIter IterIntf = VecInterfaces.begin(); while (IterIntf != VecInterfaces.end()) { ClassNode *pInfClass = CTree.FindInterface((*IterIntf)->strType); if (pInfClass) { const ClassNode::TVecProperties &IntfPropArray = pInfClass->GetProperties(); ClassNode::TVecPropertyConstIterator &IterPropIntf = IntfPropArray.begin(); while (IterPropIntf != IntfPropArray.end()) { if ((*IterPropIntf)->IsSerializable() && IterGroup->first == (*IterPropIntf)->GetGroupName()) { char Buff[1024] = {0}; char BuffDefault[1024] = {0}; int MemoryOffsetOverride = 0; { SInterfaceDecl* pIntfDecl = pClassNode->GetInterfaceDecl((*IterPropIntf)->GetClassName()); if (pIntfDecl){ MemoryOffsetOverride = pIntfDecl->byteShift; } } (*IterPropIntf)->GetProperty((BYTE*)this + MemoryOffsetOverride, Buff); if ((*IterPropIntf)->GetDefaultValue(BuffDefault)) // check default value skip if necessary { if (!strcmp(Buff, BuffDefault)) { ++IterPropIntf; continue; } } if (!(*IterPropIntf)->IsCommonValue()) // common strategy format [Name:Value] { IterGroup->second += std::string((*IterPropIntf)->GetName()) + ":" + std::string(Buff) + " "; } else // uninterrupted values purposes (string etc.) { IterGroup->second += Buff; } } ++IterPropIntf; } } ++IterIntf; } pClassNode = pClassNode->GetRootNode(); } ++IterGroup; } // write down transient property char txt[128] = {'\0'}; sprintf(txt, " Transient=\"%i\" ", int(IsTransient())); OutValue = txt;//" Transient=\"" + boost::lexical_cast<std::string>(int(IsTransient())) + "\" "; // put together all data IterGroup = ValueMap.begin(); while (IterGroup != ValueMap.end()) { if (!IterGroup->second.empty()) { OutValue += IterGroup->first + std::string("=\"") + IterGroup->second + std::string("\" "); } ++IterGroup; } } return OutValue; }