|
1 // sqlsrv.h |
|
2 // |
|
3 // Copyright (c) 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 #ifndef __SQLSRV_H__ |
|
13 #define __SQLSRV_H__ |
|
14 // Include Files |
|
15 |
|
16 #include <fshell/common.mmh> |
|
17 |
|
18 #include <fshell/ioutils.h> |
|
19 #include <SqlDb.h> |
|
20 |
|
21 //class CSqlShared; |
|
22 //class CLineEditor; |
|
23 |
|
24 using namespace IoUtils; |
|
25 |
|
26 class CCmdSqlSrv : public CServerBase |
|
27 { |
|
28 public: |
|
29 static const TDesC* ColumnTypeToString(TSqlColumnType aType); |
|
30 static void StripWrapDoubleQuote(HBufC& aText); |
|
31 |
|
32 void PrintTime(const TTime& aTime, TBool aNewline); |
|
33 static CCommandBase* NewLC(); |
|
34 static CCmdSqlSrv* GetServer(); |
|
35 ~CCmdSqlSrv(); |
|
36 |
|
37 TInt NextCommandId(); |
|
38 |
|
39 //SQL commands |
|
40 void SqlCreateL(TDesC& aFilename, CServerCommandBase* aCommand); |
|
41 void SqlOpenL(TDesC& aFilename, CServerCommandBase* aCommand); |
|
42 void SqlExecL(TDesC& aStatement, CServerCommandBase* aCommand); |
|
43 void SqlStateL(TDesC& aStatement, RPointerArray<HBufC> &aOptParamFile, CServerCommandBase* aCommand, |
|
44 TDesC* aTempFileTemplate = NULL); |
|
45 void SqlClose(CServerCommandBase* aCommand); |
|
46 void SqlAttachL(TDesC& aFilename, TDesC& aDateBaseName, CServerCommandBase* aCommand); |
|
47 void SqlDetachL(TDesC& aDateBaseName, CServerCommandBase* aCommand); |
|
48 |
|
49 #ifdef SQL_COMPACT |
|
50 void SqlCompactL(TDesC* aDateBaseName, CServerCommandBase* aCommand); |
|
51 #endif |
|
52 /////////////////////////////////// |
|
53 void ReportResult(const TServerCommandId& aId, const TDesC& aName, TRefByValue<const TDesC> aFmt, ...); |
|
54 |
|
55 ////////////////////////////////// |
|
56 void ParseResultL(RSqlStatement& aState, CServerCommandBase* aCommand, TDesC* aTempFileTemplate); |
|
57 |
|
58 private: |
|
59 CCmdSqlSrv(); |
|
60 void ConstructL(); |
|
61 void MakeTempFilename(TDes& aTmpFile, TDesC& aTemplate); |
|
62 |
|
63 private: |
|
64 enum TPrintPostfix |
|
65 { |
|
66 ENone, |
|
67 ENewLine |
|
68 }; |
|
69 |
|
70 void DoPrintf(TRefByValue<const TDesC> aFmt, ...); |
|
71 void DoPrintf(TRefByValue<const TDesC8> aFmt, ...); |
|
72 void DoPrintList(TRefByValue<const TDesC> aFmt, VA_LIST& aList, TPrintPostfix aPostfix = ENone); |
|
73 void DoPrintList(TRefByValue<const TDesC8> aFmt, VA_LIST& aList, TPrintPostfix aPostfix = ENone); |
|
74 void DoPrint(const TDesC& aDes, TPrintPostfix aPostfix = ENone); |
|
75 |
|
76 private: // From CCommandBase. |
|
77 virtual const TDesC& Name() const; |
|
78 virtual const TDesC& Description() const; |
|
79 |
|
80 virtual void ArgumentsL(RCommandArgumentList& aArguments); |
|
81 virtual void OptionsL(RCommandOptionList& aOptions); |
|
82 private: // From CServerBase. |
|
83 virtual void InitializeL(); |
|
84 virtual void Report(const TServerCommandId& aId, const TDesC& aDes); |
|
85 virtual void Report(const TServerCommandId& aId, const TDesC8& aDes); |
|
86 virtual void ReportWarning(const TServerCommandId& aId, const TDesC& aDes); |
|
87 virtual void ReportError(const TServerCommandId& aId, TInt aError, const TDesC& aDes); |
|
88 |
|
89 private: |
|
90 RSqlDatabase iSqlDb; |
|
91 TBool iDatabaseOpened; //when database is created or opened, set this to ETrue |
|
92 |
|
93 TBool iExit; |
|
94 TBuf<512> iLine; |
|
95 TInt iExitReason; |
|
96 |
|
97 TBool iLineRead; |
|
98 |
|
99 TInt iNextCommandId; |
|
100 TInt iTmpFileNo; |
|
101 |
|
102 private: |
|
103 //use this static variable to make sure only one instance exists |
|
104 static CCmdSqlSrv* iOnlyInstance; |
|
105 }; |
|
106 |
|
107 |
|
108 #endif //__SQLSRV_H__ |