phonebookengines_old/contactsmodel/cntplsql/inc/cntsqlprovider.h
changeset 40 b46a585f6909
equal deleted inserted replaced
37:fd64c38c277d 40:b46a585f6909
       
     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 __CNTSQLPROVIDER_H__
       
    27 #define __CNTSQLPROVIDER_H__
       
    28 
       
    29 #include "cntsqlprovider.h"
       
    30 
       
    31 #include <e32cmn.h>
       
    32 #include <e32base.h>
       
    33 #include <badesca.h>
       
    34 
       
    35 /**
       
    36 Enumeration defining sql statement type.
       
    37 
       
    38 @internalComponent
       
    39 @released
       
    40 */
       
    41 enum TCntSqlStatement
       
    42 	{
       
    43 	EInsert,
       
    44 	EUpdate,
       
    45 	EDelete,
       
    46 	ESelect	
       
    47 	};
       
    48 	
       
    49 /**
       
    50 Class used to build a sql statement class. It holds the statement type and the 
       
    51 database table against which sql statement is run
       
    52 
       
    53 @internalComponent
       
    54 @released
       
    55 */
       
    56 NONSHARABLE_CLASS(TCntSqlStatementType)
       
    57 	{
       
    58 public:
       
    59 	TCntSqlStatementType(TCntSqlStatement aSqlStatement, const TDesC& aTableName);
       
    60 	void SetSqlStatement(TCntSqlStatement aSqlStatement);
       
    61 	TCntSqlStatement SqlStatement() const;
       
    62 	const TDesC& TableName() const;
       
    63 private:
       
    64 	TCntSqlStatement iSqlStatement;
       
    65 	const TDesC& iTableName;
       
    66 	};	
       
    67 
       
    68 /**
       
    69 An abstract object representing a sql statement.
       
    70 
       
    71 @internalComponent
       
    72 @released
       
    73 */
       
    74 NONSHARABLE_CLASS(CCntSqlStatement) : public CBase
       
    75 	{
       
    76 public:
       
    77 	virtual TDesC& SqlStringL() = 0;
       
    78 	void SetParamL(const TDesC& aParam, const TDesC& aValue);
       
    79 	void SetConditionL(const TDesC& aCondition);
       
    80 	void ClearCondition();
       
    81 	TInt ParameterIndex(const TDesC& aParam) const;
       
    82 	void Reset();
       
    83 	~CCntSqlStatement();
       
    84 	
       
    85 protected:
       
    86 	void ConstructL(const TDesC& aTableName);
       
    87 	
       
    88 protected:
       
    89 	HBufC* 			iTableName;
       
    90 	CDesCArrayFlat*	iParams;		
       
    91 	CDesCArrayFlat*	iValues;
       
    92 	HBufC*			iCondition;
       
    93 	HBufC*			iSqlString;
       
    94 	TBool			iProcessed;
       
    95 	};
       
    96 
       
    97 /**
       
    98 Concrete implementation for sql update statement.
       
    99 
       
   100 @internalComponent
       
   101 @released
       
   102 */	
       
   103 NONSHARABLE_CLASS(CCntSqlUpdate) : public CCntSqlStatement
       
   104 	{
       
   105 public:
       
   106 	static CCntSqlUpdate* NewL(const TDesC& aTableName);
       
   107 	TDesC& SqlStringL();
       
   108 	};
       
   109 
       
   110 /**
       
   111 Concrete implementation for sql delete statement.
       
   112 
       
   113 @internalComponent
       
   114 @released
       
   115 */		
       
   116 NONSHARABLE_CLASS(CCntSqlDelete) : public CCntSqlStatement
       
   117 	{
       
   118 public:
       
   119 	static CCntSqlDelete* NewL(const TDesC& aTableName);
       
   120 	TDesC& SqlStringL();
       
   121 	};
       
   122 
       
   123 
       
   124 /**
       
   125 Concrete implementation for sql insert statement.
       
   126 
       
   127 @internalComponent
       
   128 @released
       
   129 */	
       
   130 NONSHARABLE_CLASS(CCntSqlInsert) : public CCntSqlStatement
       
   131 	{
       
   132 public:
       
   133 	static CCntSqlInsert* NewL(const TDesC& aTableName);
       
   134 	TDesC& SqlStringL();
       
   135 	};
       
   136 	
       
   137 
       
   138 /**
       
   139 Concrete implementation for sql select statement.
       
   140 
       
   141 @internalComponent
       
   142 @released
       
   143 */		
       
   144 NONSHARABLE_CLASS(CCntSqlSelect) : public CCntSqlStatement
       
   145 	{
       
   146 public:
       
   147 	static CCntSqlSelect* NewL(const TDesC& aTableName);
       
   148 	TDesC& SqlStringL();
       
   149 	};
       
   150 	
       
   151 /**
       
   152 Factory class. Used to build CCntSqlStatement objects based on statement type provided
       
   153 
       
   154 @internalComponent
       
   155 @released
       
   156 */
       
   157 NONSHARABLE_CLASS(TSqlProvider)
       
   158 	{
       
   159 public:
       
   160 	static CCntSqlStatement* GetSqlStatementL(TCntSqlStatementType aStatementType);		
       
   161 	};	
       
   162 
       
   163 #endif //__CNTSQLPROVIDER_H__
       
   164