Update doxygen
[platform/framework/native/appfw.git] / inc / FIoSqlStatementBuilder.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FIoSqlStatementBuilder.h
20  * @brief       This is the header file for the %SqlStatementBuilder class.
21  *
22  * This header file contains the declarations of the %SqlStatementBuilder class.
23  */
24
25 #ifndef _FIO_SQL_STATEMENT_BUILDER_H_
26 #define _FIO_SQL_STATEMENT_BUILDER_H_
27
28 #include <FOspConfig.h>
29
30 namespace Tizen { namespace Base
31 {
32 class String;
33 namespace Collection
34 {
35 class IList;
36 class IMap;
37 }
38 }}
39
40 namespace Tizen { namespace Io
41 {
42
43 /**
44  * @class       SqlStatementBuilder
45  * @brief       This class provides methods for building SQL statement.
46  *
47  * @since       2.0
48  *
49  * @final       This class is not intended for extension.
50  *
51  * The %SqlStatementBuilder class provides methods for building SQL statement.
52  */
53 class _OSP_EXPORT_ SqlStatementBuilder
54         : public Tizen::Base::Object
55 {
56
57 public:
58         /**
59         * Creates SQL SELECT statement.
60         *
61         * @since                2.0
62         *
63         * @return               A created SQL SELECT statement, @n
64         *                               else an empty string in case of failure
65         * @param[in]    table                           A table name to query from
66         * @param[in]    pColumnList                     A list of column names to query @n
67         *                                                                       The type of objects contained in the specified @c pColumnList must be
68         *                                                                       Tizen::Base::String class.
69         *                                                                       If it is @c null, all columns are returned in result set.
70         * @param[in]    pWhere                          A filter to select desired rows to query @n
71         *                                                                       It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
72         *                                                                       column1 = 'stringValue' AND column2 = numericValue.
73         * @param[in]    pOrder                          Sorting order of rows to query @n
74         *                                                                       It is an SQL 'ORDER BY' clause excluding the 'ORDER BY' itself.
75         * @param[in]    pLimit                          Limitation of the number of rows to query @n
76         *                                                                       It is the SQL 'LIMIT' clause excluding the 'LIMIT' itself.
77         * @param[in]    pGroup                          A filter to select a column grouping rows to query @n
78         *                                                                       It is the SQL 'GROUP BY' clause excluding the 'GROUP BY' itself.
79         * @param[in]    pHaving                         A filter for the group @n
80         *                                                                       It is the SQL 'HAVING' clause excluding the 'HAVING' itself.
81         * @exception    E_SUCCESS                       The method is successful.
82         * @exception    E_INVALID_ARG           Either of the following conditions has occurred:
83         *                                                                       - The specified @c pColumnList is empty.
84         *                                                                       - The specified @c pOrder is @c null and @c pLimit is not @c null.
85         *                                                                       - The specified @c pGroup is @c null and @c pHaving is not @c null.
86         * @exception    E_SYSTEM                        A system error has occurred.
87         * @remarks      The specific error code can be accessed using the GetLastResult() method.
88         * @remarks              If the value specified in the @c pWhere is string, the value must be wrapped in
89         *                               single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
90         *                               For more information on the SQL statement, see SQLite SQL documents.
91         */
92         static Tizen::Base::String CreateSelectStatement(const Tizen::Base::String& table, const Tizen::Base::Collection::IList* pColumnList,
93                         const Tizen::Base::String* pWhere, const Tizen::Base::String* pOrder = null, const Tizen::Base::String* pLimit = null,
94                         const Tizen::Base::String* pGroup = null, const Tizen::Base::String* pHaving = null);
95
96         /**
97         * Creates SQL INSERT statement.
98         *
99         * @since                2.0
100         *
101         * @return               A created SQL INSERT statement, @n
102         *                               else an empty string in case of failure @n
103         * @param[in]    table                           A table name to insert
104         * @param[in]    insertMap                       Column-value pairs to insert @n
105         *                                                                       The type of objects contained in the specified @c insertMap must be
106         *                                                                       Tizen::Base::String class.
107         * @exception    E_SUCCESS                       The method is successful.
108         * @exception    E_INVALID_ARG           The specified @c insertMap is empty.
109         * @exception    E_SYSTEM                        A system error has occurred.
110         * @remarks      The specific error code can be accessed using the GetLastResult() method.
111         * @remarks              If the value specified in the @c insertMap is string, the value must be wrapped in
112         *                               single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
113         *                               For more information on the SQL statement, see SQLite SQL documents.
114         */
115         static Tizen::Base::String CreateInsertStatement(const Tizen::Base::String& table, const Tizen::Base::Collection::IMap& insertMap);
116
117         /**
118         * Creates SQL UPDATE statement.
119         *
120         * @since                2.0
121         *
122         * @return               A created SQL UPDATE statement, @n
123         *                               else an empty string in case of failure @n
124         * @param[in]    table                           A table name to update
125         * @param[in]    updateMap                       Column-value pairs to update @n
126         *                                                                       The type of objects contained in the specified @c updateMap must be
127         *                                                                       Tizen::Base::String class.
128         * @param[in]    pWhere                          A filter to select desired rows to update @n
129         *                                                                       It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
130         *                                                                       column1 = 'stringValue' AND column2 = numericValue.
131         * @exception    E_SUCCESS                       The method is successful.
132         * @exception    E_INVALID_ARG           The specified @c updateMap is empty.
133         * @exception    E_SYSTEM                        A system error has occurred.
134         * @remarks      The specific error code can be accessed using the GetLastResult() method.
135         * @remarks              If the value specified in the @c pWhere or @c updateMap is string, the value must be wrapped in
136         *                               single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
137         *                               For more information on the SQL statement, see SQLITE SQL documents.
138         */
139         static Tizen::Base::String CreateUpdateStatement(const Tizen::Base::String& table, const Tizen::Base::Collection::IMap& updateMap,
140                         const Tizen::Base::String* pWhere);
141
142         /**
143         * Creates SQL DELETE statement.
144         *
145         * @since                2.0
146         *
147         * @return               A created SQL DELETE statement, @n
148         *                               else an empty string in case of failure @n
149         * @param[in]    table                           A table name to query
150         * @param[in]    pWhere                          A filter to select desired rows to delete @n
151         *                                                                       It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
152         *                                                                       column1 = 'stringValue' AND column2 = numericValue.
153         *                                                                       If it is @c null, all rows are deleted.
154         * @exception    E_SUCCESS                       The method is successful.
155         * @exception    E_INVALID_ARG           A specified parameter is invalid.
156         * @exception    E_SYSTEM                        A system error has occurred.
157         * @remarks      The specific error code can be accessed using the GetLastResult() method.
158         * @remarks              If the value specified in the @c pWhere is string, the value must be wrapped in
159         *                               single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
160         *                               For more information on the SQL statement, see SQLITE SQL documents.
161         */
162         static Tizen::Base::String CreateDeleteStatement(const Tizen::Base::String& table, const Tizen::Base::String* pWhere);
163
164 private:
165         /**
166         * This default constructor is intentionally declared as private because this class cannot be constructed.
167         *
168         * @since        2.0
169         */
170         SqlStatementBuilder(void);
171
172         /**
173         * This destructor is intentionally declared as private because this class cannot be constructed.
174         *
175         * @since        2.0
176         */
177         virtual ~SqlStatementBuilder(void);
178
179         /**
180         * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
181         *
182         * @since        2.0
183         * @remarks      This constructor is hidden.
184         */
185         SqlStatementBuilder(const SqlStatementBuilder& rhs);
186
187         /**
188         * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
189         *
190         * @since        2.0
191         * @remarks      This operator is hidden.
192         */
193         SqlStatementBuilder& operator =(const SqlStatementBuilder& rhs);
194
195         class _SqlStatementBuilderImpl* __pSqlStatementBuilderImpl;
196
197 }; // SqlStatementBuilder
198
199 }} // Tizen::Io
200
201 #endif // _FIO_SQL_STATEMENT_BUILDER_H_
202