const std::string& ExportDataManager::getDataPath(const std::string& _name) { static std::string path; VectorString result; common::VectorWString wresult; for (VectorArhivInfo::const_iterator item = mPaths.begin(); item != mPaths.end(); ++item) { common::scanFolder(wresult, (*item).name, (*item).recursive, MyGUI::UString(_name).asWStr(), true); } for (common::VectorWString::const_iterator item = wresult.begin(); item != wresult.end(); ++item) { result.push_back(MyGUI::UString(*item).asUTF8()); } if (!result.empty()) { path = result[0]; if (result.size() > 1) { MYGUI_PLATFORM_LOG(Warning, "There are several files with name '" << _name << "'. '" << path << "' was used."); MYGUI_PLATFORM_LOG(Warning, "Other candidater are:"); for (size_t index = 1; index < result.size(); index ++) MYGUI_PLATFORM_LOG(Warning, " - '" << result[index] << "'"); } } return path; }
CDB::stringSeq* DAOProxy::get_string_seq (const char * propertyName) { //ACS_TRACE("cdb::DAOProxy::get_string_seq"); // check remote mode if (m_dao.ptr() != CDB::DAO::_nil()) return m_dao->get_string_seq(propertyName); string value; try{ get_field(propertyName, value); }catch(cdbErrType::CDBFieldDoesNotExistExImpl ex){ throw ex.getCDBFieldDoesNotExistEx(); } VectorString array; split(value.c_str(), array); CDB::stringSeq_var seq = new CDB::stringSeq(); seq->length(array.size()); CORBA::ULong i = 0; for (VectorString::const_iterator iter = array.begin(); iter != array.end(); iter++) { seq[i++] = CORBA::string_dup(iter->c_str()); } return seq._retn(); }
const VectorString& Ogre2DataManager::getDataListNames(const std::string& _pattern, bool _fullpath) { static VectorString result; result.clear(); VectorString search; if (mAllGroups) { Ogre::StringVector sp = Ogre::ResourceGroupManager::getSingleton().getResourceGroups(); search.reserve(sp.size()); for (size_t i = 0; i < sp.size(); i++) search.push_back(sp[i]); } else search.push_back(mGroup); std::vector<Ogre::FileInfoListPtr> pFileInfos; int resultSize = 0; for (size_t i = 0; i < search.size(); i++) { Ogre::FileInfoListPtr pFileInfo = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(search[i], _pattern); resultSize += pFileInfo->size(); if (!pFileInfo->empty()) pFileInfos.push_back(pFileInfo); else pFileInfo.setNull(); } result.reserve(resultSize); for (size_t i = 0; i < pFileInfos.size(); i++) { Ogre::FileInfoListPtr pFileInfo = pFileInfos[i]; for (Ogre::FileInfoList::iterator fi = pFileInfo->begin(); fi != pFileInfo->end(); ++fi ) { if (fi->path.empty()) { bool found = false; for (VectorString::iterator iter = result.begin(); iter != result.end(); ++iter) { if (*iter == fi->filename) { found = true; break; } } if (!found) { result.push_back(_fullpath ? fi->archive->getName() + "/" + fi->filename : fi->filename); } } } pFileInfo.setNull(); } return result; }
bool DataMgr::LoadFromFile(const char *fileName) { std::string temp = GetFileData(fileName); if (temp.empty()) return false; std::vector<std::string> vec; int pos; const char LF = 0x0a; while(true) { if(temp.empty()) break; pos = temp.find(LF); if(pos != -1) { vec.push_back(temp.substr(0,pos)); temp = temp.substr(pos + 1); } else { vec.push_back(temp); temp = ""; } } m_StringMap.clear(); for(int i = 0;i < (int)vec.size();++i) { std::string & str = vec[i]; temp = GetDecryptedStr(str.c_str(),str.size()); VectorString vecSplit; SplitToList(temp,vecSplit,'='); if(vecSplit.size() != 2) continue; std::string keylower = vecSplit[0]; ToLower(keylower); size_t len = keylower.size(); size_t size = strlen(SAVE_TAG); size_t pos = keylower.find(SAVE_TAG); if (len >= size && pos == len-size) m_StringMap.insert(std::make_pair(keylower,vecSplit[1])); } m_save_file = fileName; return true; }
const std::string& HGEDataManager::getDataPath(const std::string& _name) { static std::string path; VectorString result; common::VectorWString wresult; for (VectorArhivInfo::const_iterator item = mPaths.begin(); item != mPaths.end(); ++item) { common::scanFolder(wresult, (*item).name, (*item).recursive, MyGUI::UString(_name).asWStr(), true); } for (common::VectorWString::const_iterator item = wresult.begin(); item != wresult.end(); ++item) { result.push_back(MyGUI::UString(*item).asUTF8()); } path = result.size() == 1 ? result[0] : ""; return path; }
CDB::longSeq * DAOProxy::get_long_seq (const char * propertyName) { //ACS_TRACE("cdb::DAOProxy::get_long_seq"); // check remote mode if (m_dao.ptr() != CDB::DAO::_nil()) return m_dao->get_long_seq(propertyName); string value; try{ get_field(propertyName, value); }catch(cdbErrType::CDBFieldDoesNotExistExImpl ex){ throw ex.getCDBFieldDoesNotExistEx(); } VectorString array; split(value.c_str(), array); CDB::longSeq_var seq = new CDB::longSeq(); seq->length(array.size()); CORBA::ULong i = 0; for (VectorString::const_iterator iter = array.begin(); iter != array.end(); iter++) { std::istringstream is(iter->c_str()); CORBA::Long val; (istream&) is >> val; if (!is) throw cdbErrType::WrongCDBDataTypeExImpl( __FILE__, __LINE__, "cdb::DAOProxy::get_long" ).getWrongCDBDataTypeEx(); // throw CDB::WrongDataType(); seq[i++] = val; } return seq._retn(); }
void SettingsSector::setPropertyValueList(const MyGUI::UString& _propertyName, const VectorString& _propertyValues) { clearProperty(_propertyName); for (size_t index = 0; index < _propertyValues.size(); ++ index) setPropertyValue(MyGUI::utility::toString(_propertyName, '.', index), _propertyValues[index]); }