source: liacs/MIR2010/SourceCode/config.h@ 394

Last change on this file since 394 was 95, checked in by Rick van der Zwet, 15 years ago

Bad boy, improper move of directory

File size: 2.8 KB
Line 
1#ifndef _INCLUDE_CONFIGH
2#define _INCLUDE_CONFIGH
3
4#pragma once
5
6#include <assert.h>
7#include <stdio.h>
8#include <stdlib.h>
9
10#define WIN32_LEAN_AND_MEAN
11#define _WIN32_WINNT 0x0501
12#include <windows.h>
13#ifndef STRICT
14#define STRICT
15#endif
16
17// use matlab to compute gist descriptors
18#define GIST_MATLAB
19
20// compiling as a DLL, put 'DLLBUILD' in the preprocessing
21// commands of the copy detection method projects
22#define DLLBUILD
23#ifdef DLLBUILD
24# define DLLAPI __declspec(dllexport)
25#else
26# define DLLAPI __declspec(dllimport)
27#endif
28
29// enable memory leak detection
30#define MEMORY_LEAK
31#ifdef MEMORY_LEAK
32#include "memoryleak.h"
33#else
34#define NEW new
35#endif
36
37// compare strings, for use by sorting algorithms
38#include <string>
39using namespace std;
40extern bool StringCompare(const string &word1, const string &word2);
41extern bool StringIdentical(const string &word1, const string &word2);
42
43// setting, unsetting, flipping and testing for bits
44#define BIT_SET32(x, n) { x |= (1 << n); }
45#define BIT_SET64(x, n) { x |= (1i64 << n); }
46#define BIT_UNSET32(x, n) { x &= ~(1 << n); }
47#define BIT_UNSET64(x, n) { x &= ~(1i64 << n); }
48#define BIT_FLIP32(x, n) { x ^= (1 << n); }
49#define BIT_FLIP64(x, n) { x ^= (1i64 << n); }
50#define BIT_ISSET32(x, n) (x & (1 << n) ? true : false)
51#define BIT_ISSET64(x, n) (x & (1i64 << n) ? true : false)
52
53// handy cleanup methods
54#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
55#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
56#define SAFE_FREE(p) { if(p) { free(p); (p)=NULL; } }
57#define SAFE_CLOSEHANDLE(p) { if(p) { CloseHandle(p); (p)=NULL; } }
58#define SAFE_CLOSEFILE(p) { if(p) { fclose(p); (p)=NULL; } }
59#define SAFE_RELEASEMUTEX(p) { if(p) { ReleaseMutex(p); (p)=NULL; } }
60// safe print string
61// count is the total length of the buffer, thus for 'char text[10]', count is 10
62extern void SAFE_SPRINTF(char *buffer, size_t count, const char *format, ...);
63// safe print string using variable amount of arguments
64extern char* SAFE_VAPRINT(const char *format, ...);
65// safe print to debug window
66extern void SAFE_DEBUG(const char *format, ...);
67// safe print string to file and immediately flush it
68extern void SAFE_FLUSHPRINT(FILE *file, const char *format, ...);
69// safe read line from file
70extern bool SAFE_GETLINE(char *buffer, unsigned int buffersize, unsigned int &linelength, FILE *file);
71// safe load file from disk
72extern bool SAFE_LOADFILE(const char *fname, unsigned char **data, unsigned int &length);
73extern bool SAFE_LOADFILE(FILE *file, unsigned char **data, unsigned int &length);
74// redirect stderr to a file and restore it
75extern bool RedirectStderr(const char *fname);
76extern bool RestoreStderr();
77
78// center the window on its parent
79void CenterWindow(HWND hWnd);
80
81#endif
Note: See TracBrowser for help on using the repository browser.