/* 
 * 
 * Confidential Information of Telekinesys Research Limited (t/a Havok).  Not for disclosure or distribution without Havok's
 * prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok.
 * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
 * 
 */


#ifndef INC_KEY_VALUE_DATABASE
#define INC_KEY_VALUE_DATABASE

#include <Common/Base/hkBase.h>
#include <Demos/DemoCommon/Utilities/GameUtils/hkObjectMap.h>

class hkIstream;

typedef hkObjectMap<hkString, hkString>				hkKeyValueEntry;
typedef hkObjectMap<hkString, hkKeyValueEntry>		hkKeyValue;

	// This is a (very basic) class designed to hold and provide acess to data indexed by
	// string "keys" , in sections (also indexed by keys). It is used to read in a simple ".ini"
	// file containing arbitrary data (ragdoll parameters, keyframes, biped data etc.)
class KeyValuesDatabase
{

public:
	HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_DEMO, KeyValuesDatabase );

	KeyValuesDatabase();
	~KeyValuesDatabase();

	const hkString&	getStringValue( const hkString& section, const hkString& key );
	hkReal	getFloatValue( const hkString& section, const hkString& key );
	int     getIntValue( const hkString& section, const hkString& key );

	void	setStringValue( const hkString& section, const hkString& key, const hkString& value );
	void	setFloatValue( const hkString& section, const hkString& key, hkReal value );
	void	setIntValue( const hkString& section, const hkString& key, int value );
	
	hkResult	load( hkIstream& stream );
	hkResult	save( hkOstream& stream );

	int		getNumSections();
	void	getSectionByIndex( int index, hkString& section );
	int		getNumKeysForSection( const hkString& section );
	void	getKeyValueByIndex( const hkString& section, int index, hkString& key, hkString& value );

protected:

	hkKeyValue m_keyValues;

	hkString	m_lastSectionString;
	const hkKeyValueEntry* m_lastSection;

	hkString	m_emptyString;
};

#endif	//INC_KEY_VALUE_DATABASE


/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529)
*
* Confidential Information of Havok.  (C) Copyright 1999-2008 
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok.  Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates 
* acceptance of the End User licence Agreement for this product. A copy of 
* the license is included with this software and is also available at
* www.havok.com/tryhavok
*
*/
