tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*!****************************************************************************
 
 @file         PVRTStringHash.h
 @copyright    Copyright (c) Imagination Technologies Limited.
 @brief        Inherits from PVRTString to include PVRTHash functionality for
               quick string compares.
 
******************************************************************************/
#ifndef PVRTSTRINGHASH_H
#define PVRTSTRINGHASH_H
 
#include "PVRTString.h"
#include "PVRTHash.h"
 
/*!***********************************************************************
 @class        CPVRTStringHash
 @brief        Inherits from PVRTString to include PVRTHash functionality for
               quick string compares.
*************************************************************************/
class CPVRTStringHash
{
public:
   /*!***********************************************************************
   @brief              Constructor
   @param[in]            _Ptr    A string
   @param[in]            _Count    Length of _Ptr
   ************************************************************************/
   explicit CPVRTStringHash(const char* _Ptr, size_t _Count = CPVRTString::npos);
 
   /*!***********************************************************************
   @brief              Constructor
   @param[in]            _Right    A string
   ************************************************************************/
   explicit CPVRTStringHash(const CPVRTString& _Right);
 
   /*!***********************************************************************
   @brief              Constructor
   ************************************************************************/
   CPVRTStringHash();
 
   /*!***********************************************************************
   @brief              Appends a string
   @param[in]            _Ptr    A string
   @return             Updated string
   *************************************************************************/
   CPVRTStringHash& append(const char* _Ptr);
 
   /*!***********************************************************************
   @brief              Appends a string
   @param[in]            _Str    A string
   @return             Updated string
   *************************************************************************/
   CPVRTStringHash& append(const CPVRTString& _Str);
 
   /*!***********************************************************************
   @brief              Assigns the string to the string _Ptr
   @param[in]            _Ptr A string
   @return             Updated string
   *************************************************************************/
   CPVRTStringHash& assign(const char* _Ptr);
 
   /*!***********************************************************************
   @brief              Assigns the string to the string _Str
   @param[in]            _Str A string
   @return             Updated string
   *************************************************************************/
   CPVRTStringHash& assign(const CPVRTString& _Str);
 
   /*!***********************************************************************
   @brief          == Operator. This function compares the hash values of
                   the string.
   @param[in]        _Str     A hashed string to compare with
   @return         True if they match
   *************************************************************************/
   bool operator==(const CPVRTStringHash& _Str) const;
 
   /*!***********************************************************************
   @brief          == Operator. This function performs a strcmp()
                   as it's more efficient to strcmp than to hash the string
                   for every comparison.
   @param[in]        _Str     A string to compare with
   @return         True if they match
   *************************************************************************/
   bool operator==(const char* _Str) const;
 
   /*!***********************************************************************
   @brief          == Operator. This function performs a strcmp()
                   as it's more efficient to strcmp than to hash the string
                   for every comparison.
   @param[in]        _Str     A string to compare with
   @return         True if they match
   *************************************************************************/
   bool operator==(const CPVRTString& _Str) const;
 
   /*!***********************************************************************
   @brief          == Operator. This function compares the hash values of
                   the string.
   @param[in]        Hash     A Hash to compare with
   @return         True if they match
   *************************************************************************/
   bool operator==(const CPVRTHash& Hash) const;
 
   /*!***********************************************************************
   @brief          != Operator
   @param[in]        _Str     A string to compare with
   @return         True if they don't match
   *************************************************************************/
   bool operator!=(const CPVRTStringHash& _Str) const;
 
   /*!***********************************************************************
   @brief          != Operator. This function compares the hash values of
                   the string.
   @param[in]        Hash     A Hash to compare with
   @return         True if they match
   *************************************************************************/
   bool operator!=(const CPVRTHash& Hash) const;
 
   /*!***********************************************************************
   @fn               String
   @return         The original string
   @brief          Returns the original, base string.
   *************************************************************************/
   const CPVRTString& String() const;
 
   /*!***********************************************************************
   @brief          Returns the hash of the base string
   @fn               Hash
   @return         The hash
   *************************************************************************/
   const CPVRTHash& Hash() const;
 
   /*!***************************************************************************
   @fn               c_str
   @return            The original string.
   @brief          Returns the base string as a const char*.
   *****************************************************************************/
   const char* c_str() const;
 
private:
   CPVRTString            m_String;
   CPVRTHash            m_Hash;
};
 
#endif