oculus1
diff libovr/Src/Kernel/OVR_StringHash.h @ 1:e2f9e4603129
added LibOVR and started a simple vr wrapper.
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 14 Sep 2013 16:14:59 +0300 |
parents | |
children | b069a5c27388 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libovr/Src/Kernel/OVR_StringHash.h Sat Sep 14 16:14:59 2013 +0300 1.3 @@ -0,0 +1,1 @@ 1.4 +/************************************************************************************ 1.5 1.6 PublicHeader: None 1.7 Filename : OVR_StringHash.h 1.8 Content : String hash table used when optional case-insensitive 1.9 lookup is required. 1.10 Created : September 19, 2012 1.11 Notes : 1.12 1.13 Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved. 1.14 1.15 Use of this software is subject to the terms of the Oculus license 1.16 agreement provided at the time of installation or download, or which 1.17 otherwise accompanies this software in either electronic or hard copy form. 1.18 1.19 ************************************************************************************/ 1.20 1.21 #ifndef OVR_StringHash_h 1.22 #define OVR_StringHash_h 1.23 1.24 #include "OVR_String.h" 1.25 #include "OVR_Hash.h" 1.26 1.27 namespace OVR { 1.28 1.29 //----------------------------------------------------------------------------------- 1.30 // *** StringHash 1.31 1.32 // This is a custom string hash table that supports case-insensitive 1.33 // searches through special functions such as GetCaseInsensitive, etc. 1.34 // This class is used for Flash labels, exports and other case-insensitive tables. 1.35 1.36 template<class U, class Allocator = ContainerAllocator<U> > 1.37 class StringHash : public Hash<String, U, String::NoCaseHashFunctor, Allocator> 1.38 { 1.39 public: 1.40 typedef U ValueType; 1.41 typedef StringHash<U, Allocator> SelfType; 1.42 typedef Hash<String, U, String::NoCaseHashFunctor, Allocator> BaseType; 1.43 1.44 public: 1.45 1.46 void operator = (const SelfType& src) { BaseType::operator = (src); } 1.47 1.48 bool GetCaseInsensitive(const String& key, U* pvalue) const 1.49 { 1.50 String::NoCaseKey ikey(key); 1.51 return BaseType::GetAlt(ikey, pvalue); 1.52 } 1.53 // Pointer-returning get variety. 1.54 const U* GetCaseInsensitive(const String& key) const 1.55 { 1.56 String::NoCaseKey ikey(key); 1.57 return BaseType::GetAlt(ikey); 1.58 } 1.59 U* GetCaseInsensitive(const String& key) 1.60 { 1.61 String::NoCaseKey ikey(key); 1.62 return BaseType::GetAlt(ikey); 1.63 } 1.64 1.65 1.66 typedef typename BaseType::Iterator base_iterator; 1.67 1.68 base_iterator FindCaseInsensitive(const String& key) 1.69 { 1.70 String::NoCaseKey ikey(key); 1.71 return BaseType::FindAlt(ikey); 1.72 } 1.73 1.74 // Set just uses a find and assigns value if found. The key is not modified; 1.75 // this behavior is identical to Flash string variable assignment. 1.76 void SetCaseInsensitive(const String& key, const U& value) 1.77 { 1.78 base_iterator it = FindCaseInsensitive(key); 1.79 if (it != BaseType::End()) 1.80 { 1.81 it->Second = value; 1.82 } 1.83 else 1.84 { 1.85 BaseType::Add(key, value); 1.86 } 1.87 } 1.88 }; 1.89 1.90 } // OVR 1.91 1.92 #endif 1.93 \ No newline at end of file