StringId.cpp
Go to the documentation of this file.00001 //*** StringId.cpp ***/ 00002 00003 #include "StringId.h" 00004 #include "StringIdTable.h" 00005 00006 //*** Constructor *** 00007 00008 StringId::StringId(): 00009 idString_(0), 00010 hash_(0) 00011 { 00012 } 00013 00014 00015 //*** Constructor *** 00016 00017 StringId::StringId(const char* idString): 00018 idString_(0), 00019 hash_(0) 00020 { 00021 // Only initialize if idString is a non-zero pointer, and of non-zero length 00022 if (idString && idString[0]) 00023 { 00024 // Calculate hash value for the string 00025 hash_=StringIdTable::GetInstance().CalculateHash(idString); 00026 00027 // Do a lookup in the shared table to find this string if it already exists, or 00028 // to insert it into the shared table if it does not 00029 idString_=StringIdTable::GetInstance().FindIdString(hash_,idString); 00030 } 00031 } 00032 00033 00034 //*** GetString *** 00035 00036 const char* StringId::GetString() const 00037 { 00038 return idString_; 00039 } 00040 00041 00042 //*** GetHash *** 00043 00044 unsigned int StringId::GetHash() const 00045 { 00046 return hash_; 00047 } 00048 00049 00050 //*** Copy Constructor *** 00051 00052 StringId::StringId(const StringId& stringId) 00053 { 00054 idString_=stringId.idString_; 00055 hash_=stringId.hash_; 00056 } 00057 00058 00059 //*** operator = *** 00060 00061 const StringId& StringId::operator=(const StringId& stringId) 00062 { 00063 idString_=stringId.idString_; 00064 hash_=stringId.hash_; 00065 return *this; 00066 } 00067 00068 00069 //*** operator == *** 00070 00071 bool StringId::operator==(const StringId& stringId) const 00072 { 00073 return idString_==stringId.idString_; 00074 } 00075 00076 00077 //*** operator != *** 00078 00079 bool StringId::operator!=(const StringId& stringId) const 00080 { 00081 return idString_!=stringId.idString_; 00082 } 00083 00084
Reproduction/republishing of any material on this site without permission is strictly prohibited.
