//Search through packs to find dir, if none found, default to 0. //This algorithm is a lot slower than doing the while( (it=it->next) ) however //it is also smaller and only used once. void packSetByPath(const char* dir) { int i=0; listItem* it=&ps.packs->begin; while( LISTFWD(ps.packs,it) ) { if( strcmp( ((packInfoType*)it->data)->path,dir ) == 0 ) { packSet(i); return; } i++; } SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "packSetByPath(); Error: Could not find pack with path '%s'\n",dir); packSet(0); return; }
/** * По имени выбирает все вхождения в список. */ stringSet getByName(const stringSet &in, const string &name) { stringSet::const_iterator beg = in.begin(); stringSet::const_iterator end = in.end(); stringSet result; while (beg != end) { TParam cur = (*--end); if (cur. getName() == name) result. push_back(cur); } packSet(result); return result; }
void packUnifySet(stringSet &l) { // Находим все массивы как скалярные переменные и // удаляем все их частные вхождения // также удаляем повторяющиеся элементы stringSet result; stringSet::const_iterator beg = l.begin(); stringSet::const_iterator end = l.end(); while (beg != end) { TParam cur = (*--end); if (!cur.isArrayElement()) { result. push_back(cur); continue; } if (!find(cur, result)) // удаляем повторения элементов result. push_back(cur); } packSet(result); // удаляем частные вхождения l = result; }