Merge "Remove fallback functions for timezone and locales." into tizen_2.2
[platform/framework/native/appfw.git] / src / app / inc / FApp_TemplateUtil.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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 /**
18  * @file         FApp_TemplateUtil.h
19  * @brief       This is the header file for the internap Tizen::App utilities.
20  */
21
22 #ifndef _FAPP_INTERNAL_TEMPLATE_UTIL_H_
23 #define _FAPP_INTERNAL_TEMPLATE_UTIL_H_
24
25 #include <FBaseString.h>
26 #include <FBaseColICollectionT.h>
27 #include <FBaseColIEnumeratorT.h>
28
29 namespace Tizen { namespace App
30 {
31
32 template<class Type> void
33 _DeleteCollection(Tizen::Base::Collection::ICollectionT<Type*>& col)
34 {
35         Tizen::Base::Collection::IEnumeratorT<Type*>* pEnum = col.GetEnumeratorN();
36
37         if (pEnum)
38         {
39                 while (pEnum->MoveNext() == E_SUCCESS)
40                 {
41                         Type* pElem = null;
42                         pEnum->GetCurrent(pElem);
43
44                         delete pElem;
45                 }
46
47                 delete pEnum;
48         }
49 }
50
51 template<class KeyType, class ValueType> void
52 _DeleteCollectionMapValue(Tizen::Base::Collection::IMapT<KeyType, ValueType*>& col)
53 {
54         Tizen::Base::Collection::IMapEnumeratorT<KeyType, ValueType*>* pEnum = col.GetMapEnumeratorN();
55
56         if (pEnum)
57         {
58                 while (pEnum->MoveNext() == E_SUCCESS)
59                 {
60                         ValueType* pValue = null;
61                         pEnum->GetValue(pValue);
62
63                         delete pValue;
64                 }
65
66                 delete pEnum;
67         }
68 }
69
70 template<class KeyType, class ValueType> void
71 _DeleteCollectionMapValue(Tizen::Base::Collection::IMultiMapT<KeyType, ValueType*>& col)
72 {
73         Tizen::Base::Collection::IMapEnumeratorT<KeyType, ValueType*>* pEnum = col.GetMapEnumeratorN();
74
75         if (pEnum)
76         {
77                 while (pEnum->MoveNext() == E_SUCCESS)
78                 {
79                         ValueType* pValue = null;
80                         pEnum->GetValue(pValue);
81
82                         delete pValue;
83                 }
84
85                 delete pEnum;
86         }
87 }
88
89 } } // Tizen::App
90
91 namespace Tizen { namespace Base
92 {
93
94 namespace Collection
95 {
96
97 template <>
98 class __HashMapDefaultProviderT<String>
99 : public IHashCodeProviderT<String>
100 , public Object
101 {
102         public:
103                 __HashMapDefaultProviderT(void) {}
104
105                 virtual ~__HashMapDefaultProviderT(void) {}
106
107                 virtual int GetHashCode(const String& obj) const
108                 {
109                         return obj.GetHashCode();
110                 }
111 };
112
113 template<>
114 class __MultiHashMapDefaultProviderT<String>
115 : public IHashCodeProviderT<String>
116 , public Object
117 {
118         public:
119                 __MultiHashMapDefaultProviderT(void) {}
120
121                 virtual ~__MultiHashMapDefaultProviderT(void) {}
122
123                 virtual int GetHashCode(const String& obj) const
124                 {
125                         return obj.GetHashCode();
126                 }
127 };
128
129
130 } // Collection
131
132 }} // Tizen::Base
133
134 #endif //_FAPP_INTERNAL_TEMPLATE_UTIL_H_
135