localconnectivityservice/generichid/src/hidsearch.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 16:03:15 +0300
branchRCL_3
changeset 19 0aa8cc770c8a
permissions -rw-r--r--
Revision: 201032 Kit: 201035

/*
* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  HID field search
*
*/

#include <e32std.h>
#include <e32svr.h>

#include "hidreportroot.h"

// ======== MEMBER FUNCTIONS ========

// ---------------------------------------------------------------------------
// SearchL()
// ---------------------------------------------------------------------------
//
EXPORT_C void THidFieldSearch::SearchL(const CReportRoot* aReportRoot,
    MHidFieldFinder* aFinder)
    {
    iFinder = aFinder;

    if (aReportRoot)
        {
        TBool done = EFalse;
        for (TInt i=0; (i < aReportRoot->CollectionCount()) && !done; ++i)
            {
            done = !DoSearchL(aReportRoot->CollectionByIndex(i));
            }
        }
    }

// ---------------------------------------------------------------------------
// DoSearchL()
// ---------------------------------------------------------------------------
//
TBool THidFieldSearch::DoSearchL(const CCollection* aCollection)
    {
    if (iFinder->BeginCollection(aCollection))
        {
        TInt i;

        for (i=0; i < aCollection->FieldCount(); ++i)
            {
            iFinder->Field(aCollection->FieldByIndex(i));
            }

        for (i=0; i < aCollection->CollectionCount(); ++i)
            {
            if (!DoSearchL(aCollection->CollectionByIndex(i)))
                {
                return EFalse;
                }
            }
        }

    return iFinder->EndCollection(aCollection);
    }