Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OVR_StringHash.h
Go to the documentation of this file.
1 /************************************************************************************
2 
3 PublicHeader: None
4 Filename : OVR_StringHash.h
5 Content : String hash table used when optional case-insensitive
6  lookup is required.
7 Created : September 19, 2012
8 Notes :
9 
10 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
11 
12 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
13 you may not use the Oculus VR Rift SDK except in compliance with the License,
14 which is provided at the time of installation or download, or which
15 otherwise accompanies this software in either electronic or hard copy form.
16 
17 You may obtain a copy of the License at
18 
19 http://www.oculusvr.com/licenses/LICENSE-3.1
20 
21 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
22 distributed under the License is distributed on an "AS IS" BASIS,
23 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 See the License for the specific language governing permissions and
25 limitations under the License.
26 
27 ************************************************************************************/
28 
29 #ifndef OVR_StringHash_h
30 #define OVR_StringHash_h
31 
32 #include "OVR_String.h"
33 #include "OVR_Hash.h"
34 
35 namespace OVR {
36 
37 //-----------------------------------------------------------------------------------
38 // *** StringHash
39 
40 // This is a custom string hash table that supports case-insensitive
41 // searches through special functions such as GetCaseInsensitive, etc.
42 // This class is used for Flash labels, exports and other case-insensitive tables.
43 
44 template<class U, class Allocator = ContainerAllocator<U> >
45 class StringHash : public Hash<String, U, String::NoCaseHashFunctor, Allocator>
46 {
47 public:
48  typedef U ValueType;
51 
52 public:
53 
54  void operator = (const SelfType& src) { BaseType::operator = (src); }
55 
56  bool GetCaseInsensitive(const String& key, U* pvalue) const
57  {
58  String::NoCaseKey ikey(key);
59  return BaseType::GetAlt(ikey, pvalue);
60  }
61  // Pointer-returning get variety.
62  const U* GetCaseInsensitive(const String& key) const
63  {
64  String::NoCaseKey ikey(key);
65  return BaseType::GetAlt(ikey);
66  }
67  U* GetCaseInsensitive(const String& key)
68  {
69  String::NoCaseKey ikey(key);
70  return BaseType::GetAlt(ikey);
71  }
72 
73 
75 
77  {
78  String::NoCaseKey ikey(key);
79  return BaseType::FindAlt(ikey);
80  }
81 
82  // Set just uses a find and assigns value if found. The key is not modified;
83  // this behavior is identical to Flash string variable assignment.
84  void SetCaseInsensitive(const String& key, const U& value)
85  {
87  if (it != BaseType::End())
88  {
89  it->Second = value;
90  }
91  else
92  {
93  BaseType::Add(key, value);
94  }
95  }
96 };
97 
98 } // OVR
99 
100 #endif
void Add(const String &key, const U &value)
Definition: OVR_Hash.h:1156
const U * GetCaseInsensitive(const String &key) const
BaseType::Iterator base_iterator
void operator=(const SelfType &src)
void SetCaseInsensitive(const String &key, const U &value)
bool GetCaseInsensitive(const String &key, U *pvalue) const
StringHash< U, Allocator > SelfType
Hash< String, U, String::NoCaseHashFunctor, Allocator > BaseType
U * GetCaseInsensitive(const String &key)
base_iterator FindCaseInsensitive(const String &key)