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