Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_mobile / modules / API / LocalStorage / ILocalStorage.h
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  * @author      Grzegorz Krawczyk (g.krawczyk@samsung.com)
18  * @author      Andrzej Surdej (a.surdej@samsung.com)
19  * @version     0.1
20  * @brief       Local storage interface file
21  */
22
23 #ifndef WRTDEVICEAPIS_LOCALSTORAGE_LOCAL_STORAGE_INTERFACE_H_
24 #define WRTDEVICEAPIS_LOCALSTORAGE_LOCAL_STORAGE_INTERFACE_H_
25
26 #include <string>
27 #include <dpl/shared_ptr.h>
28 #include <dpl/optional.h>
29
30 namespace WrtDeviceApis {
31 namespace LocalStorage {
32 namespace Api {
33 class ILocalStorage
34 {
35   public:
36
37     /**
38      * Save pair key/value in local storage
39      * @param key
40      * @param value
41      * @param readOnly - if true, the value will be read only
42      *                  otherwise the value will be modificable
43      */
44     virtual void setItem(const std::string& key,
45                          const std::string& value,
46                          bool readOnly) = 0;
47
48     /**
49      * Remove pair key/value from local storage
50      */
51     virtual void removeItem(const std::string& key) = 0;
52
53     /**
54      * Get value for key
55      *
56      */
57     virtual DPL::Optional<std::string> getValue(
58         const std::string& key) const = 0;
59
60     /**
61      * Clears the local storage
62      * @param removeReadOnly - true -remove all elements
63      *                          false - ommit items which have read only flag
64      * set
65      */
66     virtual void clear(bool removeReadOnly) = 0;
67
68     /**
69      * Get number of elements in local storage
70      * @param removeReadOnly - true -remove all elements
71      *                          false - ommit items which have read only flag
72      * set
73      */
74     virtual size_t getStorageSize() const = 0;
75
76     /**
77      * Get key name for index
78      */
79     virtual std::string getKeyByIndex(size_t index) const = 0;
80
81     /**
82      * virtual destructor
83      */
84     virtual ~ILocalStorage()
85     {}
86 };
87
88 typedef DPL::SharedPtr<ILocalStorage> ILocalStoragePtr;
89 } // Api
90 } // LocalStorage
91 } // WrtDeviceApis
92
93 #endif // WRTDEVICEAPIS_LOCALSTORAGE_LOACA_STORAGE_INTERFACE_H_