#include "HashString.h"

HashString::HashString()
: m_ulHash(0)
{
}

HashString::HashString(const std::string &typeStr)
: m_ulHash(0)
{
	setStr(typeStr);
}

void HashString::setStr(const std::string &typeStr)
{
	m_sTypeStr = typeStr;
	m_ulHash = HashString::StringToHash(typeStr);
}

unsigned long HashString::StringToHash(const std::string &str)
{
	const char* pCStr = str.c_str();

	unsigned long hash = 5381;
	int c;

	while (c = *pCStr++)
		hash = ((hash << 5) + hash) + c; /* hash * 33 + c */

	return hash;
}
