[Ika-commits] SF.net SVN: ika:[734] trunk/common
Status: Beta
Brought to you by:
the_speed_bump
From: <slu...@us...> - 2010-09-23 17:52:39
|
Revision: 734 http://ika.svn.sourceforge.net/ika/?rev=734&view=rev Author: sluimers Date: 2010-09-23 17:52:34 +0000 (Thu, 23 Sep 2010) Log Message: ----------- python 3.1 upgrade Modified Paths: -------------- trunk/common/configfile.cpp trunk/common/configfile.h Added Paths: ----------- trunk/common/debug.cpp trunk/common/debug.h Modified: trunk/common/configfile.cpp =================================================================== --- trunk/common/configfile.cpp 2010-09-23 17:51:21 UTC (rev 733) +++ trunk/common/configfile.cpp 2010-09-23 17:52:34 UTC (rev 734) @@ -42,11 +42,14 @@ return i->second; } -int CConfigFile::Int(const std::string& key) -{ +int CConfigFile::Int(const std::string& key) { return atoi((*this)[key].c_str()); } +long long CConfigFile::Long(const std::string& key) { + return atoi((*this)[key].c_str()); +} + void CConfigFile::Load(const char* fname) { File f; Modified: trunk/common/configfile.h =================================================================== --- trunk/common/configfile.h 2010-09-23 17:51:21 UTC (rev 733) +++ trunk/common/configfile.h 2010-09-23 17:52:34 UTC (rev 734) @@ -29,6 +29,7 @@ void Add(const std::string& key, const std::string& value); std::string operator [](const std::string& key); int Int(const std::string& key); + long long Long(const std::string& key); void Load(const char* fname); void Save(const char* fname); Added: trunk/common/debug.cpp =================================================================== --- trunk/common/debug.cpp (rev 0) +++ trunk/common/debug.cpp 2010-09-23 17:52:34 UTC (rev 734) @@ -0,0 +1,7 @@ +#include "debug.h" + +string int2string(const int& number) { + ostringstream oss; + oss << number; + return oss.str(); +} Added: trunk/common/debug.h =================================================================== --- trunk/common/debug.h (rev 0) +++ trunk/common/debug.h 2010-09-23 17:52:34 UTC (rev 734) @@ -0,0 +1,39 @@ +#define DEBUG + +#ifndef DEBUG_H +#define DEBUG_H + +#include <iostream> +#include <string> +#include <sstream> +using namespace std; + +#ifdef DEBUG + +/* just a helper for code location */ +#define PyDEBUGSTR (string("print('debug: ") + __FILE__ + ":" + int2string(__LINE__) + "')").c_str() +#define LOC cout << "debug:" << __FILE__ << ":" << __LINE__ << " "; +#define PyLOC PyRun_SimpleString(PyDEBUGSTR); + +/* macro for general debug print statements. */ +#define DEBUG_PRINT(text) LOC cout << text << endl; + +/* macro that prints a variable name and its actual value */ +#define DEBUG_VAR(text) LOC cout << (#text) << "=" << text << endl; + +/* python macro that prints a variable name and its actual value */ +#define DEBUG_PyRUN(text) PyLOC PyRun_SimpleString(text); + +/* python macro that prints an error */ +#define DEBUG_PyERR(type, text) PyLOC PyErr_SetString(type, text); + +#else + +/* when debug isn't defined all the macro calls do absolutely nothing for C++ debugging code and the same without helper for python debugging code */ +#define DEBUG_PRINT(text) +#define DEBUG_VAR(text) +#define DEBUG_PyRUN(text) +#define DEBUG_PyERR(type, text) PyErr_SetString(type, text); + +#endif /* DEBUG */ +#endif /* DEBUG_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |