OOFILE | Downloads | Purchasing | Press | Services | Company Information | Soapbox | References | F.A.Q. | HOME

Search expressions

Basic search expressions are the usual C++ comparative operations, applied to a field. Also available are the character search startsWith() and the numeric comparisons between() and outside().

(People.LastName.startsWith("De") );
(People.LastName == "Dent";                     - looks for an exact match

(People.Salary.between(50000, 99000) ) - includes endpoints 50000 & 99000

Combinatorial operators

The C++ logical and bitwise operators are both overloaded for combinatorial searches, as both interpretations make sense - the logical combination or bitwise combination of resulting sets. It also saves people remembering whether to use one character or two!

People.Salary >= 50000 & People.Salary <= 99000

is the same as
People.Salary >= 50000 && People.Salary

Search commands

The above expressions are passed into the basic search comands:
People[...];                                -   same as search() (People is the name of the table you wish to search)
People.searchSelection(...);  - a non-indexed subsearch within the previous search selection

*** WARNING ***

The search expression is a declaration, and so short-cut evaluation rules (as in the if statement) do NOT apply. All components of the expression will be fully evaluated. This should not be a problem as the idioms where short-cut evaluation are used are not applicable to OOFILE searches, ie: people don't do the equivalent of
if (aPointer && aPointer->someField);

Using indexed compound fields

If you need to perform a search on two fields, of the form
A==blah1 && B==blah2

Then you can define a compound field and index it. Remember that indexed fields are only used by search(), not searchSelection().

If there are further terms in the search, the compound index will still be used for the initial search of the first two terms.

Searching selections

searchSelection() is a sub-search of the current selection, which is equivalent to plain search() if the selection is allRecords. eg:


is equivalent to search().

It is always a non-indexed search and so it pays to optimise your searching so you reduce the selection as much as possible by an indexed search() before using the sub-searches.


The wildcards * and ? can be used in any string equality (== or !=) or startsWith() search expressions. The * matches 0-any characters and ? matches exactly one character. See ooftst18 for a number of examples.

Note that the following are equivalent:
People.search(People.LastName.startsWith("D*n*")); // redundant wildcard at end

Fast fragment searches

If you need to search for a number of fragments, it is very inefficient to repeat a wildcard search, eg:

People.search(People.LastName == "*wood*" || People.LastName == "*blah*");

This performs two passes over the entire database, testing every record in turn.

The alternatives allow you pass in a delimited (single character separator) list or array of char* strings and perform an OR or AND on all in one pass.

Note that the semantics of these are searchSelection(), so you need to do a selectAll() beforehand if you want a straight search().

searchSelContainsAllDelimited(field, string, char)
searchSelContainsAllOf(field, array, count)
searchSelContainsAnyDelimited(field, string, char)
searchSelContainsAnyOf(field, array, count)

eg, passing in a slash-delimited list:
People.searchSelContainsAnyDelimited(People.LastName, "ta/en/wood",'/');

or, using an array
char* BadRisks[] = {"ent", "ayl"};
People.searchSelContainsAnyOf(People.LastName, BadRisks, 2);

Non-indexed searches

All search expressions can now be performed regardless of an index on the fields.

If you are regularly only searching a field as a secondary expression in a combinatorial search (eg: LastName ... && Othernames...) or in searchSelection() then there is no point in indexing it, and incurring the space and time overhead of building an index.


Feature index

(c) Copyright A.D. Software 1994-2000 (All Rights Reserved).
Last Updated: 9th September 2001