//-------------------------------------------------------------------------------- SFBool CSlurperApp::Filter(COptions& options, SFString& message) { double start = vrNow(); SFInt32 nFuncFilts=0; SFString funcFilts[20]; SFString filtList = options.funcFilter; while (!filtList.IsEmpty()) funcFilts[nFuncFilts++] = nextTokenClear(filtList, ','); theAccount.nVisible=0; for (int i=0;i<theAccount.transactions.getCount();i++) { CTransaction *trans = &theAccount.transactions[i]; // Turn every transaction on and then turning them off if they match the filter. trans->setShowing(TRUE); // The -blocks and -dates filters are mutually exclusive, -dates predominates. if (options.firstDate != earliestDate || options.lastDate != latestDate) { SFTime date = trans->getDate(); SFBool isVisible = (date >= options.firstDate && date <= options.lastDate); trans->setShowing(isVisible); } else if (options.firstBlock2Read!=0||options.lastBlock2Read!=LONG_MAX) { SFInt32 bN = trans->blockNumber; SFBool isVisible = (bN >= options.firstBlock2Read && bN <= options.lastBlock2Read); trans->setShowing(isVisible); } // The -incomeOnly and -expensesOnly filters are also mutually exclusive ASSERT(!(options.incomeOnly && options.expenseOnly)); // can't be both if (options.incomeOnly && trans->to != theAccount.addr) { if (verbose) outErr << trans->Format("\tskipping expenditure [{HASH}]\n"); trans->setShowing(FALSE); } else if (options.expenseOnly && trans->from != theAccount.addr) { if (verbose) outErr << trans->Format("\tskipping inflow [{HASH}]\n"); trans->setShowing(FALSE); } if (!options.funcFilter.IsEmpty()) { SFBool show = FALSE; for (int i=0;i<nFuncFilts;i++) show = (show || trans->isFunction(funcFilts[i])); trans->setShowing(show); } theAccount.nVisible += trans->isShowing(); SFInt32 nFiltered = (theAccount.nVisible+1); if (!(nFiltered%REP_INFREQ)) { outErr << "\t" << "Filtering..." << nFiltered << " records passed." << (isTesting?"\n":"\r"); outErr.Flush(); } } if (!isTesting) { double stop = vrNow(); double timeSpent = stop-start; fprintf(stderr, "\tFilter passed %ld visible records of %ld in %f seconds\n", theAccount.nVisible, theAccount.transactions.getCount(), timeSpent); fflush(stderr); } return TRUE; }