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(); }
VectorString UtilString::split(const string &str, const string &delim /* = */, uint32_t maxSplits /* = 0 */) { VectorString ret; uint32_t numSplits = 0; size_t start = 0; size_t pos = 0; do { pos = str.find_first_of(delim, start); if (pos == start) { ret.push_back(""); start = pos + 1; } else if (pos == string::npos || (maxSplits && numSplits == maxSplits)) { ret.push_back(str.substr(start)); break; } else { ret.push_back(str.substr(start, pos - start)); start = pos + 1; } ++numSplits; } while (pos != string::npos); return ret; }
void LanguageManager::loadLanguage(const VectorString & _list, const std::string & _group) { mMapLanguage.clear(); for (VectorString::const_iterator iter=_list.begin(); iter!=_list.end(); ++iter) { loadLanguage(*iter, _group); } }
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 VectorString& ExportDataManager::getDataListNames(const std::string& _pattern) { static VectorString result; common::VectorWString wresult; result.clear(); for (VectorArhivInfo::const_iterator item = mPaths.begin(); item != mPaths.end(); ++item) { common::scanFolder(wresult, (*item).name, (*item).recursive, MyGUI::UString(_pattern).asWStr(), false); } for (common::VectorWString::const_iterator item = wresult.begin(); item != wresult.end(); ++item) { result.push_back(MyGUI::UString(*item).asUTF8()); } return result; }
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; }
void SettingsManager::setValueList(const std::string& _path, const VectorString& _values) { if (!MyGUI::utility::endWith(_path, ".List")) return; std::string itemName = "Value"; pugi::xml_node targetNode; pugi::xpath_node node = mUserDocument->document_element().select_single_node(_path.c_str()); if (!node.node().empty()) { targetNode = node.node(); while (!targetNode.first_child().empty()) targetNode.remove_child(targetNode.first_child()); } else { std::vector<std::string> names; std::string delims("/"); names = MyGUI::utility::split(_path, delims); pugi::xml_node currentNode = mUserDocument->document_element(); for (std::vector<std::string>::const_iterator name = names.begin(); name != names.end(); name ++) { pugi::xml_node childNode = currentNode.child((*name).c_str()); if (childNode.empty()) childNode = currentNode.append_child((*name).c_str()); currentNode = childNode; } targetNode = currentNode; } for (VectorString::const_iterator value = _values.begin(); value != _values.end(); value ++) targetNode.append_child(itemName.c_str()).text().set((*value).c_str()); eventSettingsChanged(_path); }
const VectorString& OgreDataManager::getDataListNames(const std::string& _pattern, bool _fullpath) { static VectorString result; result.clear(); Ogre::FileInfoListPtr pFileInfo = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(mGroup, _pattern); result.reserve(pFileInfo->size()); 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; }
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]); }
bool DAOProxy::split(const string& str, VectorString& array) { //ACS_TRACE("cdb::DAOProxy::split"); // The string that will be added to the list next. string strCur; // Tells us what kind of quote we are in. bool bQuote = 0; unsigned int iter = 0; unsigned int len = str.length(); array.clear(); while(iter < len) { // We got to a whitespace and we are not in a quote: push the currently // build substring at the end of the array. if(!bQuote && str[iter] == ',') { if(strCur.length()!=0) { array.push_back(strCur); strCur.erase(strCur.begin(), strCur.end()); // using erase because clear not supported on VxWorks } } // Escape sequence. else if(str[iter] == '\\') { ++iter; // Whoops, escape ended before the new line. if(iter == len) { return false; } switch(str[iter]) { case 'n': strCur += '\n'; break; case 'r': strCur += '\r'; break; case ',': case '\\': case '\'': case '"': // Treat next character verbatim, regardless what it may be. strCur += str[iter]; break; default: // An unrecognized escape! return false; } } // The quote ended. else if(bQuote && str[iter] == '"') { // Indicate that we are in the quote no longer. bQuote = 0; array.push_back(strCur); strCur.erase(strCur.begin(), strCur.end()); // using erase because clear not supported on VxWorks } // The quote begun. else if(str[iter] == '"') { if(strCur.length()!=0) { array.push_back(strCur); strCur.erase(strCur.begin(), strCur.end()); // using erase because clear not supported on VxWorks } bQuote = 1; } else { // A regular character. strCur += str[iter]; } ++iter; } // Push the last string to the end of the array. if(strCur.length()!=0) { array.push_back(strCur); } return true; }
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; }