2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FIoSqlStatementBuilder.h
20 * @brief This is the header file for the %SqlStatementBuilder class.
22 * This header file contains the declarations of the %SqlStatementBuilder class.
25 #ifndef _FIO_SQL_STATEMENT_BUILDER_H_
26 #define _FIO_SQL_STATEMENT_BUILDER_H_
28 #include <FOspConfig.h>
30 namespace Tizen { namespace Base
40 namespace Tizen { namespace Io
44 * @class SqlStatementBuilder
45 * @brief This class provides methods for building SQL statement.
49 * @final This class is not intended for extension.
51 * The %SqlStatementBuilder class provides methods for building SQL statement.
53 class _OSP_EXPORT_ SqlStatementBuilder
54 : public Tizen::Base::Object
59 * Creates SQL SELECT statement.
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.
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);
97 * Creates SQL INSERT statement.
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.
115 static Tizen::Base::String CreateInsertStatement(const Tizen::Base::String& table, const Tizen::Base::Collection::IMap& insertMap);
118 * Creates SQL UPDATE statement.
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.
139 static Tizen::Base::String CreateUpdateStatement(const Tizen::Base::String& table, const Tizen::Base::Collection::IMap& updateMap,
140 const Tizen::Base::String* pWhere);
143 * Creates SQL DELETE statement.
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.
162 static Tizen::Base::String CreateDeleteStatement(const Tizen::Base::String& table, const Tizen::Base::String* pWhere);
166 * This default constructor is intentionally declared as private because this class cannot be constructed.
170 SqlStatementBuilder(void);
173 * This destructor is intentionally declared as private because this class cannot be constructed.
177 virtual ~SqlStatementBuilder(void);
180 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
183 * @remarks This constructor is hidden.
185 SqlStatementBuilder(const SqlStatementBuilder& rhs);
188 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
191 * @remarks This operator is hidden.
193 SqlStatementBuilder& operator =(const SqlStatementBuilder& rhs);
195 class _SqlStatementBuilderImpl* __pSqlStatementBuilderImpl;
197 }; // SqlStatementBuilder
201 #endif // _FIO_SQL_STATEMENT_BUILDER_H_