common.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006-2010 Jacek Sieka, arnetheduck on gmail point com
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00037 #ifndef ADCHPP_COMMON_H
00038 #define ADCHPP_COMMON_H
00039 
00040 namespace adchpp {
00041 
00042 extern ADCHPP_DLL const char compileTime[];
00043 extern ADCHPP_DLL void logAssert(const char* file, int line, const char* exp);
00044 
00045 #ifndef NDEBUG
00046 
00047 inline void debugTrace(const char* format, ...)
00048 {
00049     va_list args;
00050     va_start(args, format);
00051 
00052 #ifdef _MSC_VER
00053     char buf[512];
00054 
00055     _vsnprintf(buf, sizeof(buf), format, args);
00056     OutputDebugStringA(buf);
00057     fputs(buf, stderr);
00058 #else // _MSC_VER
00059     vfprintf(stdout, format, args);
00060 #endif // _MSC_VER
00061     va_end(args);
00062 }
00063 
00064 #define dcdebug debugTrace
00065 #define dcassert(exp) do { if(!(exp)) logAssert(__FILE__, __LINE__, #exp); } while(false)
00066 //#define dcassert(exp) do { if(!(exp)) __asm { int 3}; } while(0)
00067 
00068 #define dcasserta(exp) dcassert(exp)
00069 #define dcdrun(exp) exp
00070 #else //NDEBUG
00071 #define dcdebug if(false) printf
00072 //#define dcassert(exp) do { if(!(exp)) logAssert(__FILE__, __LINE__, #exp); } while(0)
00073 #define dcassert(exp)
00074 #ifdef _MSC_VER
00075 #define dcasserta(exp) __assume(exp)
00076 #else
00077 #define dcasserta(exp)
00078 #endif // WIN32
00079 #define dcdrun(exp)
00080 #endif //NDEBUG
00081 
00082 // Make sure we're using the templates from algorithm...
00083 #ifdef min
00084 #undef min
00085 #endif
00086 #ifdef max
00087 #undef max
00088 #endif
00089 
00090 typedef std::vector<std::string> StringList;
00091 typedef StringList::iterator StringIter;
00092 typedef StringList::const_iterator StringIterC;
00093 
00094 typedef std::vector<uint8_t> ByteVector;
00095 typedef ByteVector::iterator ByteIter;
00096 
00100 ADCHPP_DLL void initialize(const std::string& path);
00101 
00105 ADCHPP_DLL void startup(void (*f)());
00106 
00110 ADCHPP_DLL void shutdown(void (*f)());
00111 
00115 ADCHPP_DLL void cleanup();
00116 
00117 }
00118 
00119 #endif // COMMON_H
Generated on Sat Nov 27 23:37:53 2010 for adchpp by  doxygen 1.6.3