/*********************************************************************** * ebase library - an embedded C++ database library * * Copyright (C) 2001, Jun Sun, jsun@mvista.com or jsun@junsun.net. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * *********************************************************************** */ #ifndef _ebsearch_h_ #define _ebsearch_h_ #include "ebase.h" /********************************************************************** *Client-level search functions ********************************************************************** */ //====================================================================== // CLASS EbSearch // EbSearch is a client-level module that provides // single field based search functions. //====================================================================== class EbSearch { public: // -*- // Search options. enum { CASE = 0, NO_CASE = 1, CASE_MASK = 1, EXACT_MATCH = 0, PREFIX_MATCH = 2, SUFFIX_MATCH = 4, SUBSTRING_MATCH = 6, MATCH_MASK = 6, NORMAL = 0, NEGATIVE = 8, NEGATIVE_MASK = 8, EQUAL_TO = 0, LESS_THAN = 16, GREATER_THAN = 32, COMPARE_MASK = 48, SIGNED = 0, UNSIGNED = 64, SIGN_MASK = 64, FORWARD = 0, // search forward BACKWARD = 128, DIRECTION_MASK = 128, }; // -*- // Search for a string in a string field. // // If the search is backward, and startOffset is bigger than the number // of records, startOffset is adjusted to be the last record offset. // // Valid search flags include : //
// CASE (default) case-sensitive // NO_CASE case-insensitive // // EXACT_MATCH (default) exact match // PREFIX_MATCH search for prefix match // SUFFIX_MATCH search for suffix match // SUBSTRING_MATCH search for substring // // NORMAL (default) normal // NEGATIVE treat "match" as "not match"; vice versa. // // FORWARD (deafult) search forward // BACKWARD search backward //// // Flags from different groups can be combined together through '|' // operator. // // Para : // [in] iid // Index id according to whose sorting order the search is performed. // [in] fieldName // The field to be searched. // [in] startOffset // The first record to be search. // [in] string // The string to be searched for. It cannot be a NULL pointer. // [in] flag // How the string should be search. // // Return : // The offset of the matching record. Or < 0, if not found. // // Exceptoins : // [] EBE_DATABASE_NOT_OPEN // [] EBE_INVALID_INDEX // iid out of range // [] EBE_INVALID_FIELD // cannot find the field // [] EBE_FIELD_TYPE_MISMATCH // [] EBE_OUT_OF_MEMORY // static EbInt32 SearchString(Ebase *ebase, const char *fieldName, const char *string, EbUint32 flag=0, EbUint32 startOffset=0, EbUint32 iid=0); // -*- // Search for a number in a number field. // // If the search is backward, and startOffset is bigger than the number // of records, startOffset is set to the last record. // // Valid search flags include : //
// EQAUL_TO (default) equal // LESS_THAN search for less-than // GREATER_THAN search for greater-than // // SINGED (default) numbers are signed // UNSINGED // // NORMAL (default) normal // NEGATIVE treat "match" as "not match"; vice versa. // // FORWARD (deafult) search forward // BACKWARD search backward //// // Para : // [in] iid // Index id according to whose sorting order the search is performed. // [in] fieldName // The field to be searched. // [in] number // The the number to be searched for. // [in] flags // The search flags. // // Return : // The offset of the matching record. Or < 0 if not found. // // Exceptoins : // Those which are returned by GetRecord(), GetFieldInt32(). // static EbInt32 SearchNumber(Ebase *ebase, const char *fieldName, EbInt32 number, EbUint32 flags=0, EbUint32 startOffset=0, EbUint32 iid=0); }; #endif