Index: trunk/gsdl/packages/isis-gdl/Debug.cpp
===================================================================
--- trunk/gsdl/packages/isis-gdl/Debug.cpp	(revision 7139)
+++ trunk/gsdl/packages/isis-gdl/Debug.cpp	(revision 7139)
@@ -0,0 +1,213 @@
+#include "stdafx.h"
+#include "Debug.h"
+
+//---------------------------------------------------------------
+//
+// AssertFailed
+//
+//---------------------------------------------------------------
+#if DEBUG || ASSERTS_THROW
+void AssertFailed(const char* expr, const char* file, int line)
+{
+	/*
+	_TCHAR mesg[512];							
+
+	const char* fileName = file + strlen(file);		// strip off path
+	while (fileName > file && fileName[-1] != '\\')
+		--fileName;
+
+	_stprintf(mesg, _T("ASSERT(%s) in '%s' at line %d failed."), expr, fileName, line);
+	
+	MSG msg;							// remove pending quit messages so the message box displays
+	bool quitting = (bool) ::PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
+
+	UINT32 flags = MB_OK +				// just an OK button
+				   MB_ICONERROR +		// display the icon for errors
+				   MB_DEFBUTTON1 +		// select the OK button
+				   MB_TASKMODAL +		// don't let the user do anything else in the app
+				   MB_SETFOREGROUND;	// bring the app to the front
+
+	(void) MessageBox(NULL, mesg, NULL, flags);
+//#if DEBUG
+//	if (gBreakOnAssert)
+//		BreakStrToDebugger(mesg);
+//#endif
+
+//#if ASSERTS_THROW
+	CString text = L"Internal (Assert) Error: ";
+	AfxThrowUserException( ); 
+//#endif
+*/
+}
+#endif	// DEBUG || ASSERTS_THROW
+
+
+//---------------------------------------------------------------
+//
+// RequireFailed
+//
+//---------------------------------------------------------------
+#if !DEBUG
+void RequireFailed(const char* expr, const char* file, int line)
+{
+	/*
+	char mesg[512];							
+
+	const char* fileName = file + strlen(file);		// strip off path
+	while (fileName > file && fileName[-1] != '\\')
+		--fileName;
+
+	sprintf(mesg, "There has been a fatal error in '%s' at line %d.", fileName, line);
+
+	MSG msg;							// remove pending quit messages so the message box displays
+	bool quitting = (bool) ::PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
+
+	UINT32 flags = MB_OK +				// just an OK button
+				   MB_ICONERROR +		// display the icon for errors
+				   MB_DEFBUTTON1 +		// select the OK button
+				   MB_TASKMODAL +		// don't let the user do anything else in the app
+				   MB_SETFOREGROUND;	// bring the app to the front
+
+	(void) MessageBox(NULL, mesg, NULL, flags);
+
+	abort();
+	*/
+}
+#endif // !DEBUG
+
+//---------------------------------------------------------------
+//
+// ToStr (bool)
+//
+//---------------------------------------------------------------
+std::wstring ToStr(bool value)
+{
+	return value ? L"true" : L"false";
+}
+
+
+//---------------------------------------------------------------
+//
+// ToStr (char)
+//
+//---------------------------------------------------------------
+std::wstring ToStr(char value)
+{
+	wchar_t str[32];							
+	::swprintf(str, L"%c", value);
+	
+	return str;
+}
+
+
+//---------------------------------------------------------------
+//
+// ToStr (int16, int32)
+//
+//---------------------------------------------------------------
+std::wstring ToStr(int16_t value, int32_t fieldWidth)
+{
+	wchar_t str[32];							
+	::swprintf(str, L"%*d", fieldWidth, value);
+	
+	return str;
+}
+
+
+//---------------------------------------------------------------
+//
+// ToStr (uint16, int32)
+//
+//---------------------------------------------------------------
+std::wstring ToStr(uint16_t value, int32_t fieldWidth)
+{
+	wchar_t str[32];							
+	::swprintf(str, L"%*d", fieldWidth, value);
+	
+	return str;
+}
+
+
+//---------------------------------------------------------------
+//
+// ToStr (int32, int32)
+//
+//---------------------------------------------------------------
+std::wstring ToStr(int32_t value, int32_t fieldWidth)
+{
+	wchar_t str[32];							
+	::swprintf(str, L"%*ld", fieldWidth, value);
+	
+	return str;
+}
+
+
+//---------------------------------------------------------------
+//
+// ToStr (uint32, int32)
+//
+//---------------------------------------------------------------
+std::wstring ToStr(uint32_t value, int32_t fieldWidth)
+{
+	wchar_t str[32];							
+	::swprintf(str, L"%*lu", fieldWidth, value);
+	
+	return str;
+}
+
+
+//---------------------------------------------------------------
+//
+// ToStr (float, int32)
+//
+//---------------------------------------------------------------
+std::wstring ToStr(float value, int32_t precision)
+{
+	wchar_t str[32];							
+	::swprintf(str, L"%.*f", precision, value);
+	
+	return str;
+}
+
+
+//---------------------------------------------------------------
+//
+// ToStr (double, int32)
+//
+//---------------------------------------------------------------
+std::wstring ToStr(double_t value, int32_t precision)
+{
+	wchar_t str[32];							
+	::swprintf(str, L"%.*f", precision, value);
+	
+	return str;
+}
+
+
+//---------------------------------------------------------------
+//
+// ToStr (const char*)
+//
+//---------------------------------------------------------------
+std::wstring ToStr(const char* value)
+{
+	wchar_t str[2048];							
+	::swprintf(str, L"%s", value);
+	
+	return str;
+}
+
+
+//---------------------------------------------------------------
+//
+// ToStr (std::string)
+//
+//---------------------------------------------------------------
+std::wstring ToStr(const std::string& value)
+{
+	wchar_t str[2048];							
+	::swprintf(str, L"%s", value.c_str());
+	
+	return str;
+}
+
Index: trunk/gsdl/packages/isis-gdl/Debug.h
===================================================================
--- trunk/gsdl/packages/isis-gdl/Debug.h	(revision 7139)
+++ trunk/gsdl/packages/isis-gdl/Debug.h	(revision 7139)
@@ -0,0 +1,161 @@
+#ifndef __DEBUG_H__
+#define __DEBUG_H__
+
+//	Abstract:	This file provides the following macros:
+//
+//				ASSERT(p) - If p is false and DEBUG is true drops into the 
+//				debugger, if ASSERTS_THROW is true throws a XAssertException exception.
+//
+//				VERIFY(p) - Like ASSERT except that p is evaluated in release builds.
+//
+//				REQUIRE(p) - Like VERIFY except that it exits the app if the test fails
+//				(this is needed because the boot strap code can't safely throw).
+//
+//				COMPILE_CHECK(p) - An ASSERT that fires at compile time. This is useful
+//				for doing things like verifying the layout of items within a struct.
+//				Note that this check is also done in release builds.
+//
+//				DEBUGSTR(formatStr, n1, n2, ...) - Drops into the debugger and
+//				displays a string.
+//
+//				TRACE(formatStr, n1, n2, ...) - Writes a string to a debug window
+//				without suspending the program.
+//
+//				TRACEFLOW(category, formatStr, n1, n2, ...) - Like TRACE, but with 
+//				the addition of a category string. The category string allows users 
+//				to turn off entire categories of messages. Note that DEBUGSTR, TRACE, 
+//				and TRACEFLOW may be used with boolean expressions by tacking an _IF 
+//				on the end (eg DEBUGSTR_IF(x < 0, "Sqrt was passed a negative argument.")).
+//
+//				PRECONDITION(p)  - Used in conjunction with POSTCONDITION to verify 
+//				the integrity of an object: each public method should include one call to 
+//				PRECONDITION and another to POSTCONDITION. The idea here is to check to 
+//				see if the object stays in a valid state given valid arguments. Note that 
+//				these macros call a method named Invariant. This method should use ASSERT's 
+//				to check to see if the object is in a sane state. See ZInvariant.h for
+//				more details.
+//
+//				CHECK_INVARIANT() - Calls the Invariant. This is useful in ctors because
+//				PRECONDITION doesn't call the dtor (PRECONDITION constructs an object on
+//				the stack which calls the Invariant when the function exits).
+
+#pragma once      // Open only once per build
+
+#define RUNTIME_EXPORT 
+
+RUNTIME_EXPORT std::wstring ToStr(bool value);				// I originally used iostreams, but that caused a ridiculous amount of bloat in object files (but much less so in the exe)
+RUNTIME_EXPORT std::wstring ToStr(char value);
+inline 		   std::wstring ToStr(wchar_t value)						{return std::wstring(1, value);}
+RUNTIME_EXPORT std::wstring ToStr(int16_t value, int32_t fieldWidth = 1);
+RUNTIME_EXPORT std::wstring ToStr(uint16_t value, int32_t fieldWidth = 1);
+RUNTIME_EXPORT std::wstring ToStr(int32_t value, int32_t fieldWidth = 1);
+RUNTIME_EXPORT std::wstring ToStr(uint32_t value, int32_t fieldWidth = 1);
+RUNTIME_EXPORT std::wstring ToStr(float value, int32_t precision = 6);
+RUNTIME_EXPORT std::wstring ToStr(double_t value, int32_t precision = 6);
+RUNTIME_EXPORT std::wstring ToStr(const char* value);
+inline 		   std::wstring ToStr(const wchar_t* value)					{return value;}
+RUNTIME_EXPORT std::wstring ToStr(const std::string& value);
+inline 		   std::wstring ToStr(const std::wstring& value)			{return value;}
+
+
+#ifdef _DEBUG
+	#define	DEBUG					1
+#else		
+	#define	DEBUG					0
+	
+	#if	!defined(NDEBUG)
+		#define	NDEBUG							// used by <assert.h>
+	#endif
+#endif
+
+#ifndef ASSERTS_THROW
+#define ASSERTS_THROW				0			
+#endif
+#define ASSERTS_THROW               1
+// Synch with ANSI definitions.
+#if DEBUG && defined(NDEBUG)
+	#error DEBUG and NDEBUG are out of sync!
+#endif
+
+#if !DEBUG && !defined(NDEBUG)
+	#error DEBUG and NDEBUG are out of sync!
+#endif
+
+// Synch with MSVC.
+#if _MSC_VER && DEBUG != defined(_DEBUG)
+	#error DEBUG and _DEBUG are out of sync!
+#endif
+
+#ifndef _lint
+	#define COMPILE_CHECK(p)	{struct _CC {char a[(p) ? 1 : -1];};} (void) 0
+#else
+	#define COMPILE_CHECK(p)					
+#endif
+
+#if DEBUG
+	
+	void AssertFailed(const char* expr, const char* file, int line);
+	
+	#undef assert
+
+	#define ASSERT(p)					do {if (!(p)) AssertFailed(#p, __FILE__, __LINE__);} while (false)
+
+	#define ASSERT_IF(p, x)				do {if ((p) && !(x)) AssertFailed(#x, __FILE__, __LINE__);} while (false)
+	#define assert(p) 					ASSERT(p)
+	#define VERIFY(p)					ASSERT(p)
+	#define REQUIRE(p)					ASSERT(p)
+
+	#define	PRECONDITION(p)				ASSERT(p)
+	#define	POSTCONDITION(p)			ASSERT(p)
+
+    #ifdef NO_NESTED_QUOTES
+          #define PRECONDITION2(a,b)	ASSERT(a)
+          #define POSTCONDITION2(a,b)	ASSERT(a)
+    #else
+          #define PRECONDITION2(a,b)	ASSERT((b, (a) !=0))
+          #define POSTCONDITION2(a,b)	ASSERT((b, (a) !=0))
+    #endif
+
+#else	// #if DEBUG
+
+
+	#if ASSERTS_THROW
+		void AssertFailed(const char*, const char*, int);
+
+		#define ASSERT(p)				do {if (!(p)) AssertFailed(#p, __FILE__, __LINE__);} while (false)
+
+		#define ASSERT_IF(p, x)			do {if ((p) && !(x)) AssertFailed(#x, __FILE__, __LINE__);} while (false)
+		#define VERIFY(p)				ASSERT(p)
+
+		#define	PRECONDITION(p)			ASSERT(p)
+		#define	POSTCONDITION(p)		ASSERT(p)
+
+        #define PRECONDITION2(a,b)	    ASSERT(a)
+        #define POSTCONDITION2(a,b)	    ASSERT(a)
+	#else
+		#define	ASSERT(p)				((void) 0)
+
+		#define	ASSERT_IF(p, x)			((void) 0)
+		#define VERIFY(p)				do {if (p) 0;} while (false)
+
+		#define	PRECONDITION(p)			((void) 0)
+		#define	POSTCONDITION(p)		((void) 0)
+
+        #define PRECONDITION2(a,b)
+        #define POSTCONDITION2(a,b)
+	#endif
+
+	void RequireFailed(const char*, const char*, int);
+	
+	#define REQUIRE(p)					do {if (!(p)) RequireFailed(#p, __FILE__, __LINE__);} while (false)
+
+
+#endif	// DEBUG
+
+#ifdef _CONSOLE
+#define TRACE
+#endif
+	
+
+
+#endif /* __DEBUG_H__ */
