phonebookengines_old/contactsmodel/tsrc/dbcreator.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 11 Jun 2010 13:29:23 +0300
changeset 40 b46a585f6909
permissions -rw-r--r--
Revision: 201021 Kit: 2010123

/*
* Copyright (c) 2008-2009 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:
* Summary:
* A class for creating a CContactDatabase object with random data.
* The contact items take the form of the following example:
* [KUidContactFieldFamilyName]	Fasiokljno	<5-10 chars>
* [KUidContactFieldGivenName]		Liasidwq	<5-10 chars>
* [KUidContactFieldCompanyName]	Xwjweiohj	<5-10 chars>	
* [KUidContactFieldPhoneNumber]	9874234891	<10 digits>
* Usage example:
* #include "dbcreator.h"
* void MyFunctionL()
* // create a database populated with 500 randomly created contact items
* const TInt KNumContacts(500);
* _LIT(KDbName, "C:mydb.cbd");
* CContactDatabase* db = DbCreator::CreateDbL(KDbName, KNumContacts);
* CleanupStack::PushL(db);
* // do something interesting...
* CleanupStack::PopAndDestroy(db);
* CContactDatabase::DeleteDatabaseL(KDbName);
* Written by:
* James Clarke
* 
*
*/



#ifndef __DBCREATOR_H__
#define __DBCREATOR_H__

#include <cntdb.h>
#include <cntitem.h>
#include <cntfield.h>
#include <cntfldst.h>
#include <e32math.h>
#include <e32cmn.h>


class DbCreator
	{
public:
	static CContactDatabase* CreateDbL(const TDesC &aFileName, TInt aNumContacts);
private:
	static TUint RandomNum(TUint aMin, TUint aMax);
	static TChar RandomAlphaChar(TBool aIsUpper);
	static HBufC* RandomNameL();
	static HBufC* RandomPhoneNumL();
	static void PopulateDatabaseL(CContactDatabase& aDb, TInt aNumContacts);
	};



#endif //__DBCREATOR_H__