Debian Codegraph @

Oodle/src/utils.h

raw
1 #ifndef _UTILS_
2 #define _UTILS_
3
4 #include <exception>
5 #include <stdexcept>
6 #include <sstream>
7 #include <fstream>
8 #include <string>
9 #include <time.h>
10 #include "exceptions.h"
11 #include "SDL.h"
12 using namespace std;
13
14 //! Enum to describe different types of things that can be written to a log
15 enum logTypes
16 {
17 LOG_INFO,
18 LOG_ERROR
19 };
20
21 //! Function to convert a double to a string
22 std::string stringify(double x);
23
24 //! Function to convert an int to a string
25 std::string stringify(int x);
26
27 //! Function to log output to a file (log.txt) in program's directory
28 void log(const std::ostringstream &s, int lvl, logTypes type);
29
30 //! Macro used when calling log
31 #define LOG(t, lvl, type) { \
32 ostringstream ss; \
33 ss << t;\
34 log(ss, lvl, type);\
35 }
36
37 Uint32 getPixel32(SDL_Surface *, int, int);
38 void setPixel32(SDL_Surface *, int, int, Uint32);
39
40 #ifndef __GNUC__
41 template <class T> void deleteContainer(T& a)
42 {
43 for(T::iterator i = a.begin(); i != a.end(); ++i)
44 {
45 delete (*i);
46 }
47 }
48 #endif
49
50 #define FOREACH(container, ident, iter, act) { \
51 for (container::iterator iter = ident.begin(); iter != ident.end(); ++iter) { \
52 act; \
53 }\
54 }
55
56 #define FOREACH_CONST(container, ident, iter, act) { \
57 for (container::const_iterator iter = ident.begin(); iter != ident.end(); ++iter) { \
58 act; \
59 }\
60 }
61
62 extern const Uint32 RMASK, GMASK, BMASK, AMASK;
63
64
65 #endif