author | ar <ar> | 2004-05-21 21:03:21 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-21 21:03:21 (UTC) |
commit | e7810bdfec718c3364e31c2d32357ec0fd2fda77 (patch) (side-by-side diff) | |
tree | 2e5e4028580ca4fce98dc56567731b4cdce4b74b /noncore/tools/calc2/engine.cpp | |
parent | 37294c41a902eab36427372bdda31b4462fd73ca (diff) | |
download | opie-e7810bdfec718c3364e31c2d32357ec0fd2fda77.zip opie-e7810bdfec718c3364e31c2d32357ec0fd2fda77.tar.gz opie-e7810bdfec718c3364e31c2d32357ec0fd2fda77.tar.bz2 |
- convert qDebug to odebug
Diffstat (limited to 'noncore/tools/calc2/engine.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/calc2/engine.cpp | 133 |
1 files changed, 70 insertions, 63 deletions
diff --git a/noncore/tools/calc2/engine.cpp b/noncore/tools/calc2/engine.cpp index e843e29..74cd701 100644 --- a/noncore/tools/calc2/engine.cpp +++ b/noncore/tools/calc2/engine.cpp @@ -20,8 +20,15 @@ #include "engine.h" + +/* OPIE */ +#include <opie2/odebug.h> + +/* QT */ #include <qstring.h> -#include <math.h> #include <qlcdnumber.h> +/* STD */ +#include <math.h> + Data Engine::evalStack (Data num, bool inbrace = FALSE) { @@ -35,6 +42,6 @@ Data Engine::evalStack (Data num, bool inbrace = FALSE) // Check this ops prec vs next ops prec if (!stack.isEmpty ()) - if (i->precedence <= stack.top()->precedence) - i->acc = evalStack (i->acc, inbrace); + if (i->precedence <= stack.top()->precedence) + i->acc = evalStack (i->acc, inbrace); // Evaluate this instruction @@ -43,8 +50,8 @@ Data Engine::evalStack (Data num, bool inbrace = FALSE) // Error-check ( change this to work for all types ) if (isnan (num.dbl) || isinf (num.dbl)) { - qDebug ("bad result from operation"); - state = sError; - clearData(&num); - return num; + odebug << "bad result from operation" << oendl; + state = sError; + clearData(&num); + return num; } } @@ -90,20 +97,20 @@ void Engine::pushValue (char v) bool ok = FALSE; switch (currentRep) { - case rDouble: - displayString.append(v); - num.dbl=displayString.toDouble(&ok); - break; - case rFraction: - break; - default: - displayString.append(v); - num.i=displayString.toInt(&ok, calcBase()); + case rDouble: + displayString.append(v); + num.dbl=displayString.toDouble(&ok); + break; + case rFraction: + break; + default: + displayString.append(v); + num.i=displayString.toInt(&ok, calcBase()); }; if (!ok) { - state = sError; - odebug << "pushValue() - num->string conversion" << oendl; + state = sError; + odebug << "pushValue() - num->string conversion" << oendl; } else { - const QString constString = displayString; - emit(display(constString)); + const QString constString = displayString; + emit(display(constString)); }; @@ -114,5 +121,5 @@ void Engine::pushValue (char v) pushValue (v); } else if (state == sError) { - qDebug ("in error state"); + odebug << "in error state" << oendl; return; } @@ -123,22 +130,22 @@ void Engine::del () bool ok; switch (currentRep) { - case rDouble: - displayString.truncate(displayString.length()); - num.dbl=displayString.toDouble(&ok); - break; - case rFraction: - odebug << "not available" << oendl; - break; - default: - displayString.truncate(displayString.length()); - num.i = displayString.toInt(&ok, calcBase()); + case rDouble: + displayString.truncate(displayString.length()); + num.dbl=displayString.toDouble(&ok); + break; + case rFraction: + odebug << "not available" << oendl; + break; + default: + displayString.truncate(displayString.length()); + num.i = displayString.toInt(&ok, calcBase()); }; if (!ok) { - state = sError; - odebug << "del() - num->string conversion" << oendl; + state = sError; + odebug << "del() - num->string conversion" << oendl; } else { - const QString constString = displayString; - emit(display(constString)); + const QString constString = displayString; + emit(display(constString)); }; } @@ -146,13 +153,13 @@ void Engine::del () void Engine::displayData(Data d) { switch (currentRep) { - case rDouble: - displayString.setNum(d.dbl); - break; - case rFraction: - odebug << "fractional display not yet impl" << oendl; - break; - default: - displayString.setNum(d.i, calcBase()); - break; + case rDouble: + displayString.setNum(d.dbl); + break; + case rFraction: + odebug << "fractional display not yet impl" << oendl; + break; + default: + displayString.setNum(d.i, calcBase()); + break; }; const QString constString= displayString; @@ -163,16 +170,16 @@ void Engine::displayData(Data d) { int Engine::calcBase () { switch (currentRep) { - case rBin: - return 2; - case rOct: - return 8; - case rDec: - return 10; - case rHex: - return 16; - default: - state = sError; - odebug << "Error - attempt to calc base for non-integer" << oendl; - return 10; + case rBin: + return 2; + case rOct: + return 8; + case rDec: + return 10; + case rHex: + return 16; + default: + state = sError; + odebug << "Error - attempt to calc base for non-integer" << oendl; + return 10; }; } @@ -181,13 +188,13 @@ int Engine::calcBase () { class iOpenBrace:public Instruction { public: - iOpenBrace (Engine *e):Instruction (100) {engine = e;}; - ~iOpenBrace () {}; + iOpenBrace (Engine *e):Instruction (100) {engine = e;}; + ~iOpenBrace () {}; - Data eval (Data num) { - engine->decBraces(); - return num; - }; + Data eval (Data num) { + engine->decBraces(); + return num; + }; private: - Engine *engine; + Engine *engine; }; |