// EMERGENT GAME TECHNOLOGIES PROPRIETARY INFORMATION // // This software is supplied under the terms of a license agreement or // nondisclosure agreement with Emergent Game Technologies and may not // be copied or disclosed except in accordance with the terms of that // agreement. // // Copyright (c) 1996-2008 Emergent Game Technologies. // All Rights Reserved. // // Emergent Game Technologies, Chapel Hill, North Carolina 27517 // http://www.emergent.net //--------------------------------------------------------------------------- // NiTStringTemplateMap inline functions //--------------------------------------------------------------------------- template inline NiTStringMap::NiTStringMap( unsigned int uiHashSize, bool bCopy) : NiTStringTemplateMap, TVAL, THASH, TEQUALS>(uiHashSize, bCopy) { } //--------------------------------------------------------------------------- template inline NiTStringPointerMap:: NiTStringPointerMap(unsigned int uiHashSize, bool bCopy) : NiTStringTemplateMap, TVAL>(uiHashSize, bCopy) { } //--------------------------------------------------------------------------- template inline NiTStringTemplateMap::NiTStringTemplateMap( unsigned int uiHashSize, bool bCopy) : TPARENT(uiHashSize) { m_bCopy = bCopy; } //--------------------------------------------------------------------------- template inline NiTStringTemplateMap::~NiTStringTemplateMap() { if (m_bCopy) { for (unsigned int i = 0; i < TPARENT::m_uiHashSize; i++) { NiTMapItem* pkItem = TPARENT::m_ppkHashTable[i]; while (pkItem) { NiTMapItem* pkSave = pkItem; pkItem = pkItem->m_pkNext; NiFree((char*) pkSave->m_key); } } } } //--------------------------------------------------------------------------- inline unsigned int NiStringHashFunctor::KeyToHashIndex( const char* pKey, unsigned int uiTableSize) { unsigned int uiHash = 0; while (*pKey) uiHash = (uiHash << 5) + uiHash + *pKey++; return uiHash % uiTableSize; } //--------------------------------------------------------------------------- inline bool NiStringEqualsFunctor::IsKeysEqual(const char* pcKey1, const char* pcKey2) { return strcmp(pcKey1, pcKey2) == 0; } //--------------------------------------------------------------------------- template inline void NiTStringTemplateMap::SetValue( NiTMapItem* pkItem, const char* pcKey, TVAL val) { if (m_bCopy) { size_t stLen = strlen(pcKey) + 1; pkItem->m_key = NiAlloc(char, stLen); NIASSERT(pkItem->m_key); NiStrcpy((char*) pkItem->m_key, stLen, pcKey); } else { pkItem->m_key = pcKey; } pkItem->m_val = val; } //--------------------------------------------------------------------------- template inline void NiTStringTemplateMap::ClearValue( NiTMapItem* pkItem) { if (m_bCopy) { NiFree((char*) pkItem->m_key); } } //---------------------------------------------------------------------------