Sorted Socket.
[UnsignedByte.git] / src / Resource / Global.cpp
blobfded91c244e54b0d6fff99776ae1d6dae06bd618
1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include <stdarg.h>
22 #include "Global.h"
24 bool g_shutdown = false;
25 bool g_nocatch = false;
26 bool g_printsql = false;
27 bool g_printbugs = true;
28 bool g_printstatus = true;
29 bool g_printlogs = false;
31 Global::Global() :
32 EmptyString(),
33 OOCIdentifier('@')
38 Global::~Global()
43 std::string Global::sprintf(const char* format, ...)
45 Assert(format);
47 va_list args;
48 va_start(args, format);
49 vsnprintf(m_workspace, MAXSIZE, format, args);
50 va_end(args);
52 return m_workspace;
55 std::string Global::sprint(va_list& args, const char* format)
57 Assert(format);
59 vsnprintf(m_workspace, MAXSIZE, format, args);
60 return m_workspace;
63 void Global::printraw(const std::string& msg)
65 printf(msg.c_str());
68 void Global::printbug(const std::string& msg)
70 if(!g_printbugs)
71 return;
73 printraw("[BUG ] ");
74 printraw(msg);
77 void Global::printlog(const std::string& msg)
79 if(!g_printlogs)
80 return;
82 printraw("[LOG ] ");
83 printraw(msg);
86 void Global::printsql(const std::string& msg)
88 if(!g_printsql)
89 return;
91 printraw("[SQL ] ");
92 printraw(msg);
93 printraw("\n");
96 void Global::printexception(const std::string& msg)
98 printraw("[ERROR ] ");
99 printraw(msg);
102 void Global::printexception(const std::string& msg, const std::string& what)
104 printexception(msg);
106 printraw("[ MSG] ");
107 printraw(what);
110 void Global::printstatus(const std::string& msg)
112 if(!g_printstatus)
113 return;
115 printraw("[STATUS] ");
116 printraw(msg);
119 void Global::printmode(const std::string& msg)
121 printraw("[MODE ] ");
122 printraw(msg);