Merge "Revert "Fix N_SE-46938 for tz list."" into devel_3.0_main
[platform/framework/native/appfw.git] / src / io / inc / FIo_DbContextImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 //
17 // This method is for internal use only. The Tizen platform team is not
18 // responsible for any behavioral correctness, consistency, and
19 // security-related issues that might arise after using this method.
20 //
21 // @file        FIo_DbContextImpl.h
22 // @brief       This is the header file for the %_DbContextImpl class.
23 //
24 // This header file contains declarations of the %_DbContextImpl class.
25
26 #ifndef _FIO_INTERNAL_DBCONTEXTIMPL_H_
27 #define _FIO_INTERNAL_DBCONTEXTIMPL_H_
28
29 #include <FOspConfig.h>
30 #include <FBaseString.h>
31
32 namespace Tizen { namespace Io
33 {
34
35 class _IDbUserFunctionListener;
36 class _IDbUserAggregateListener;
37 class _IDbUserCollationListener;
38
39 // This method is for internal use only. The Tizen platform team is not
40 // responsible for any behavioral correctness, consistency, and
41 // security-related issues that might arise after using this method.
42 //
43 // @enum                _DbUserListenerErrorCode
44 // Defines Database error codes used by user listeners.
45 //
46 // @since 2.1
47 // @see         Tizen::Io::_IDbUserFunctionListener, Tizen::Io::_IDbUserAggregateListener, and
48 //                      Tizen::Io::_IDbUserCollationListener.
49
50 enum _DbUserListenerErrorCode
51 {
52         DB_USER_LISTENER_OK = 0,    /** Successful result */
53         DB_USER_LISTENER_ERROR,     /** SQL error */
54         DB_USER_LISTENER_ABORT,     /** Callback routine requested an abort */
55         DB_USER_LISTENER_NOMEM,     /** Insufficient memory */
56 };
57
58 // This method is for internal use only. The Tizen platform team is not
59 // responsible for any behavioral correctness, consistency, and
60 // security-related issues that might arise after using this method.
61 //
62 // @class       _DbContext
63 // @brief       This class provides methods for managing the user defined SQL function or aggregate.
64 // @since 2.1
65 class _OSP_EXPORT_ _DbContextImpl
66         : public Tizen::Base::Object
67 {
68
69 public:
70         // This method is for internal use only. The Tizen platform team is not
71         // responsible for any behavioral correctness, consistency, and
72         // security-related issues that might arise after using this method.
73         //
74         // This is the default destructor for this class.
75         //
76         // @since 2.1
77         virtual ~_DbContextImpl(void);
78
79         // This method is for internal use only. The Tizen platform team is not
80         // responsible for any behavioral correctness, consistency, and
81         // security-related issues that might arise after using this method.
82         //
83         // Gets the String value from a parameter of the user defined SQL function or aggregate.
84         //
85         // @since 2.1
86         // @return              An error code
87         // @param[in]   argumentIndex           The index of the arguments of the user defined SQL function or aggregate. @n
88         //                                   It starts from @c 0.
89         // @param[in]    value               The String value obtained from the argument pointed by the specified @c argumentIndex.
90         // @exception   E_SUCCESS                       The method was successful. @n
91         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
92         // @exception   E_INVALID_ARG           If the specified @c argumentIndex is negative. @n
93         // @exception   E_DATABASE                      Failed to retrieve the String value.
94         //
95         result GetStringAt(int argumentIndex, Tizen::Base::String& value);
96
97         // This method is for internal use only. The Tizen platform team is not
98         // responsible for any behavioral correctness, consistency, and
99         // security-related issues that might arise after using this method.
100         //
101         // Sets the String value as result to be passsed to database engine.
102         //
103         // @since 2.1
104         // @return              An error code
105         // @param[in]   value                       String value to be set @n
106         // @exception   E_SUCCESS                       The method was successful. @n
107         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
108         // @exception   E_DATABASE                      Failed to set the result.
109         //
110         result SetResultString(const Tizen::Base::String& value);
111
112         // This method is for internal use only. The Tizen platform team is not
113         // responsible for any behavioral correctness, consistency, and
114         // security-related issues that might arise after using this method.
115         //
116         // Sets the integer value as result to be passsed to database engine.
117         //
118         // @since 2.1
119         // @return              An error code.
120         // @param[in]   result                      Interger value to be set. @n
121         // @exception   E_SUCCESS                       The method was successful. @n
122         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
123         // @exception   E_DATABASE                      Failed to set the result. @n
124         //
125         result SetResultInt(int value);
126
127         // This method is for internal use only. The Tizen platform team is not
128         // responsible for any behavioral correctness, consistency, and
129         // security-related issues that might arise after using this method.
130         //
131         // Sets the double value as result to be passsed to database engine.
132         //
133         // @since 2.1
134         // @return              An error code.
135         // @param[in]   result                      double value to be set. @n
136         // @exception   E_SUCCESS                       The method was successful. @n
137         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
138         // @exception   E_DATABASE                      Failed to set the result. @n
139         //
140         result SetResultDouble(double value);
141
142         // This method is for internal use only. The Tizen platform team is not
143         // responsible for any behavioral correctness, consistency, and
144         // security-related issues that might arise after using this method.
145         //
146         // Sets the result error code to be passsed to database engine.
147         //
148         // @since 2.1
149         // @return              An error code.
150         // @param[in]   errorCode                   SQLite error code. @n
151         // @exception   E_SUCCESS                       The method was successful. @n
152         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
153         // @exception   E_DATABASE                      Failed to set the error code. @n
154         //
155         result SetResultErrorCode(_DbUserListenerErrorCode errorCode);
156
157         // This method is for internal use only. The Tizen platform team is not
158         // responsible for any behavioral correctness, consistency, and
159         // security-related issues that might arise after using this method.
160         //
161         // Gets the user data if set any while creating SQL functions or aggregate.
162         //
163         // @since 2.1
164         // @return              user data pointer.
165         // @exception   E_SUCCESS                       The method was successful. @n
166         // @exception   E_INVALID_STATE         This instance has not been properly constructed yet. @n
167         void* GetUserData(void);
168
169         static void DestroyListener(void* pData);
170
171 private:
172         // This method is for internal use only. The Tizen platform team is not
173         // responsible for any behavioral correctness, consistency, and
174         // security-related issues that might arise after using this method.
175         //
176         // This is the default constructor for this class.
177         //
178         // @since 2.1
179         _DbContextImpl(void);
180
181         static int ConvertDbErrorToNativeSqliteError(int errorCode);
182
183         void* __pContext;
184
185         void** __pArgList;
186
187         void* __pUserData;
188
189         _IDbUserFunctionListener* __pUserFunctionListener;
190
191         _IDbUserAggregateListener* __pUserAggregateListener;
192
193         _IDbUserCollationListener* __pUserCollationListener;
194
195         int __argumentCount;
196
197         Tizen::Base::String __functionName;
198
199         Tizen::Base::String __collationName;
200
201         friend class _DatabaseImpl;
202
203 }; // _DbContextImpl
204
205 }} // Tizen::Io
206
207 #endif  //_FIO_INTERNAL_DBCONTEXTIMPL_H_