Modernize debugging.

This commit is contained in:
Roman Telezhynskyi 2021-11-23 11:28:54 +02:00
parent 642fbe815d
commit a8d8fa0946
5 changed files with 18 additions and 18 deletions

View File

@ -128,9 +128,9 @@ BAD_READ_ENTITIES, /*!< error in entities read process. */
BAD_READ_OBJECTS /*!< error in objects read process. */ BAD_READ_OBJECTS /*!< error in objects read process. */
}; };
enum DBG_LEVEL { enum class DebugLevel {
NONE, None,
DEBUG Debug
}; };
//! Special codes for colors //! Special codes for colors

View File

@ -59,10 +59,10 @@ DRW_dbg::DRW_dbg() :
prClass(std::make_unique<print_none>()) prClass(std::make_unique<print_none>())
{} {}
void DRW_dbg::setLevel(LEVEL lvl){ void DRW_dbg::setLevel(Level lvl){
level = lvl; level = lvl;
switch (level){ switch (level){
case DEBUG: case Level::Debug:
prClass = std::make_unique<print_debug>(); prClass = std::make_unique<print_debug>();
break; break;
default: default:
@ -70,7 +70,7 @@ void DRW_dbg::setLevel(LEVEL lvl){
} }
} }
DRW_dbg::LEVEL DRW_dbg::getLevel() const{ DRW_dbg::Level DRW_dbg::getLevel() const{
return level; return level;
} }

View File

@ -32,12 +32,12 @@ class print_none;
class DRW_dbg { class DRW_dbg {
public: public:
enum LEVEL { enum class Level {
NONE, None,
DEBUG Debug
}; };
void setLevel(LEVEL lvl); void setLevel(Level lvl);
LEVEL getLevel() const; Level getLevel() const;
static DRW_dbg *getInstance(); static DRW_dbg *getInstance();
void print(const std::string &s); void print(const std::string &s);
void print(int i); void print(int i);
@ -56,7 +56,7 @@ private:
DRW_dbg(); DRW_dbg();
~DRW_dbg(); ~DRW_dbg();
static DRW_dbg *instance; static DRW_dbg *instance;
LEVEL level{NONE}; Level level{Level::None};
std::ios_base::fmtflags flags{std::cerr.flags()}; std::ios_base::fmtflags flags{std::cerr.flags()};
std::unique_ptr<print_none> prClass; std::unique_ptr<print_none> prClass;
}; };

View File

@ -54,7 +54,7 @@ dxfRW::dxfRW(const char* name)
imageDef(), imageDef(),
currHandle() currHandle()
{ {
DRW_DBGSL(DRW_dbg::NONE); DRW_DBGSL(DRW_dbg::Level::None);
} }
dxfRW::~dxfRW(){ dxfRW::~dxfRW(){
@ -68,13 +68,13 @@ dxfRW::~dxfRW(){
imageDef.clear(); imageDef.clear();
} }
void dxfRW::setDebug(DRW::DBG_LEVEL lvl){ void dxfRW::setDebug(DRW::DebugLevel lvl){
switch (lvl){ switch (lvl){
case DRW::DEBUG: case DRW::DebugLevel::Debug:
DRW_DBGSL(DRW_dbg::DEBUG); DRW_DBGSL(DRW_dbg::Level::Debug);
break; break;
default: default:
DRW_DBGSL(DRW_dbg::NONE); DRW_DBGSL(DRW_dbg::Level::None);
} }
} }

View File

@ -28,7 +28,7 @@ class dxfRW {
public: public:
explicit dxfRW(const char* name); explicit dxfRW(const char* name);
~dxfRW(); ~dxfRW();
static void setDebug(DRW::DBG_LEVEL lvl); static void setDebug(DRW::DebugLevel lvl);
/// reads the file specified in constructor /// reads the file specified in constructor
/*! /*!
* An interface must be provided. It is used by the class to signal various * An interface must be provided. It is used by the class to signal various