/*******************************************************************************
 *
 *	Copyright (C) 2008 ITS Co., Ltd. All rights reserved.
 *
 *	SubSystem Name : 
 *	Initial Author : hsahn
 *	Description:
 *		CPtrHash class created by tmpl_hash.py
 *		Key   : string(char *)
 *		Value : CPtrArrayItem *, Set(CPtrArrayItem *), Get(CPtrArrayItem *), Get(CPtrArray)
 *		if hash key collision, append as linked list
 *
 *		*** Don't edit this file manually ***
 ******************************************************************************/

#ifndef __PTR_HASH_H__
#define __PTR_HASH_H__

#include <stdio.h>
#include "cstream.h"
#include "cstring.h"
#include "str_array.h"
#include "ptr_array.h"


class V2_CLASS_API CPtrHash
{
private:
	class CHashBag
	{
	public:
		int iHash;
		CString sKey;
		CPtrArray vaData;
		CHashBag *pNext;
	};

	CHashBag **m_ppBag;
	int m_iBagSize;
	int m_iDataCnt;
	bool m_bAdopt;

public:
	CPtrHash(bool p_bAdopt=true, int p_iBagSize=1024);
	~CPtrHash();

	void Clear(void);
	int Set(const char *p_szKey, CPtrArrayItem * p_szData, bool p_bOverwrite=false);
	int Get(const char *p_szKey, CPtrArrayItem * *p_pVal);
	int Get(const char *p_szKey, CPtrArray *p_pArr);
	CPtrArrayItem * Get(const char *p_szKey);
	void Remove(const char *p_szKey);
	void GetKeys(CStrArray &p_saKeys);

	void Dump(CStream *p_pBuffer);

	static int HashFunc(const char *p_sKey, int p_iLen);
};

#endif	// __PTR_HASH_H__

