Click here to Skip to main content
15,884,298 members
Articles / Web Development / HTML

A Comprehensive CE Class Library to Replace ATL and MFC

Rate me:
Please Sign up or sign in to vote.
4.48/5 (14 votes)
4 Oct 2000CPOL 278.3K   998   70  
A collection of classes for CE that do not use ATL or MFC, plus an FTP client, database viewer, and sample application that solves beam deflection equations.
#ifndef __CeDebug_h__
#define __CeDebug_h__

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

#define HANDLE_EXCEPTION(n)	\
	((GetExceptionCode() ==(n)) ? EXCEPTION_EXECUTE_HANDLER: EXCEPTION_CONTINUE_SEARCH)

// Define TRACE behavior
#ifndef _DEBUG
	inline void CeTrace(LPCTSTR, ...) { }
	inline void CeAssert(BOOL, LPCTSTR) { }
#  define TRACE						1 ? (void)0 : ::CeTrace
#  define TRACE0(sz)
#  define TRACE1(sz, p1)
#  define TRACE2(sz, p1, p2)
#  define TRACE3(sz, p1, p2, p3)
#  define ISVALIDPTR(p, sz)
#else
	void CeTrace(LPCTSTR lpszFormat, ...);
	void CeAssert(BOOL bExp, LPCTSTR lpszFormat);
#  define TRACE						::CeTrace
#  define TRACE0(sz)				::CeTrace(_T("%s"), _T(sz))
#  define TRACE1(sz, p1)			::CeTrace(sz, p1)
#  define TRACE2(sz, p1, p2)		::CeTrace(sz, p1, p2)
#  define TRACE3(sz, p1, p2, p3)	::CeTrace(sz, p1, p2, p3)
#  define ISVALIDPTR(p, sz)			(p != NULL && !IsBadReadPtr((void*)p, sz) && !IsBadWritePtr((void*)p, sz))
#endif

//#ifdef _DEBUG
#  define TRAP(_stmt) \
	__try { _stmt; } \
    __except (EXCEPTION_EXECUTE_HANDLER) \
	{ \
		::MessageBox(NULL, L#_stmt, _T("Exception trapped"), MB_OK | MB_ICONSTOP); \
	}
//#else
//#  define TRAP(_stmt)	_stmt
//#endif

// Define ASSERT behavior
#if defined(_DEBUG) && defined(_WIN32_WCE)
#  ifdef UNICODE
#    define CHW_ASSERT(_exp)		::CeAssert(BOOL(_exp), L"Assert Failed: " L#_exp)
#  else
#    define CHW_ASSERT(_exp)		::CeAssert(BOOL(_exp), "Assert Failed: " #_exp)
#  endif
#elif defined(_DEBUG)
#  include <crtdbg.h>
#  define CHW_ASSERT(exp)			_ASSERTE(exp)
#else
#  define CHW_ASSERT(exp)
#endif

#undef ASSERT
#ifndef ASSERT
#  define ASSERT(exp)				CHW_ASSERT(exp)
#endif

#undef ASSERT_VALID
#ifndef ASSERT_VALID
#  define ASSERT_VALID(p)			ISVALIDPTR(p, sizeof *p)
#endif

#undef _ASSERTE
#ifndef _ASSERTE
#  define _ASSERTE(exp)				CHW_ASSERT(exp)
#endif

#undef VERIFY
#ifndef VERIFY
#  ifdef _DEBUG
#    define VERIFY(exp)				ASSERT(exp)
#  else
#    define VERIFY(exp)				((void)(exp))
#  endif
#endif


#endif __CeDebug_h__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions