wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / DataControl / RowData.h
1 //
2 // Tizen Web Device API
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 #ifndef TIZENAPIS_API_ROWDATA_H_
20 #define TIZENAPIS_API_ROWDATA_H_
21
22 #include <dpl/shared_ptr.h>
23 #include <map>
24 #include <vector>
25 #include <Commons/Exception.h>
26 #include <Logger.h>
27
28 namespace DeviceAPI {
29 namespace DataControl {
30
31
32 class RowData
33 {
34 public:
35         std::map<std::string, std::string> m_Data;
36
37         RowData() { ThrowMsg(WrtDeviceApis::Commons::ConversionException, "empty constructor not allowed");     }
38
39         RowData(std::vector<std::string>& keys, std::vector<std::string>& values) 
40         { 
41                 LoggerD("entered"); 
42
43                 if (keys.size() == 0)
44                 {
45                         ThrowMsg(WrtDeviceApis::Commons::ConversionException, "size 0 attribute");
46                 }
47                         
48                 if (keys.size() != values.size())
49                 {
50                         ThrowMsg(WrtDeviceApis::Commons::ConversionException, "columns & values size mismatch");
51                 }
52
53                 for (size_t index = 0; index < keys.size(); index++)
54                 {
55                         m_Data[keys[index]] = values[index];
56                 }
57         }
58
59         ~RowData() { }
60
61 };
62
63 typedef DPL::SharedPtr<RowData> RowDataPtr;
64
65 }
66 }
67
68 #endif