Merge "Update DeviceManager [dep:osp-common-service, osp-app-service]" into devel_3...
[platform/framework/native/appfw.git] / src / io / FIoDbStatement.cpp
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 /**
18  * @file        FIoDbStatement.cpp
19  * @brief       This is the implementation file for DbStatement class.
20  */
21
22 #include <new>
23
24 #include <FBaseUtilStringUtil.h>
25 #include <FBaseSysLog.h>
26 #include <FIoDbStatement.h>
27
28 #include <FBase_NativeError.h>
29 #include <FIo_DbStatementImpl.h>
30
31 #define FIO_STMT_VAR_NUM_MAX    999
32
33 using namespace Tizen::Base;
34
35 namespace Tizen { namespace Io
36 {
37
38 DbStatement::DbStatement(void)
39         : __pDbStatementImpl(null)
40 {
41         __pDbStatementImpl = new (std::nothrow) _DbStatementImpl;
42
43         SysTryReturnVoidResult(NID_IO, __pDbStatementImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
44 }
45
46 DbStatement::~DbStatement(void)
47 {
48         delete __pDbStatementImpl;
49 }
50
51 result
52 DbStatement::BindInt(int columnIndex, int value)
53 {
54         SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex <= FIO_STMT_VAR_NUM_MAX, E_INVALID_ARG,
55                            "Wrong column index.");
56
57         return __pDbStatementImpl->BindInt(columnIndex, value);
58 }
59
60 result
61 DbStatement::BindInt64(int columnIndex, long long value)
62 {
63         SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex <= FIO_STMT_VAR_NUM_MAX, E_INVALID_ARG,
64                                    "Wrong column index.");
65
66         return __pDbStatementImpl->BindInt64(columnIndex, value);
67 }
68
69 result
70 DbStatement::BindDouble(int columnIndex, double value)
71 {
72         SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex <= FIO_STMT_VAR_NUM_MAX, E_INVALID_ARG,
73                                    "Wrong column index.");
74
75         return __pDbStatementImpl->BindDouble(columnIndex, value);
76 }
77
78 result
79 DbStatement::BindString(int columnIndex, const String& value)
80 {
81         SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex <= FIO_STMT_VAR_NUM_MAX, E_INVALID_ARG,
82                                    "Wrong column index.");
83
84         return __pDbStatementImpl->BindString(columnIndex, value);
85 }
86
87 result
88 DbStatement::BindBlob(int columnIndex, const ByteBuffer& value)
89 {
90         SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex <= FIO_STMT_VAR_NUM_MAX, E_INVALID_ARG,
91                                    "Wrong column index.");
92
93         return __pDbStatementImpl->BindBlob(columnIndex, value);
94 }
95
96 result
97 DbStatement::BindBlob(int columnIndex, const void* buffer, int size)
98 {
99         SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex <= FIO_STMT_VAR_NUM_MAX, E_INVALID_ARG,
100                                    "Wrong column index.");
101
102         return __pDbStatementImpl->BindBlob(columnIndex, buffer, size);
103 }
104
105 result
106 DbStatement::BindDateTime(int columnIndex, const DateTime& value)
107 {
108         SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex <= FIO_STMT_VAR_NUM_MAX, E_INVALID_ARG,
109                                    "Wrong column index.");
110
111         return __pDbStatementImpl->BindDateTime(columnIndex, value);
112 }
113
114 result
115 DbStatement::BindNull(int columnIndex)
116 {
117         SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex <= FIO_STMT_VAR_NUM_MAX, E_INVALID_ARG,
118                                    "Wrong column index.");
119
120         return __pDbStatementImpl->BindNull(columnIndex);
121 }
122
123 }} // Tizen::Io
124