#ifndef _INCLUDE_CONFIGH #define _INCLUDE_CONFIGH #pragma once #include #include #include #define WIN32_LEAN_AND_MEAN #define _WIN32_WINNT 0x0501 #include #ifndef STRICT #define STRICT #endif // use matlab to compute gist descriptors #define GIST_MATLAB // compiling as a DLL, put 'DLLBUILD' in the preprocessing // commands of the copy detection method projects #define DLLBUILD #ifdef DLLBUILD # define DLLAPI __declspec(dllexport) #else # define DLLAPI __declspec(dllimport) #endif // enable memory leak detection #define MEMORY_LEAK #ifdef MEMORY_LEAK #include "memoryleak.h" #else #define NEW new #endif // compare strings, for use by sorting algorithms #include using namespace std; extern bool StringCompare(const string &word1, const string &word2); extern bool StringIdentical(const string &word1, const string &word2); // setting, unsetting, flipping and testing for bits #define BIT_SET32(x, n) { x |= (1 << n); } #define BIT_SET64(x, n) { x |= (1i64 << n); } #define BIT_UNSET32(x, n) { x &= ~(1 << n); } #define BIT_UNSET64(x, n) { x &= ~(1i64 << n); } #define BIT_FLIP32(x, n) { x ^= (1 << n); } #define BIT_FLIP64(x, n) { x ^= (1i64 << n); } #define BIT_ISSET32(x, n) (x & (1 << n) ? true : false) #define BIT_ISSET64(x, n) (x & (1i64 << n) ? true : false) // handy cleanup methods #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } #define SAFE_FREE(p) { if(p) { free(p); (p)=NULL; } } #define SAFE_CLOSEHANDLE(p) { if(p) { CloseHandle(p); (p)=NULL; } } #define SAFE_CLOSEFILE(p) { if(p) { fclose(p); (p)=NULL; } } #define SAFE_RELEASEMUTEX(p) { if(p) { ReleaseMutex(p); (p)=NULL; } } // safe print string // count is the total length of the buffer, thus for 'char text[10]', count is 10 extern void SAFE_SPRINTF(char *buffer, size_t count, const char *format, ...); // safe print string using variable amount of arguments extern char* SAFE_VAPRINT(const char *format, ...); // safe print to debug window extern void SAFE_DEBUG(const char *format, ...); // safe print string to file and immediately flush it extern void SAFE_FLUSHPRINT(FILE *file, const char *format, ...); // safe read line from file extern bool SAFE_GETLINE(char *buffer, unsigned int buffersize, unsigned int &linelength, FILE *file); // safe load file from disk extern bool SAFE_LOADFILE(const char *fname, unsigned char **data, unsigned int &length); extern bool SAFE_LOADFILE(FILE *file, unsigned char **data, unsigned int &length); // redirect stderr to a file and restore it extern bool RedirectStderr(const char *fname); extern bool RestoreStderr(); // center the window on its parent void CenterWindow(HWND hWnd); #endif