/*
	ZUtilBuild.hpp
	Author: James Russell <jcrussell@762studios.com>
	Created: 11/7/2010

	Purpose: 

	Used to generate definitions for the preprocessor using only compiler-set
	preprocessor variables, mostly to force a semblance of cross-system compatibility.

	License:

	TODO

*/

#pragma once

#ifndef _ZUTILBUILD_HPP
#define _ZUTILBUILD_HPP

//This gives us our standard int types
#include <pstdint.h>

#include "ZBuild.hpp"

//Version number constants for ZUtil
#define ZUTIL_VERSION_MAJOR		0x01
#define ZUTIL_VERSION_MINOR		0x00
#define ZUTIL_VERSION_PATCH		0x0000
#define ZUTIL_VERSION			(ZUTIL_VERSION_MAJOR << 24) | (ZUTIL_VERSION_MINOR << 16) | (ZUTIL_VERSION_PATCH)

#define ZUTIL_VERSION_STRING	"1.0.0"

//Make sure we get proper C-style TRUE, FALSE, and NULL
#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

#ifndef NULL
#define NULL 0
#endif

//Get our numeric limits
#include <limits>
#undef min
#undef max
#define STDINT_MAX std::numeric_limits<int>::max()
#define STDINT_MIN std::numeric_limits<int>::min()
#define STDFLT_MAX std::numeric_limits<float>::max()
#define STDFLT_MIN std::numeric_limits<float>::min()
#define STDDBL_MAX std::numeric_limits<double>::max()
#define STDDBL_MIN std::numeric_limits<double>::min()

//Used to get rid of the (/W4 or -Wall) warning 'Unreferenced Formal Parameter'
#if !defined(URFP)
	#define URFP(x) ((void)x)
#endif

//Use this to disable copy construction and assignment on a class
#define DISABLE_COPY_AND_ASSIGN(ClassName) \
	ClassName(const ClassName&); \
	void operator = (const ClassName&)

//Directory separators and line terminators for the various platforms
#define DIRECTORY_SEPARATOR_WIN32	"\\"
#define LINE_TERMINATOR_WIN32		"\r\n"

#define DIRECTORY_SEPARATOR_UNIX	"/"
#define LINE_TERMINATOR_UNIX		"\n"

#define DIRECTORY_SEPARATOR_OSX		":"
#define LINE_TERMINATOR_OSX			"\n"

//Windows specialized defines
#ifdef _WIN32
#define WINDOWS 1
#define UNIX 0
#define OSX 0

#define DIRECTORY_SEPARATOR		DIRECTORY_SEPARATOR_WIN32
#define LINE_TERMINATOR			LINE_TERMINATOR_WIN32

#define _SCL_SECURE_NO_WARNINGS

#endif

//UNIX specialized defines
#ifdef _UNIX
#define WINDOWS 0
#define UNIX 1
#define OSX 0

#define DIRECTORY_SEPARATOR		DIRECTORY_SEPARATOR_UNIX
#define LINE_TERMINATOR			LINE_TERMINATOR_UNIX

//Macros to get around gcc's lack of *_s and _* functions and vc9's insistence on using them
#define _stricmp(a, b)					strcasecmp(a, b)
#define sprintf_s(a, b, c, d...)		snprintf(a, b, c, ## d)
#define vsnprintf_s(a, b, c, d, e...)	vsnprintf(a, b, d, ## e)
#endif 

//Mac specialized defines
#ifdef _MACOS
#define WINDOWS 0
#define UNIX 0
#define OSX 1

#define DIRECTORY_SEPARATOR DIRECTORY_SEPARATOR_OSX
#define LINE_TERMINATOR LINE_TERMINATOR_OSX

#define _stricmp(a, b)					strcasecmp(a, b)
#define sprintf_s(a, b, c, d...)		snprintf(a, b, c, ## d)
#define vsnprintf_s(a, b, c, d, e...)	vsnprintf(a, b, d, ## e)
#endif

#endif //_ZUTILBUILD_HPP
