Skip to content

Commit

Permalink
Rename "DEBUG" enum
Browse files Browse the repository at this point in the history
This was required for the QGIS fork, where "DEBUG" is a macro set by
Qt. (I've upgraded it to a enum class while I'm at it)
  • Loading branch information
nyalldawson committed Aug 15, 2021
1 parent 4022239 commit 8caa0c1
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 32 deletions.
6 changes: 3 additions & 3 deletions src/drw_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ BAD_READ_ENTITIES, /*!< error in entities read process. */
BAD_READ_OBJECTS /*!< error in objects read process. */
};

enum DBG_LEVEL {
NONE,
DEBUG
enum class DebugLevel {
None,
Debug
};

//! Special codes for colors
Expand Down
4 changes: 2 additions & 2 deletions src/drw_entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ bool DRW_LWPolyline::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
}
}
}
if (DRW_DBGGL == DRW_dbg::DEBUG){
if (DRW_DBGGL == DRW_dbg::Level::Debug){
DRW_DBG("\nVertex list: ");
for (auto& pv: vertlist) {
DRW_DBG("\n x: "); DRW_DBG(pv->x); DRW_DBG(" y: "); DRW_DBG(pv->y); DRW_DBG(" bulge: "); DRW_DBG(pv->bulge);
Expand Down Expand Up @@ -2155,7 +2155,7 @@ bool DRW_Spline::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
for (dint32 i= 0; i<nfit; ++i)
fitlist.push_back(std::make_shared<DRW_Coord>(buf->get3BitDouble()));

if (DRW_DBGGL == DRW_dbg::DEBUG){
if (DRW_DBGGL == DRW_dbg::Level::Debug){
DRW_DBG("\nknots list: ");
for (auto const& v: knotslist) {
DRW_DBG("\n"); DRW_DBG(v);
Expand Down
2 changes: 1 addition & 1 deletion src/drw_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,7 @@ bool DRW_Header::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbuf
DRW_DBG("\nstring buf position: "); DRW_DBG(buf->getPosition());
DRW_DBG(" string buf bit position: "); DRW_DBG(buf->getBitPos());

if (DRW_DBGGL == DRW_dbg::DEBUG){
if (DRW_DBGGL == DRW_dbg::Level::Debug){
for (std::map<std::string,DRW_Variant*>::iterator it=vars.begin(); it!=vars.end(); ++it){
DRW_DBG("\n"); DRW_DBG(it->first); DRW_DBG(": ");
switch (it->second->type()){
Expand Down
9 changes: 5 additions & 4 deletions src/intern/drw_dbg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,19 @@ DRW_dbg::DRW_dbg(){
prClass.reset( new print_none );
}

void DRW_dbg::setLevel(LEVEL lvl){
void DRW_dbg::setLevel(Level lvl){
level = lvl;
switch (level){
case DEBUG:
case Level::Debug:
prClass.reset(new print_debug);
break;
default:
case Level::None:
prClass.reset(new print_none);
break;
}
}

DRW_dbg::LEVEL DRW_dbg::getLevel(){
DRW_dbg::Level DRW_dbg::getLevel(){
return level;
}

Expand Down
12 changes: 6 additions & 6 deletions src/intern/drw_dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class print_none;

class DRW_dbg {
public:
enum LEVEL {
NONE,
DEBUG
enum class Level {
None,
Debug
};
void setLevel(LEVEL lvl);
LEVEL getLevel();
void setLevel(Level lvl);
Level getLevel();
static DRW_dbg *getInstance();
void print(const std::string& s);
void print(int i);
Expand All @@ -53,7 +53,7 @@ class DRW_dbg {
private:
DRW_dbg();
static DRW_dbg *instance;
LEVEL level{NONE};
Level level{Level::None};
std::ios_base::fmtflags flags{std::cerr.flags()};
std::unique_ptr<print_none> prClass;
};
Expand Down
4 changes: 2 additions & 2 deletions src/intern/dwgreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ bool dwgReader::readDwgTables(DRW_Header& hdr, dwgBuffer *dbuf) {
}

//RLZ: parse remaining object controls, TODO: implement all
if (DRW_DBGGL == DRW_dbg::DEBUG){
if (DRW_DBGGL == DRW_dbg::Level::Debug){
mit = ObjectMap.find(hdr.viewCtrl);
if (mit==ObjectMap.end()) {
DRW_DBG("\nWARNING: View control not found\n");
Expand Down Expand Up @@ -1182,7 +1182,7 @@ bool dwgReader::readDwgObjects(DRW_Interface& intfa, dwgBuffer *dbuf){
if (ret)
ret = ret2;
}
if (DRW_DBGGL == DRW_dbg::DEBUG) {
if (DRW_DBGGL == DRW_dbg::Level::Debug) {
for (std::map<duint32, objHandle>::iterator it=remainingMap.begin(); it != remainingMap.end(); ++it){
DRW_DBG("\nnum.# "); DRW_DBG(i++); DRW_DBG(" Remaining object Handle, loc, type= "); DRW_DBG(it->first);
DRW_DBG(" "); DRW_DBG(it->second.loc); DRW_DBG(" "); DRW_DBG(it->second.type);
Expand Down
12 changes: 6 additions & 6 deletions src/libdwgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@
dwgR::dwgR(const char* name)
: fileName{ name }
{
DRW_DBGSL(DRW_dbg::NONE);
DRW_DBGSL(DRW_dbg::Level::None);
}

dwgR::~dwgR() = default;

void dwgR::setDebug(DRW::DBG_LEVEL lvl){
void dwgR::setDebug(DRW::DebugLevel lvl){
switch (lvl){
case DRW::DEBUG:
DRW_DBGSL(DRW_dbg::DEBUG);
case DRW::DebugLevel::Debug:
DRW_DBGSL(DRW_dbg::Level::Debug);
break;
default:
DRW_DBGSL(DRW_dbg::NONE);
case DRW::DebugLevel::None:
DRW_DBGSL(DRW_dbg::Level::None);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libdwgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class dwgR {
DRW::Version getVersion(){return version;}
DRW::error getError(){return error;}
bool testReader();
void setDebug(DRW::DBG_LEVEL lvl);
void setDebug(DRW::DebugLevel lvl);

private:
bool openFile(std::ifstream *filestr);
Expand Down
12 changes: 6 additions & 6 deletions src/libdxfrw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
};*/

dxfRW::dxfRW(const char* name){
DRW_DBGSL(DRW_dbg::NONE);
DRW_DBGSL(DRW_dbg::Level::None);
fileName = name;
reader = NULL;
writer = NULL;
Expand All @@ -51,13 +51,13 @@ dxfRW::~dxfRW(){
imageDef.clear();
}

void dxfRW::setDebug(DRW::DBG_LEVEL lvl){
void dxfRW::setDebug(DRW::DebugLevel lvl){
switch (lvl){
case DRW::DEBUG:
DRW_DBGSL(DRW_dbg::DEBUG);
case DRW::DebugLevel::Debug:
DRW_DBGSL(DRW_dbg::Level::Debug);
break;
default:
DRW_DBGSL(DRW_dbg::NONE);
case DRW::DebugLevel::None:
DRW_DBGSL(DRW_dbg::Level::None);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libdxfrw.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class dxfRW {
public:
dxfRW(const char* name);
~dxfRW();
void setDebug(DRW::DBG_LEVEL lvl);
void setDebug(DRW::DebugLevel lvl);
/// reads the file specified in constructor
/*!
* An interface must be provided. It is used by the class to signal various
Expand Down

0 comments on commit 8caa0c1

Please sign in to comment.