2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FIoSqlStatementBuilder.h
19 * @brief This is the header file for the %SqlStatementBuilder class.
21 * This header file contains the declarations of the %SqlStatementBuilder class.
24 #ifndef _FIO_SQL_STATEMENT_BUILDER_H_
25 #define _FIO_SQL_STATEMENT_BUILDER_H_
27 #include <FOspConfig.h>
29 namespace Tizen { namespace Base
39 namespace Tizen { namespace Io
43 * @class SqlStatementBuilder
44 * @brief This class provides methods for building SQL statement.
48 * @final This class is not intended for extension.
50 * The %SqlStatementBuilder class provides methods for building SQL statement.
52 class _OSP_EXPORT_ SqlStatementBuilder
53 : public Tizen::Base::Object
58 * Creates SQL SELECT statement.
62 * @return A created SQL SELECT statement, @n
63 * else an empty string in case of failure
64 * @param[in] table A table name to query from
65 * @param[in] pColumnList A list of column names to query @n
66 * The type of objects contained in the specified @c pColumnList must be
67 * Tizen::Base::String class.
68 * If it is @c null, all columns are returned in result set.
69 * @param[in] pWhere A filter to select desired rows to query @n
70 * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
71 * column1 = 'stringValue' AND column2 = numericValue.
72 * @param[in] pOrder Sorting order of rows to query @n
73 * It is an SQL 'ORDER BY' clause excluding the 'ORDER BY' itself.
74 * @param[in] pLimit Limitation of the number of rows to query @n
75 * It is the SQL 'LIMIT' clause excluding the 'LIMIT' itself.
76 * @param[in] pGroup A filter to select a column grouping rows to query @n
77 * It is the SQL 'GROUP BY' clause excluding the 'GROUP BY' itself.
78 * @param[in] pHaving A filter for the group @n
79 * It is the SQL 'HAVING' clause excluding the 'HAVING' itself.
80 * @exception E_SUCCESS The method is successful.
81 * @exception E_INVALID_ARG Either of the following conditions has occurred:
82 * - The specified @c pColumnList is empty.
83 * - The specified @c pOrder is @c null and @c pLimit is not @c null.
84 * - The specified @c pGroup is @c null and @c pHaving is not @c null.
85 * @exception E_SYSTEM A system error has occurred.
86 * @remarks The specific error code can be accessed using the GetLastResult() method.
87 * @remarks If the value specified in the @c pWhere is string, the value must be wrapped in
88 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
89 * For more information on the SQL statement, see SQLite SQL documents.
91 static Tizen::Base::String CreateSelectStatement(const Tizen::Base::String& table, const Tizen::Base::Collection::IList* pColumnList,
92 const Tizen::Base::String* pWhere, const Tizen::Base::String* pOrder = null, const Tizen::Base::String* pLimit = null,
93 const Tizen::Base::String* pGroup = null, const Tizen::Base::String* pHaving = null);
96 * Creates SQL INSERT statement.
100 * @return A created SQL INSERT statement, @n
101 * else an empty string in case of failure @n
102 * @param[in] table A table name to insert
103 * @param[in] insertMap Column-value pairs to insert @n
104 * The type of objects contained in the specified @c insertMap must be
105 * Tizen::Base::String class.
106 * @exception E_SUCCESS The method is successful.
107 * @exception E_INVALID_ARG The specified @c insertMap is empty.
108 * @exception E_SYSTEM A system error has occurred.
109 * @remarks The specific error code can be accessed using the GetLastResult() method.
110 * @remarks If the value specified in the @c insertMap is string, the value must be wrapped in
111 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
112 * For more information on the SQL statement, see SQLite SQL documents.
114 static Tizen::Base::String CreateInsertStatement(const Tizen::Base::String& table, const Tizen::Base::Collection::IMap& insertMap);
117 * Creates SQL UPDATE statement.
121 * @return A created SQL UPDATE statement, @n
122 * else an empty string in case of failure @n
123 * @param[in] table A table name to update
124 * @param[in] updateMap Column-value pairs to update @n
125 * The type of objects contained in the specified @c updateMap must be
126 * Tizen::Base::String class.
127 * @param[in] pWhere A filter to select desired rows to update @n
128 * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
129 * column1 = 'stringValue' AND column2 = numericValue.
130 * @exception E_SUCCESS The method is successful.
131 * @exception E_INVALID_ARG The specified @c updateMap is empty.
132 * @exception E_SYSTEM A system error has occurred.
133 * @remarks The specific error code can be accessed using the GetLastResult() method.
134 * @remarks If the value specified in the @c pWhere or @c updateMap is string, the value must be wrapped in
135 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
136 * For more information on the SQL statement, see SQLITE SQL documents.
138 static Tizen::Base::String CreateUpdateStatement(const Tizen::Base::String& table, const Tizen::Base::Collection::IMap& updateMap,
139 const Tizen::Base::String* pWhere);
142 * Creates SQL DELETE statement.
146 * @return A created SQL DELETE statement, @n
147 * else an empty string in case of failure @n
148 * @param[in] table A table name to query
149 * @param[in] pWhere A filter to select desired rows to delete @n
150 * It is an SQL 'WHERE' clause excluding the 'WHERE' itself such as
151 * column1 = 'stringValue' AND column2 = numericValue.
152 * If it is @c null, all rows are deleted.
153 * @exception E_SUCCESS The method is successful.
154 * @exception E_INVALID_ARG A specified parameter is invalid.
155 * @exception E_SYSTEM A system error has occurred.
156 * @remarks The specific error code can be accessed using the GetLastResult() method.
157 * @remarks If the value specified in the @c pWhere is string, the value must be wrapped in
158 * single quotes. Otherwise it is not needed to wrap the numeric value in single quotes.
159 * For more information on the SQL statement, see SQLITE SQL documents.
161 static Tizen::Base::String CreateDeleteStatement(const Tizen::Base::String& table, const Tizen::Base::String* pWhere);
165 * This default constructor is intentionally declared as private because this class cannot be constructed.
169 SqlStatementBuilder(void);
172 * This destructor is intentionally declared as private because this class cannot be constructed.
176 virtual ~SqlStatementBuilder(void);
179 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
182 * @remarks This constructor is hidden.
184 SqlStatementBuilder(const SqlStatementBuilder& rhs);
187 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
190 * @remarks This operator is hidden.
192 SqlStatementBuilder& operator =(const SqlStatementBuilder& rhs);
194 class _SqlStatementBuilderImpl* __pSqlStatementBuilderImpl;
196 }; // SqlStatementBuilder
200 #endif // _FIO_SQL_STATEMENT_BUILDER_H_