2.1.2.38 okutil_is_in_list


Description

Check and see if given string is in the list. The match can be partial, and case insensitive, is desired. The search can start from any index.

Syntax

BOOL okutil_is_in_list( LPCSTR lpcszTest, StringArray * psaList, BOOL bCaseSensitive = false, BOOL bKeyPartialMatch = false, int * pnFound = NULL, int nStart = 0 )

Parameters

lpcszTest
[input] the string to search for.
psaList
[input] the list to search for the string lpcszTest.
bCaseSensitive
[input] if true, the search is case sensitive.
bKeyPartialMatch
[input] if true, the match can be partial meaning that lpcszTest need only match the first part of the string in the list.
pnFound
[output] the index in the list of the first match. The index starts at 0.
nStart
[input] the offset index from which to begin the search in the list.

Return

Returns true if found.

Examples

EX1

void okutil_is_in_list_ex1()
{
    vector<string> vsList = {"aaa", "bbb", "ccc", "ddd", "D", "eee", "fff"};
    string strFind = "D";
        
    //call with function defaults
    bool bIsInList = okutil_is_in_list( strFind, &vsList);
    //the search starts from 'aaa'. It finds "D" and returns true.
    
    //call again with following arguments
    bool bKeyCaseSensitive = false;
    bool bKeyPartialMatch = true;
    int nFirstIndexFound;
    int nStartOffset = 2;
    bIsInList = okutil_is_in_list( strFind, &vsList,  bKeyCaseSensitive, bKeyPartialMatch,  &nFirstIndexFound, nStartOffset);
    // this search begins with "ccc". It finds "ddd" to be a match since bKeyCaseSensitive = false and bKeyPartialMatch = true.
    // nFirstIndexFound is set to 3, and returns true.
}


See Also

is_in_list

Header to Included

origin.h

Reference