void Recurse(TiXmlNode * pParentNode, CCObject * pParentObj) { std::string keyValue; for (TiXmlNode * pNode = pParentNode->FirstChild(); pNode; pNode = pNode->NextSiblingElement()) { TiXmlElement * pNodeNE = pNode->ToElement(); if (pNodeNE == NULL) continue; const char * szValue = pNodeNE->Value(); const char * szText = pNodeNE->GetText(); if (_stricmp(szValue, "key") == 0) { keyValue = szText; } else if (_stricmp(szValue, "dict") == 0) { CCDictionary * pNewDict = new CCDictionary; addObject(pParentObj, keyValue, pNewDict); Recurse(pNode, pNewDict); } else if (_stricmp(szValue, "array") == 0) { CCArray * pNewArray = new CCArray(); addObject(pParentObj, keyValue, pNewArray); Recurse(pNode, pNewArray); } else if (_stricmp(szValue, "string") == 0) { const char * szIn = szText == NULL ? "" : szText; std::wstring ret = ConvertToWString(szIn); CCString * pString = new CCString(ret.c_str()); addObject(pParentObj, keyValue, pString); } else if (_stricmp(szValue, "false") == 0 || _stricmp(szValue, "true") == 0) { CCBool * pBool = new CCBool(_stricmp(szValue, "true") == 0); addObject(pParentObj, keyValue, pBool); } else if (_stricmp(szValue, "integer") == 0) { CCInteger * pInt = new CCInteger(atoi(szText)); addObject(pParentObj, keyValue, pInt); } else if (_stricmp(szValue, "real") == 0) { CCReal * pReal = new CCReal(atof(szText)); addObject(pParentObj, keyValue, pReal); } else if (_stricmp(szValue, "date") == 0) { CCDate * pDate = new CCDate(getTimeFromString(szText)); addObject(pParentObj, keyValue, pDate); } else { assert(!"unknown value"); } } }
//Metoda zwraca atrybut wskazanego typu std::wstring CXml::GetWString(xml_node<> *parent, const std::string &attrib_name) { xml_node<>* real_parent = parent ? parent : m_xml_root; if (real_parent) { if (attrib_name == "") { if (real_parent->first_node()) return ConvertToWString(real_parent->first_node()->value()); } else if (xml_attribute<>* attr = real_parent->first_attribute(attrib_name.c_str())) { std::string out = attr->value(); return ConvertToWString(out); } } return L""; }
void ccbiReader::readCachedString(wchar_t * pBuf) { const std::string & rStr = readCachedString(); wcscpy(pBuf, ConvertToWString(rStr).c_str()); }