Angus Leeming <[EMAIL PROTECTED]> writes: | The whole point of this exercise was to clean-up the code in biblio.C. As a | side effect, boost::regex searching now works in the same way as 1.2. > | Ok to apply?
Ok, but I belive it could be further simplified. | vector<string>::const_iterator | searchKeys(InfoMap const & theMap, | vector<string> const & keys, | - string const & expr, | + string const & search_expr, | vector<string>::const_iterator start, | Search type, | Direction dir, | @@ -330,16 +341,23 @@ searchKeys(InfoMap const & theMap, | if (start < keys.begin() || start >= keys.end()) | return keys.end(); | | - string search_expr = trim(expr); | - if (search_expr.empty()) | - return keys.end(); | - | - if (type == SIMPLE) | - return simpleSearch(theMap, keys, search_expr, start, dir, | - caseSensitive); | + string expr = trim(search_expr); | + if (expr.empty()) | + return keys.end(); | | - return regexSearch(theMap, keys, search_expr, start, dir); | -} | + if (type == SIMPLE) { | + if (!caseSensitive) | + expr = lowercase(expr); | + SimpleMatch match(theMap, | + getVectorFromString(expr, " "), | + caseSensitive); | + return findMatch(start, keys, dir, match); | + | + } else { // type == REGEX | + RegexMatch const match(theMap, boost::regex(STRCONV(expr))); | + return findMatch(start, keys, dir, match); | + } | + } use a switch: switch (type) { case SIMPLE: if (!caseSensitive) expr = lowercase(expr); SimpleMatch match(theMap, getVectorFromString(expr, " "), caseSensitive); return findMatch(start, keys, dir, match); case REGEX: RegexMatch const match(theMap, boost::regex(STRCONV(expr))); return findMatch(start, keys, dir, match); } (some more braces needed) -- Lgb