SourceForge.jp

dKingyoMacro.h

説明を見る。
00001 
00002 
00008 #ifndef DKINGYO_MACRO____//一回だけ読み込む
00009 #define DKINGYO_MACRO____
00010 
00011 #include "dkutilCompileOption.h"
00012 
00013 #ifdef USE_DKINGYO_INCLUDE_SETTING_LIKE_BOOST
00014 #   include <dkutil/config/dkutilConfig.h>
00015 #else
00016 #   if DKUTIL_COMPILE_OPTION_MSVC
00017 #       include "config/dkutilConfig.h"
00018 #   else
00019 #       include "dkutilConfig.h"
00020 #   endif
00021 #endif
00022 
00024 #define VISUAL_LASTERROR() \
00025 {\
00026   LPVOID lpMsgBuf;\
00027   FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,\
00028                NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL );\
00029   ::MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );\
00030   LocalFree( lpMsgBuf );\
00031 }
00032 
00033 /*
00035 #define DKUTIL_TRY try{try{
00037 #define DKUTIL_CATCH(a) }catch(a){
00038 
00039 #define DKUTIL_END_CATCH }
00041 #define DKUTIL_FINALY(f) }catch(...){\
00042         f;\
00043     }\
00044     f;
00045 */
00046 
00047 #ifdef _DEBUG
00048 
00057 
00058 #   define DEBUGMB(s) ::MessageBox(NULL,s,"DEBUG MESSAGE BOX",MB_OK)
00059 
00060 #   define DEBUGODS(s) ::OutputDebugString(s)
00061 
00062 #   include <assert.h>
00063 #   define DEBUGASSERT(s) assert(s)
00064 #else
00065 #   define DEBUGMB(s) {} //念のため{}でもつけておく
00066 #   define DEBUGODS(s) {}
00067 #   define DEBUGASSERT(s) {}
00068 #endif
00069 
00070 
00079 
00080 
00081 #define SET_VA_LIST_INSERT_YEN_N(s,snum,origin) \
00082     {\
00083         SET_VA_LIST(s,snum,origin);\
00084         size_t len = strlen(s);\
00085         bool isYen = s[len-1] != '\n';\
00086         if(len >= snum - 1){\
00087             if(isYen){\
00088                 s[len-1]='\n';\
00089             }\
00090         }else{\
00091             if(isYen){\
00092                 s[len] = '\n';\
00093                 s[len + 1] = '\0';\
00094             }\
00095         }\
00096     }
00097 /*
00098 #define SET_VA_LIST_INSERT_YEN_N(s,snum,origin) \
00099     {\
00100         SET_VA_LIST(s,snum,origin);\
00101         size_t len = strlen(s);\
00102         if(s[len-1] != '\n'){\
00103             if(len >= snum - 1){\
00104                 s[len-1]='\n';\
00105             }else{\
00106                 strncat(s,"\n",len);\
00107             }\
00108         }\
00109     }*/
00110 /*
00111 //可変引数関数を作る時,文字列バッファを使う場合に必要なバッファの数を得る
00112 #define GET_VALIST_CHAR_BUFF_NUM(origin) \
00113     {
00114         va_list VaList;\
00115         va_start( VaList , origin ) ;\
00116         int len = strlen(origin);
00117         for(int i=0;i<len;i++){
00118             if (_ismbblead((int) origin[i])){
00119                 i++;
00120                 continue;
00121             }
00122             if(origin[i] == '%'){//%を見つけたなり
00123                 if(!(i + 1 >= len)){//バッファオーバーフローしないようであれば
00124                     switch(origin[i+1]){
00125                     case 'c'://文字
00126                     case 's'://文字列
00127                     case 'd'://
00128                     case 'u':
00129 
00130                  printf("%i : %o - 符号付8進数(%dと冗長)と符号なし8進数\n" , 0xff , 0xff);
00131         printf("%x : %X - 符号なし16進数、小文字と大文字\n" , 0xff , 0xff);
00132 
00133         printf("%e : %E - [-]d.dddd e [sign]ddd 形式符号付きの値\n" , 1.24 , 1.24);
00134         printf("%f - [-]dddd.dddd 形式の符号付きの値\n" , 1.24);
00135         printf("%g : %G - f,eうち精度を表現できる短い方の書式\n" , 1.24 , 1.24);
00136 
00137         printf("%s : %S - ヌル文字までの文字列\n", STR , STR);
00138 
00139         printf("Kitty%n <- ここまでの出力数を保存\n" , &i);
00140         printf("%d - ストリームまたはバッファに書き込まれた文字数\n" , i);
00141         printf("%p - ポインタを表示\n" , i);
00142 */
00149 
00150 #define BEGIN_GET_MANY_ARG(result,s,add,str) \
00151     { \
00152         size_t strnum = strlen(str) + add;\
00153         s = (char *)::malloc(strnum);\
00154         result = false;\
00155         if(s){\
00156             SET_VA_LIST(s,strnum,str);\
00157             result = true;\
00158         }\
00159     }
00160 
00163 
00164 #define END_GET_MANY_ARG(mem) \
00165     {\
00166         if(mem){::free(mem);mem=NULL;}\
00167     }
00168 
00169 //  WARNINGマクロ(yane SDKより
00170 #ifdef _DEBUG
00171 #   define DK_WARNING(s) {\
00172     CHAR buf[256];              \
00173     wsprintf(buf,"%sファイルの%d行 \n%s",__FILE__,__LINE__,s);  \
00174     MessageBox(NULL,buf,"WARNING!!",MB_OK); \
00175     * LPLONG(0x00000000) = 0;   \
00176     }
00177 #   define YANE_WARNING(b,s)                \
00178         if(b) {                     \
00179             CHAR buf[256];              \
00180             wsprintf(buf,"%sファイルの%d行 %s\n",__FILE__,__LINE__,s);  \
00181             MessageBox(NULL,buf,"WARNING!!",MB_OK); \
00182             * LPLONG(0xcdcdcdcd) = 0;   \
00183         }
00184     //  最後の* LPLONG(0xcdcdcdcd) = 0;の部分は、メモリエラーをわざと起こすコード
00185 #else
00186 #   define YANE_WARNING(var,s) {}
00187 #   define DK_WARNING(s) 
00188 #endif
00189 
00190 //**********************************************************
00191 //その他もろもろのセッティング
00192 //**********************************************************
00193 
00195 #ifdef __cplusplus
00196 #   define DINLINE inline
00197 #   if _MSC_VER >= 1200
00198 #       undef DINLINE
00199 #       define DINLINE __inline
00200 #   endif//end of __inline
00201 #else
00202 #   define DINLINE 
00203 #endif//end of __cplusplus
00204 
00205 //ユーザーが例外処理を使うかどうか?
00206 #ifdef USE_DKINGYO_THROW
00207 
00208 #   define DK_THROW(str) throw str
00209 
00210 #   define DK_BAD_ALLOC() std::bad_alloc()
00211 
00212 #   include <assert.h>
00214 #   define DK_TRUE_ASSERT_OR_THROW(ass,thr) \
00215     {if(ass){\
00216         throw thr;\
00217     }}
00218 
00219 #else
00220 #   define DK_THROW(str) { \
00221     char buff[2056];\
00222     _snprintf(buff,"例外処理が発生しました. -> %s",str);\
00223     MessageBox(NULL,buff,"例外発生",MB_OK);\ 
00224     ERROR_BOX("file:%s \nline : %d",__FILE__,__LINE__);
00225     exit(-1);\
00226 }
00227 #   define DK_BAD_ALLOC() ((void)0)
00228 
00229 #   define DK_TRUE_ASSERT_OR_THROW(ass,thr) \
00230     {if(ass){\
00231         assert(!ass);\
00232     }}
00233 #endif//end of USE_DKINGYO_THROW
00234 
00236 #define DKUTIL_TRUE_ASSERT_OR_THROW(a1,a2) DK_TRUE_ASSERT_OR_THROW(a1,a2)
00237 
00239 #define DKUTIL_RETURN_FALSE(func) if(false==func){return false;}
00240 
00241 
00242 
00243 #ifndef BOOST_NO_PRIVATE_IN_AGGREGATE //なぜか boost 対応・・・
00244 
00245 #   define BOOST_PROTECTED public
00246 #   define BOOST_PRIVATE public
00247 
00248 #else
00249 #   define BOOST_PROTECTED protected
00250 #   define BOOST_PRIVATE private
00251 #endif
00252 
00253 #ifndef numof
00254 #   define numof(s) ( sizeof(s) / sizeof(s[0]) )
00255 #endif
00256 
00257 #endif//end of DKINGYO_MACRO____ once include defined

dkutil 1.02リリース前 d金魚専用マニュアルバージョンに対してSun Dec 28 21:23:07 2003に生成されました。 doxygen 1.3.5