Minor changes here and there.
[aesalon.git] / include / util / StringToBool.h
blob994d001c37107bb54104fa9174a3e2b1bc87c2fc
1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file include/util/StringToBool.h
8 */
10 #ifndef AesalonUtil_StringToBool_H
11 #define AesalonUtil_StringToBool_H
13 #include <string.h>
15 /** C version of the StringToBool function. Returns the boolean representation of @a string.
17 inline int StringToBool(const char *string) {
18 if(string != NULL && (strcmp(string, "true") == 0 || strcmp(string, "True") == 0)) return 1;
19 return 0;
22 #ifdef __cplusplus
24 #include <string>
26 namespace Util {
28 /** C++ version of the StringToBool function. Returns the boolean representation of @a string. */
29 bool StringToBool(const std::string &string) {
30 if(string.length() == 0) return false;
31 return ::StringToBool(string.c_str()) == 1;
34 } // namespace Util
36 #endif
38 #endif