secureswitools/swisistools/source/dbmanager/dbprocessor.h
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
     1 /*
     1 /*
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    30 #pragma warning(disable: 4273)
    30 #pragma warning(disable: 4273)
    31 
    31 
    32 #include "./sqlite/sqlite3.h"
    32 #include "./sqlite/sqlite3.h"
    33 #include "symbiantypes.h"
    33 #include "symbiantypes.h"
    34 #include <string>
    34 #include <string>
    35 
       
    36 #ifdef __linux__
       
    37 typedef void* HINSTANCE;
       
    38 #else
       
    39 #include <windows.h>
    35 #include <windows.h>
    40 #endif // __linux__
       
    41 
    36 
    42 // Forward declarations
    37 // Forward declarations
    43 class CStatement;
    38 class CStatement;
    44 
    39 
    45 typedef int (*FnPtr_sqlite3_open)(const char *filename, sqlite3 **ppDb );
    40 typedef int (*FnPtr_sqlite3_open)(const char *filename, sqlite3 **ppDb );
   110 		HINSTANCE sqLiteHndl;
   105 		HINSTANCE sqLiteHndl;
   111 		
   106 		
   112 	};
   107 	};
   113 
   108 
   114 
   109 
   115 #ifdef __TOOLS2_LINUX__
       
   116 typedef enum {
       
   117 	allowSlashConversion = 0,
       
   118 	avoidSlashConversion
       
   119 } SlashConversionFlags;
       
   120 
       
   121 // utf16WString represents the UTF-16 data(WINDOWS wstring).
       
   122 typedef std::basic_string<unsigned short int> utf16WString;
       
   123 
       
   124 
       
   125 inline void ConvertToWindowsSpecificPaths(std::wstring& aPath)
       
   126 {
       
   127 		std::wstring::size_type idx = 0;
       
   128 		while( (idx = aPath.find(L"//", idx)) != std::wstring::npos)
       
   129 		{
       
   130 			aPath.replace( idx, 2, L"\\\\" );
       
   131 		}
       
   132 
       
   133 		idx = 0;
       
   134 
       
   135 		while( (idx = aPath.find(L"/", idx)) != std::wstring::npos)
       
   136 		{
       
   137 			aPath.replace( idx, 1, L"\\" );
       
   138 		}
       
   139 }
       
   140 
       
   141 inline void ConvertToLinuxSpecificPaths(std::wstring& aPath)
       
   142 {
       
   143 	 std::wstring::size_type idx = 0;
       
   144      while( (idx = aPath.find(L"\\\\", idx)) != std::wstring::npos)
       
   145      {
       
   146              aPath.replace( idx, 2, L"//" );
       
   147      }
       
   148 
       
   149      idx = 0;
       
   150 
       
   151      while( (idx = aPath.find(L"\\", idx)) != std::wstring::npos)
       
   152      {
       
   153              aPath.replace( idx, 1, L"/" );
       
   154      }
       
   155 }
       
   156 
       
   157 #endif
       
   158 
       
   159 /**
   110 /**
   160 	An instance of this class is used to execute all types of SQL statements with or without
   111 	An instance of this class is used to execute all types of SQL statements with or without
   161 	parameters. 
   112 	parameters. 
   162 */
   113 */
   163 	
   114 	
   230 			- immediately after this object has been created
   181 			- immediately after this object has been created
   231 			- after a call to @see CStatement::Reset 
   182 			- after a call to @see CStatement::Reset 
   232 			@param aParameterIndex The index value identifying the parameter; the first parameter 
   183 			@param aParameterIndex The index value identifying the parameter; the first parameter 
   233 			       has an index of 1.
   184 			       has an index of 1.
   234 			@param aParameterStr The 16-bit descriptor whose content is to be assigned to the parameter.
   185 			@param aParameterStr The 16-bit descriptor whose content is to be assigned to the parameter.
   235 			@param aConvertSlash The integer value which is used only under LINUX platform specifies whether
   186 		 */
   236 								 to convert any LINUX specific paths to WINDOWS specific paths in aParameterStr.
   187 		void BindStr(int aParameterIndex, const std::wstring& aParameterStr);
   237 								 This helps in avoiding the wrong interpretation of the DataType strings
       
   238 								 having the syntax (DataType/Format) as PATHs.
       
   239 		 */
       
   240 		#ifdef __TOOLS2_LINUX__
       
   241 		void BindStr(TInt aParameterIndex, const std::wstring &aParameterStr, int aConvertSlash=allowSlashConversion);
       
   242 		#else
       
   243 		void BindStr(TInt aParameterIndex, const std::wstring &aParameterStr);
       
   244 		#endif
       
   245 		
   188 		
   246 		void BindBinary(int aParameterIndex, const std::string &aParameterStr);
   189 		void BindBinary(int aParameterIndex, const std::string &aParameterStr);
   247 
       
   248 		void BindBinary(int aParameterIndex, const std::wstring &aParameterStr);
       
   249 
   190 
   250 		/**
   191 		/**
   251 			Resets this SQL statement object to its initial state and makes it ready to be executed again.
   192 			Resets this SQL statement object to its initial state and makes it ready to be executed again.
   252 			Any SQL statement parameters that had values bound to them, retain their values.
   193 			Any SQL statement parameters that had values bound to them, retain their values.
   253 			If this object processes a parameterised SQL statement, then the parameter values 
   194 			If this object processes a parameterised SQL statement, then the parameter values