// processLine - parse a line from the input file into the element and operation sets // then perform the element swaps void processLine (std::string& str) { std::istringstream is(str); std::string segment; // parse the element set std::vector<int> list; list.reserve(10); std::getline(is, segment, ':'); getList(list,segment); // parse the operation set std::vector<OPERATION> ops; ops.reserve(10); std::getline(is, segment, ':'); getOperations(ops, segment); // swap the elements as instructed doSwaps (list,ops); // print out the elements in their new order printList (list); }
bool ModelClassifier::isDefinition() const { return(getAttributes().size() + getOperations().size() > 0); }
QList<CatItem> Catalog::parseRequest(InputList & inputData, int itemsDesired, int* beginPos){ if(inputData.customVerbChosen() && !inputData.isOperationChosen()){ return cat_store.getItemsByKey(inputData.getUserKeys(), &inputData, itemsDesired); } if(inputData.isOperationChosen()){ return getOperationChildren(inputData); } if(!inputData.getParentItem().isEmpty() ){ if(inputData.getParentItem().canFilterWith()){ return cat_store.getAssociatedDocuments(&inputData, inputData.getParentItem(), itemsDesired); } else { CatItem par = cat_store.getItemByPath(inputData.getParentItem().getPath(),1); CatBuilder::updateItem(par,2,UserEvent::SELECTED); return par.getChildren(); } } QList<CatItem> res; if(inputData.getUserKeys().length() >0){ QString userKeys = inputData.getUserKeys(); res.append(cat_store.getItemsByKey(userKeys, &inputData, itemsDesired, beginPos)); } else if(inputData.slotCount() ==1 || inputData.isOperationChosen()){ res.append(cat_store.getInitialItems(&inputData, itemsDesired, beginPos)); } if(res.count()>0 && beginPos){ (*beginPos)++; } if(inputData.slotCount()>1 ){ QList<CatItem> extra_actions; if(inputData.isCustomVerbChoosableByArgSig()) { extra_actions = parseCustomVerbSelection(inputData); } QList<CatItem> operations = getOperations(inputData); if(extra_actions.count() > MAX_SEPERATE_VERBS){ res.push_front( CatItem::createTempfolder(EXTRA_ACTIONS_PSUEDO_FOLD_NAME, extra_actions)); } else { res.append(extra_actions); } res.append(operations); //At "bare" verb - possibly w/ operation if(inputData.verbPosition() ==0){ if(inputData.hasVerb() && !inputData.customVerbChosen() && inputData.nounList().length()==0){ res.push_front(CatItem::createRunPseudoItem()); } res.append(cat_store.getAssociatedDocuments(&inputData, inputData.getFilterItem(), itemsDesired)); } if(inputData.atPossibleVerbSlot()){ inputData.setDefaultVerbIfNeeded(); CatItem defVerb = inputData.getItemDefaultVerb(); if(!defVerb.isEmpty()) { res.append(defVerb); } QList<CatItem> associations = inputData.getNormalAssociation(); CatItem defaultVerb = inputData.getItemDefaultVerb(); if(!defaultVerb.isEmpty()) { res.append(defaultVerb); } if(associations.count() > MAX_SEPERATE_VERBS){ res.push_front( CatItem::createTempfolder(ASSOCIATED_APPS_PSUEDO_FOLD_NAME, associations)); } else { res.append(associations); } } } CatItem curArg = inputData.argChosenType(); if(!curArg.isEmpty()) { res.append(cat_store.getItemChildren(&inputData, curArg)); } qDebug() << res.count() << " items found"; return res; }