/**************************/
/* Written by David Yates */
/* Copyright Atos 2013    */
/**************************/

#if !defined(AFX_DATABASE_H__7C26F6DD_FA16_41BB_8030_D82D3E3A4C02__INCLUDED_)
#define AFX_DATABASE_H__7C26F6DD_FA16_41BB_8030_D82D3E3A4C02__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

//#ifdef _DEBUG
#pragma warning( disable : 4786) 
//#endif

#include <map>
#include <string>
using namespace std;

class database  
{
public:		// construction
	database(const char * path, unsigned int device, unsigned int level);
	virtual ~database(){};

public:		// methods
	const char* getName(unsigned int index);
	bool getName(unsigned int index, char * name, unsigned int len);

	bool setName(unsigned int index, const char*, bool writeToFile = true, bool * changed = 0);
	unsigned int getIndex(const char * name, unsigned int start = 0, unsigned int end = 0);
	unsigned int getIndex( const char * name, bool caseInsensitive, bool substring );
	unsigned int size( void );

	bool exists(unsigned int index);

	bool dump(const char* path);
	bool loadDump(const char* path);
private:	// variables
	map< unsigned int, string > db;
	unsigned int m_device;
	unsigned int m_level;
	unsigned int m_maxSize;
	string m_filename;

private:	// member functions
	void load(const char * path, unsigned int device, unsigned int level);
};

#endif // !defined(AFX_DATABASE_H__7C26F6DD_FA16_41BB_8030_D82D3E3A4C02__INCLUDED_)
