phonebookengines/contactsmodel/cntdbdumper/src/dbsqldumper.h
changeset 0 e686773b3f54
child 24 0ba2181d7c28
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /**
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef __CDbSqlDumper_H__
       
    27 #define __CDbSqlDumper_H__
       
    28 
       
    29 #include <e32std.h>
       
    30 #include <e32def.h>
       
    31 #include <f32file.h>
       
    32 #include <badesca.h>
       
    33 #include <sqldb.h> 
       
    34 #include <e32cmn.h>
       
    35 #include <e32base.h>
       
    36 
       
    37 /**
       
    38 Utility class used to provide table names and column names existing in the sql database.
       
    39 It is mapped to a specific sql schema.
       
    40 
       
    41 */
       
    42 class CDbStructure : public CBase
       
    43 	{
       
    44 public:
       
    45 	CDbStructure();
       
    46 	~CDbStructure();
       
    47 	void Init();
       
    48 	TBool NextTable();
       
    49 	const TDesC& TableName();
       
    50 	const TDesC& TableName(TInt aTablePosition);
       
    51 	TBool NextColumn(TInt aTableIndex);
       
    52 	const TDesC& Column(TInt aTableIndex);
       
    53 	const TDesC& Column(TInt aTableIndex, TInt aColumnIndex);
       
    54 	TBool IsLastColumn(TInt aTableIndex);
       
    55 	TInt ColumnNo(const TInt aTableIndex);
       
    56 	
       
    57 private:
       
    58 	TInt iTablesIndex;
       
    59 	TInt iNumTables;	
       
    60 	RArray<TInt> iColumnsIndex;
       
    61 	RArray<TInt> iNumColumns;
       
    62 	};
       
    63 
       
    64 /** 
       
    65 CDbSqlDumper class dumps the contents and columns of all tables in 
       
    66 a given sql database in HTML format to a given location 
       
    67 */
       
    68 class CDbSqlDumper : public CBase
       
    69 	{
       
    70 public:  
       
    71    	static CDbSqlDumper* NewLC(const TDesC& aDbName, const TDesC& aOutputDir);
       
    72 	~CDbSqlDumper();
       
    73 	void OutputDBContentsL(); 
       
    74 		                      
       
    75 private: 	
       
    76     void ConstructL(const TDesC& aDbName, const TDesC& aOutputDir);  
       
    77 	void OutputTableNameToFile(TInt aTableIndex);
       
    78 	void OutputTableColHeadingsToFile(TInt aTableIndex);
       
    79 	void OutputTableColDataToFileL(TInt aTableIndex);
       
    80 	void OutputTableToFileL(TInt aTableIndex);
       
    81 
       
    82 	void FieldHeaderColL(TInt aFieldIndex);
       
    83 	void LongBinaryL(TInt aFieldIndex);
       
    84 	void DumpStreamL(RReadStream& stream);
       
    85 
       
    86 	void PrepareSQLStatementL(TInt aTableIndex);
       
    87 private: 
       
    88 	RFs	iFsSession;
       
    89 	RSqlDatabase iDatabase;
       
    90 	RSqlStatement iSqlStatement;
       
    91 	RPointerArray<TDesC> iTableNames; 
       
    92 	RFile iFile;
       
    93 	HBufC8*	iBuffer;
       
    94 	CDbStructure* iDbStructure;
       
    95 	};
       
    96 	
       
    97 #endif // __CDbSqlDumper_H__