Update wrt-commons_0.2.53
[framework/web/wrt-commons.git] / modules / db / src / orm.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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  * @file        orm.cpp
18  * @author      Bartosz Janiak (b.janiak@samsung.com)
19  * @version     1.0
20  * @brief       Static definitions and function template specialziations of DPL-ORM.
21  */
22
23 #include <dpl/db/orm.h>
24
25 namespace DPL {
26 namespace DB {
27 namespace ORM {
28
29 namespace RelationTypes {
30 const char Equal[] = "=";
31 const char LessThan[] = "<";
32 const char And[] = "AND";
33 const char Or[] = "OR";
34 const char Is[] = "IS";
35 const char In[] = "IN";
36 }
37
38 template<>
39 int GetColumnFromCommand<int>(ColumnIndex columnIndex,
40         DataCommand *command)
41 {
42     return command->GetColumnInteger(columnIndex);
43 }
44
45 template<>
46 DPL::String GetColumnFromCommand<DPL::String>(ColumnIndex columnIndex,
47         DataCommand *command)
48 {
49     return DPL::FromUTF8String(command->GetColumnString(columnIndex));
50 }
51
52 template<>
53 OptionalInteger GetColumnFromCommand<OptionalInteger>(ColumnIndex columnIndex,
54         DataCommand *command)
55 {
56     return command->GetColumnOptionalInteger(columnIndex);
57 }
58
59 template<>
60 OptionalString GetColumnFromCommand<OptionalString>(ColumnIndex columnIndex,
61         DataCommand *command)
62 {
63     return command->GetColumnOptionalString(columnIndex);
64 }
65
66 template<>
67 double GetColumnFromCommand<double>(ColumnIndex columnIndex,
68         DataCommand *command)
69 {
70     return command->GetColumnDouble(columnIndex);
71 }
72
73 void DataCommandUtils::BindArgument(DataCommand *command,
74         ArgumentIndex index,
75         int argument)
76 {
77     command->BindInteger(index, argument);
78 }
79
80 void DataCommandUtils::BindArgument(DataCommand *command,
81         ArgumentIndex index,
82         const OptionalInteger& argument)
83 {
84     command->BindInteger(index, argument);
85 }
86
87 void DataCommandUtils::BindArgument(DataCommand *command,
88         ArgumentIndex index,
89         const DPL::String& argument)
90 {
91     command->BindString(index, argument);
92 }
93
94 void DataCommandUtils::BindArgument(DataCommand *command,
95         ArgumentIndex index,
96         const OptionalString& argument)
97 {
98     command->BindString(index, argument);
99 }
100
101 }
102 }
103 }