| 1 |
#include "oodle.h" |
| 2 |
|
| 3 |
std::string stringify(double x) |
| 4 |
{ |
| 5 |
std::ostringstream o; |
| 6 |
if (!(o << x)) |
| 7 |
_THROWEX(ex_badConversion, "Bad Conversion Exception", "global", "stringify", "x = " << x); |
| 8 |
return o.str(); |
| 9 |
} |
| 10 |
|
| 11 |
std::string stringify(int x) |
| 12 |
{ |
| 13 |
std::ostringstream o; |
| 14 |
if (!(o << x)) |
| 15 |
_THROWEX(ex_badConversion, "Bad Conversion Exception", "global", "stringify", "x = " << x); |
| 16 |
return o.str(); |
| 17 |
} |
| 18 |
|
| 19 |
void log(const std::ostringstream &s, int lvl, logTypes type) |
| 20 |
{ |
| 21 |
char t; |
| 22 |
if (type == LOG_INFO) |
| 23 |
t = 'I'; |
| 24 |
else if (type == LOG_ERROR) |
| 25 |
t = 'E'; |
| 26 |
|
| 27 |
#if defined(WIN32) || defined(_WIN32) |
| 28 |
ofstream fout( "log.txt", ios::app ); |
| 29 |
#else |
| 30 |
char *homedir; |
| 31 |
string logfilename; |
| 32 |
|
| 33 |
homedir = getenv("HOME"); |
| 34 |
if (homedir != NULL) |
| 35 |
{ |
| 36 |
logfilename = string(homedir) + "/.blocks-log"; |
| 37 |
} |
| 38 |
else |
| 39 |
{ |
| 40 |
logfilename = "blocks-log"; |
| 41 |
} |
| 42 |
|
| 43 |
ofstream fout( logfilename.c_str(), ios::app ); |
| 44 |
#endif |
| 45 |
|
| 46 |
char tmpbuf[128]; |
| 47 |
time_t aclock; |
| 48 |
time( &aclock ); // Get time in seconds |
| 49 |
struct tm *newtime = localtime( &aclock ); // Convert time to struct tm form |
| 50 |
strftime( tmpbuf, 128, "%x %H:%M:%S", newtime ); |
| 51 |
fout << tmpbuf << " [" << t << "]: \t" << s.str() << endl; |
| 52 |
/*if (lvl <= 3) |
| 53 |
{*/ |
| 54 |
cout << "[" << t << "]\t" << s.str() << endl; |
| 55 |
//} |
| 56 |
fout.close(); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
#if SDL_BYTEORDER == SDL_BIG_ENDIAN |
| 63 |
const Uint32 RMASK = 0xff000000; |
| 64 |
const Uint32 GMASK = 0x00ff0000; |
| 65 |
const Uint32 BMASK = 0x0000ff00; |
| 66 |
const Uint32 AMASK = 0x000000ff; |
| 67 |
#else |
| 68 |
const Uint32 RMASK = 0x000000ff; |
| 69 |
const Uint32 GMASK = 0x0000ff00; |
| 70 |
const Uint32 BMASK = 0x00ff0000; |
| 71 |
const Uint32 AMASK = 0xff000000; |
| 72 |
#endif |