Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
from-kvstore-ignoring-visitor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Contact: Pawel Kubik (p.kubik@samsung.com)
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License
17  */
18 
25 #ifndef CARGO_SQLITE_FROM_KVSTORE_IGNORING_VISITOR_HPP
26 #define CARGO_SQLITE_FROM_KVSTORE_IGNORING_VISITOR_HPP
27 
29 
30 
31 namespace cargo {
32 
38 class FromKVStoreIgnoringVisitor : public FromKVStoreVisitorBase<FromKVStoreIgnoringVisitor> {
39 public:
40  FromKVStoreIgnoringVisitor(KVStore& store, const std::string& prefix)
42  {
43  }
44 
46  const std::string& prefix)
48  {
49  }
50 
52 
53 protected:
54  template<typename T>
55  void visitImpl(const std::string& name, T& value)
56  {
57  try {
58  getInternal(name, value);
59  } catch (const NoKeyException& e) {
60  } catch (const ContainerSizeException& e) {
61  }
62  }
63 
64 private:
66  const std::string& prefix)
68  {
69  }
70 
71  template<typename T,
72  typename std::enable_if<isUnion<T>::value, int>::type = 0>
73  void getInternal(const std::string& name, T& value)
74  {
75  std::string type;
76  getInternal(key(name, "type"), type);
77  if (type.empty()) {
78  return;
79  }
80 
81  FromKVStoreIgnoringVisitor visitor(*this, name);
82  value.accept(visitor);
83  }
84 
85  template<typename T,
86  typename std::enable_if<!isUnion<T>::value, int>::type = 0>
87  void getInternal(const std::string& name, T& value)
88  {
90  }
91 
92  friend class FromKVStoreVisitorBase;
93 };
94 
95 } // namespace cargo
96 
97 #endif // CARGO_SQLITE_FROM_KVSTORE_IGNORING_VISITOR_HPP
FromKVStoreIgnoringVisitor(const FromKVStoreVisitorBase< FromKVStoreIgnoringVisitor > &visitor, const std::string &prefix)
Definition: from-kvstore-ignoring-visitor.hpp:45
FromKVStoreIgnoringVisitor(KVStore &store, const std::string &prefix)
Definition: from-kvstore-ignoring-visitor.hpp:40
Definition: kvstore.hpp:43
FromKVStoreIgnoringVisitor(const FromKVStoreIgnoringVisitor &visitor, const std::string &prefix)
Definition: from-kvstore-ignoring-visitor.hpp:65
void getInternal(const std::string &name, T &value)
Definition: from-kvstore-ignoring-visitor.hpp:73
No such key error.
Definition: exception.hpp:43
Container size does not match.
Definition: exception.hpp:59
void visitImpl(const std::string &name, T &value)
Definition: from-kvstore-ignoring-visitor.hpp:55
std::string key(const Arg1 &a1, const Args &...args)
Concatenates all parameters into one std::string.
Definition: kvstore-visitor-utils.hpp:60
Base of visitors for loading from KVStore.
KVStore & mStore
Definition: from-kvstore-visitor-base.hpp:62
A variant of KVStoreVisitor that ignore non-existing fields.
Definition: from-kvstore-ignoring-visitor.hpp:38
Base class for KVStore visitors.
Definition: from-kvstore-visitor-base.hpp:51
void visitImpl(const std::string &name, T &value)
Definition: from-kvstore-visitor-base.hpp:66
FromKVStoreIgnoringVisitor & operator=(const FromKVStoreIgnoringVisitor &)=delete