Ejemplo n.º 1
0
ListFilter::Preparation ListFilter::prepare(InfoFunction aInfoF, NumericFunction aNumericF) {
    Preparation prep = Preparation(matcher);
    if(empty())
        return prep;

    prep.column = getColumn();
    prep.method = getMethod();
    prep.type = COLUMN_TEXT;

    if (prep.method < StringMatch::METHOD_LAST || prep.column >= colCount) {
        if (mode != LAST) {
            prep.type = COLUMN_TIME;
            auto ret = prepareTime();

            if (!ret.second) {
                prep.type = COLUMN_SIZE;
                ret = prepareSize();
            }

            if (!ret.second) {
                prep.type = COLUMN_SPEED;
                ret = prepareSpeed();
            }

            if (!ret.second) {
                prep.type = COLUMN_NUMERIC_OTHER;
                prep.num = Util::toDouble(matcher.pattern);
            } else {
                prep.num = ret.first;
            }
        }

        matcher.setMethod(static_cast<StringMatch::Method>(prep.method));
        matcher.prepare();
    } else if (columns[prep.column]->colType == COLUMN_SIZE) {
        prep.type = COLUMN_SIZE;
        prep.num = prepareSize().first;
    } else if (columns[prep.column]->colType == COLUMN_TIME) {
        prep.type = COLUMN_TIME;
        prep.num = prepareTime().first;
    } else if (columns[prep.column]->colType == COLUMN_SPEED) {
        prep.type = COLUMN_SPEED;
        prep.num = prepareSpeed().first;
    } else if (columns[prep.column]->colType == COLUMN_NUMERIC_OTHER) {
        prep.type = COLUMN_NUMERIC_OTHER;
        prep.num = Util::toDouble(matcher.pattern);
    }

    prep.infoF = aInfoF;
    prep.numericF = aNumericF;
    return prep;
}
Ejemplo n.º 2
0
	void PropertyFilter::prepare(const string& aPattern, int aMethod, int aProperty) {
		WLock l(cs);
		setPattern(aPattern);
		setFilterMethod(static_cast<StringMatch::Method>(aMethod));
		setFilterProperty(aProperty);

		type = TYPE_TEXT;
		if (currentFilterProperty < 0 || currentFilterProperty >= propertyCount) {
			if (numComparisonMode != LAST) {
				// Attempt to detect the column type 

				type = TYPE_TIME;
				auto ret = prepareTime();

				if (!ret.second) {
					type = TYPE_SIZE;
					ret = prepareSize();
				}

				if (!ret.second) {
					type = TYPE_SPEED;
					ret = prepareSpeed();
				}

				if (!ret.second) {
					// Try generic columns
					type = TYPE_NUMERIC_OTHER;
					numericMatcher = Util::toDouble(matcher.pattern);
				} else {
					// Set the value if parsing succeed
					numericMatcher = ret.first;
				}
			} else {
				type = TYPE_TEXT;
				matcher.setMethod(static_cast<StringMatch::Method>(defMethod));
				matcher.prepare();
			}
		} else if (propertyTypes[currentFilterProperty].filterType == TYPE_SIZE) {
			type = TYPE_SIZE;
			numericMatcher = prepareSize().first;
		} else if (propertyTypes[currentFilterProperty].filterType == TYPE_TIME) {
			type = TYPE_TIME;
			numericMatcher = prepareTime().first;
		} else if (propertyTypes[currentFilterProperty].filterType == TYPE_SPEED) {
			type = TYPE_SPEED;
			numericMatcher = prepareSpeed().first;
		} else if (propertyTypes[currentFilterProperty].filterType == TYPE_NUMERIC_OTHER || propertyTypes[currentFilterProperty].filterType == TYPE_LIST_NUMERIC) {
			type = TYPE_NUMERIC_OTHER;
			numericMatcher = Util::toDouble(matcher.pattern);
		}
	}