//
// Tools_EnumerationReader.h
//
// Created by Richard Rice - 30/05/2002
// 
// Copyright (C) 2002 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef __TOOLS_ENUMERATIONREADER_H__
#define __TOOLS_ENUMERATIONREADER_H__

#include "Core/Asura_NameTree.h"

/*
Reads in the values of an enumeration from a C/C++ header file
Does recognise :
1) Single and multiline comments
2) Entries of the form 'enumerationString = value'  , where value is decimal or hexadeximal

Limitations include (but are not limited to...):
1) Doesn't recognise preprocessor statements
2) Each entry in the enumeration has to be on a seperate line
3) Doesn't support entries of the form 'enumerationString = anotherEnumerationString'
*/


class Tools_EnumerationReader
{
public :

	bool ReadEnumeration(const char* filename,const char* enumeration,bool bCheckNetwork =true);

	bool GetEnumerationValue(const char* valueName,int& outputValue);
    const char* GetEnumerationValueName( int iValue );

    const char* GetError( void ) const { return ErrorMessage; }
	
	Asura_NameTree& GetNameTree() { return EnumerationNameTree; }

private :
	void RemoveComments(char* buffer);
	void SkipWhiteSpaceOnLine(char*& buffer);
	void GotoNextLine(char*& buffer);


	Asura_NameTree EnumerationNameTree;


	char ErrorMessage[500];

};


#endif //__TOOLS_ENUMERATIONREADER_H__
