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