/** @file errorencoder.h
*	An encoder that blows (but will not crash) up if you try to encode something
*	@author Chris Burns (cburns@ea.com)
*
*	Core Technology UI
*	(c) 2012 Electronic Arts Inc.
*/

#ifndef EABASETYPESPLUS_ERRORENCODER_H_
#define EABASETYPESPLUS_ERRORENCODER_H_

#include "eaassert/eaassert.h"

#include "EABaseTypes/datatypes.h"

namespace EA
{
namespace Types
{
	/*! @class ErrorEncoder errorencoder.h	"EABaseTypesPlus/errorencoder.h"
	*	@brief An encoder that verifies that we don't encode anything
	*/
	class ErrorEncoder
	{
	public:

		EA_FORCE_INLINE ErrorEncoder() {}

		// template interface
		EA_FORCE_INLINE void Reset() {}

		EA_FORCE_INLINE void BeginArray() { Fail(); }
		EA_FORCE_INLINE void EndArray() { Fail(); }

		EA_FORCE_INLINE void BeginArrayValue(size_t index) { Fail(); }
		EA_FORCE_INLINE void EndArrayValue(size_t index) { Fail(); }

		EA_FORCE_INLINE void BeginObject() { Fail(); }
		EA_FORCE_INLINE void EndObject() { Fail(); }

		EA_FORCE_INLINE void BeginObjectValue(const char* key, size_t length) { Fail(); }
		EA_FORCE_INLINE void EndObjectValue(const char* key, size_t length) { Fail(); }

		EA_FORCE_INLINE void Boolean(bool boolean) { Fail(); }
		EA_FORCE_INLINE void Number(EA::BaseTypeFloat number) { Fail(); }
		EA_FORCE_INLINE void String(const char* str, size_t length) { Fail(); }
		EA_FORCE_INLINE void Function(EA::Types::FunctionIn function) { Fail(); }
		EA_FORCE_INLINE void UserData(EA::Types::UserDataIn userData) { Fail(); }
		EA_FORCE_INLINE void Null() { /* Fail(); */ }

	private:

		EA_FORCE_INLINE void Fail() { EA_FAIL_MESSAGE("Nothing can be encoded by an error encoder!"); }
	};
}
}

#endif /* EABASETYPESPLUS_ERRORENCODER_H_ */
