summaryrefslogtreecommitdiffstats
path: root/kcalc/knumber
diff options
context:
space:
mode:
Diffstat (limited to 'kcalc/knumber')
-rw-r--r--kcalc/knumber/knumber.cpp54
-rw-r--r--kcalc/knumber/knumber.h8
-rw-r--r--kcalc/knumber/knumber_priv.cpp40
-rw-r--r--kcalc/knumber/knumber_priv.h18
-rw-r--r--kcalc/knumber/tests/knumbertest.cpp22
5 files changed, 71 insertions, 71 deletions
diff --git a/kcalc/knumber/knumber.cpp b/kcalc/knumber/knumber.cpp
index d282b26..80bae1f 100644
--- a/kcalc/knumber/knumber.cpp
+++ b/kcalc/knumber/knumber.cpp
@@ -22,8 +22,8 @@
#include <config.h>
-#include <qregexp.h>
-#include <qstring.h>
+#include <tqregexp.h>
+#include <tqstring.h>
#include "knumber.h"
@@ -94,17 +94,17 @@ KNumber::KNumber(KNumber const & num)
}
-KNumber::KNumber(QString const & num)
+KNumber::KNumber(TQString const & num)
{
- if (QRegExp("^(inf|-inf|nan)$").exactMatch(num))
+ if (TQRegExp("^(inf|-inf|nan)$").exactMatch(num))
_num = new _knumerror(num);
- else if (QRegExp("^[+-]?\\d+$").exactMatch(num))
+ else if (TQRegExp("^[+-]?\\d+$").exactMatch(num))
_num = new _knuminteger(num);
- else if (QRegExp("^[+-]?\\d+/\\d+$").exactMatch(num)) {
+ else if (TQRegExp("^[+-]?\\d+/\\d+$").exactMatch(num)) {
_num = new _knumfraction(num);
simplifyRational();
}
- else if (QRegExp("^[+-]?\\d+(\\.\\d*)?(e[+-]?\\d+)?$").exactMatch(num))
+ else if (TQRegExp("^[+-]?\\d+(\\.\\d*)?(e[+-]?\\d+)?$").exactMatch(num))
if (_fraction_input == true) {
_num = new _knumfraction(num);
simplifyRational();
@@ -228,7 +228,7 @@ KNumber & KNumber::operator -=(KNumber const &arg)
}
// increase the digit at 'position' by one
-static void _inc_by_one(QString &str, int position)
+static void _inc_by_one(TQString &str, int position)
{
for (int i = position; i >= 0; i--)
{
@@ -274,7 +274,7 @@ static void _inc_by_one(QString &str, int position)
}
// Cut off if more digits in fractional part than 'precision'
-static void _round(QString &str, int precision)
+static void _round(TQString &str, int precision)
{
int decimalSymbolPos = str.find('.');
@@ -287,7 +287,7 @@ static void _round(QString &str, int precision)
}
// fill up with more than enough zeroes (in case fractional part too short)
- str.append(QString().fill('0', precision));
+ str.append(TQString().fill('0', precision));
// Now decide whether to round up or down
char last_char = str[decimalSymbolPos + precision + 1].latin1();
@@ -319,11 +319,11 @@ static void _round(QString &str, int precision)
if (precision == 0) str = str.section('.', 0, 0);
}
-static QString roundNumber(const QString &numStr, int precision)
+static TQString roundNumber(const TQString &numStr, int precision)
{
- QString tmpString = numStr;
+ TQString tmpString = numStr;
if (precision < 0 ||
- ! QRegExp("^[+-]?\\d+(\\.\\d+)*(e[+-]?\\d+)?$").exactMatch(tmpString))
+ ! TQRegExp("^[+-]?\\d+(\\.\\d+)*(e[+-]?\\d+)?$").exactMatch(tmpString))
return numStr;
@@ -333,12 +333,12 @@ static QString roundNumber(const QString &numStr, int precision)
// Split off exponential part (including 'e'-symbol)
- QString mantString = tmpString.section('e', 0, 0,
- QString::SectionCaseInsensitiveSeps);
- QString expString = tmpString.section('e', 1, 1,
- QString::SectionCaseInsensitiveSeps |
- QString::SectionIncludeLeadingSep);
- if (expString.length() == 1) expString = QString();
+ TQString mantString = tmpString.section('e', 0, 0,
+ TQString::SectionCaseInsensitiveSeps);
+ TQString expString = tmpString.section('e', 1, 1,
+ TQString::SectionCaseInsensitiveSeps |
+ TQString::SectionIncludeLeadingSep);
+ if (expString.length() == 1) expString = TQString();
_round(mantString, precision);
@@ -349,9 +349,9 @@ static QString roundNumber(const QString &numStr, int precision)
}
-QString const KNumber::toQString(int width, int prec) const
+TQString const KNumber::toQString(int width, int prec) const
{
- QString tmp_str;
+ TQString tmp_str;
if (*this == Zero) // important to avoid infinite loops below
return "0";
@@ -363,7 +363,7 @@ QString const KNumber::toQString(int width, int prec) const
tmp_str = (KNumber("1.0")*(*this)).toQString(width, -1);
_fraction_input = tmp_bool;
} else
- tmp_str = QString(_num->ascii());
+ tmp_str = TQString(_num->ascii());
break;
case FractionType:
if (_float_output) {
@@ -376,13 +376,13 @@ QString const KNumber::toQString(int width, int prec) const
// split off integer part
KNumber int_part = this->integerPart();
if (int_part == Zero)
- tmp_str = QString(_num->ascii());
+ tmp_str = TQString(_num->ascii());
else if (int_part < Zero)
tmp_str = int_part.toQString() + " " + (int_part - *this)._num->ascii();
else
tmp_str = int_part.toQString() + " " + (*this - int_part)._num->ascii();
} else
- tmp_str = QString(_num->ascii());
+ tmp_str = TQString(_num->ascii());
if (width > 0 && tmp_str.length() > width) {
//result needs to be cut-off
@@ -396,13 +396,13 @@ QString const KNumber::toQString(int width, int prec) const
break;
case FloatType:
if (width > 0)
- tmp_str = QString(_num->ascii(width));
+ tmp_str = TQString(_num->ascii(width));
else
// rough estimate for maximal decimal precision (10^3 = 2^10)
- tmp_str = QString(_num->ascii(3*mpf_get_default_prec()/10));
+ tmp_str = TQString(_num->ascii(3*mpf_get_default_prec()/10));
break;
default:
- return QString(_num->ascii());
+ return TQString(_num->ascii());
}
if (prec >= 0)
diff --git a/kcalc/knumber/knumber.h b/kcalc/knumber/knumber.h
index 489a579..b0b4444 100644
--- a/kcalc/knumber/knumber.h
+++ b/kcalc/knumber/knumber.h
@@ -115,7 +115,7 @@ class KDE_EXPORT KNumber
KNumber(KNumber const & num);
- KNumber(QString const & num);
+ KNumber(TQString const & num);
~KNumber()
{
@@ -142,7 +142,7 @@ class KDE_EXPORT KNumber
static void setDefaultFloatOutput(bool flag);
/**
- * Set whether a number constructed from a QString should be
+ * Set whether a number constructed from a TQString should be
* initialized as a fraction or as a float, e.g. "1.01" would be
* treated as 101/100, if this flag is set to true.
*
@@ -168,7 +168,7 @@ class KDE_EXPORT KNumber
static void setSplitoffIntegerForFractionOutput(bool flag);
/**
- * Return a QString representing the KNumber.
+ * Return a TQString representing the KNumber.
*
* @param width This number specifies the maximal length of the
* output, before the method switches to exponential notation and
@@ -179,7 +179,7 @@ class KDE_EXPORT KNumber
* is ignored.
*
*/
- QString const toQString(int width = -1, int prec = -1) const;
+ TQString const toQString(int width = -1, int prec = -1) const;
/**
* Compute the absolute value, i.e. @p x.abs() returns the value
diff --git a/kcalc/knumber/knumber_priv.cpp b/kcalc/knumber/knumber_priv.cpp
index 1326d44..56de7d3 100644
--- a/kcalc/knumber/knumber_priv.cpp
+++ b/kcalc/knumber/knumber_priv.cpp
@@ -23,8 +23,8 @@
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
-#include <qregexp.h>
-#include <qstring.h>
+#include <tqregexp.h>
+#include <tqstring.h>
#include "knumber_priv.h"
@@ -115,7 +115,7 @@ _knumfloat::_knumfloat(_knumber const & num)
-_knumerror::_knumerror(QString const & num)
+_knumerror::_knumerror(TQString const & num)
{
if (num == "nan")
_error = UndefinedNumber;
@@ -125,20 +125,20 @@ _knumerror::_knumerror(QString const & num)
_error = MinusInfinity;
}
-_knuminteger::_knuminteger(QString const & num)
+_knuminteger::_knuminteger(TQString const & num)
{
mpz_init(_mpz);
mpz_set_str(_mpz, num.ascii(), 10);
}
-_knumfraction::_knumfraction(QString const & num)
+_knumfraction::_knumfraction(TQString const & num)
{
mpq_init(_mpq);
- if (QRegExp("^[+-]?\\d+(\\.\\d*)?(e[+-]?\\d+)?$").exactMatch(num)) {
+ if (TQRegExp("^[+-]?\\d+(\\.\\d*)?(e[+-]?\\d+)?$").exactMatch(num)) {
// my hand-made conversion is terrible
// first me convert the mantissa
unsigned long int digits_after_dot = ((num.section( '.', 1, 1)).section('e', 0, 0)).length();
- QString tmp_num = num.section('e', 0, 0).remove('.');
+ TQString tmp_num = num.section('e', 0, 0).remove('.');
mpq_set_str(_mpq, tmp_num.ascii(), 10);
mpz_t tmp_int;
mpz_init(tmp_int);
@@ -163,7 +163,7 @@ _knumfraction::_knumfraction(QString const & num)
mpq_canonicalize(_mpq);
}
-_knumfloat::_knumfloat(QString const & num)
+_knumfloat::_knumfloat(TQString const & num)
{
mpf_init(_mpf);
mpf_set_str(_mpf, num.ascii(), 10);
@@ -178,51 +178,51 @@ _knuminteger const & _knuminteger::operator = (_knuminteger const & num)
return *this;
}
-QString const _knumerror::ascii(int prec) const
+TQString const _knumerror::ascii(int prec) const
{
static_cast<void>(prec);
switch(_error) {
case UndefinedNumber:
- return QString("nan");
+ return TQString("nan");
case Infinity:
- return QString("inf");
+ return TQString("inf");
case MinusInfinity:
- return QString("-inf");
+ return TQString("-inf");
default:
- return QString::null;
+ return TQString::null;
}
}
-QString const _knuminteger::ascii(int prec) const
+TQString const _knuminteger::ascii(int prec) const
{
static_cast<void>(prec);
char *tmp_ptr;
gmp_asprintf(&tmp_ptr, "%Zd", _mpz);
- QString ret_str = tmp_ptr;
+ TQString ret_str = tmp_ptr;
free(tmp_ptr);
return ret_str;
}
-QString const _knumfraction::ascii(int prec) const
+TQString const _knumfraction::ascii(int prec) const
{
static_cast<void>(prec);
char *tmp_ptr = mpq_get_str(0, 10, _mpq);
- QString ret_str = tmp_ptr;
+ TQString ret_str = tmp_ptr;
free(tmp_ptr);
return ret_str;
}
-QString const _knumfloat::ascii(int prec) const
+TQString const _knumfloat::ascii(int prec) const
{
- QString ret_str;
+ TQString ret_str;
char *tmp_ptr;
if (prec > 0)
- gmp_asprintf(&tmp_ptr, ("%." + QString().setNum(prec) + "Fg").ascii(), _mpf);
+ gmp_asprintf(&tmp_ptr, ("%." + TQString().setNum(prec) + "Fg").ascii(), _mpf);
else
gmp_asprintf(&tmp_ptr, "%Fg", _mpf);
diff --git a/kcalc/knumber/knumber_priv.h b/kcalc/knumber/knumber_priv.h
index 7dd58a6..cb6b13b 100644
--- a/kcalc/knumber/knumber_priv.h
+++ b/kcalc/knumber/knumber_priv.h
@@ -47,7 +47,7 @@ class _knumber
virtual NumType type(void) const = 0;
- virtual QString const ascii(int prec = -1) const = 0;
+ virtual TQString const ascii(int prec = -1) const = 0;
virtual _knumber * abs(void) const = 0;
virtual _knumber * intPart(void) const = 0;
@@ -79,7 +79,7 @@ class _knumerror : public _knumber
_knumerror(_knumber const & num);
- _knumerror(const QString & num);
+ _knumerror(const TQString & num);
//virtual ~_knumerror() { }
@@ -92,7 +92,7 @@ class _knumerror : public _knumber
virtual NumType type(void) const {return SpecialType;}
- virtual QString const ascii(int prec = -1) const;
+ virtual TQString const ascii(int prec = -1) const;
virtual _knumber * abs(void) const;
virtual _knumber * intPart(void) const;
@@ -150,7 +150,7 @@ class _knuminteger : public _knumber
_knuminteger(_knumber const & num);
- _knuminteger(const QString & num);
+ _knuminteger(const TQString & num);
virtual ~_knuminteger()
{
@@ -166,7 +166,7 @@ class _knuminteger : public _knumber
virtual NumType type(void) const {return IntegerType;}
- virtual QString const ascii(int prec = -1) const;
+ virtual TQString const ascii(int prec = -1) const;
virtual _knumber * abs(void) const;
virtual _knumber * intPart(void) const;
@@ -213,7 +213,7 @@ class _knumfraction : public _knumber
_knumfraction(_knumber const & num);
- _knumfraction(QString const & num);
+ _knumfraction(TQString const & num);
virtual ~_knumfraction()
{
@@ -227,7 +227,7 @@ class _knumfraction : public _knumber
virtual NumType type(void) const {return FractionType;}
- virtual QString const ascii(int prec = -1) const;
+ virtual TQString const ascii(int prec = -1) const;
bool isInteger(void) const;
@@ -267,7 +267,7 @@ class _knumfloat : public _knumber
_knumfloat(_knumber const & num);
- _knumfloat(QString const & num);
+ _knumfloat(TQString const & num);
virtual ~_knumfloat()
{
@@ -281,7 +281,7 @@ class _knumfloat : public _knumber
virtual NumType type(void) const {return FloatType;}
- virtual QString const ascii(int prec = -1) const;
+ virtual TQString const ascii(int prec = -1) const;
virtual _knumber * abs(void) const;
virtual _knumber * intPart(void) const;
diff --git a/kcalc/knumber/tests/knumbertest.cpp b/kcalc/knumber/tests/knumbertest.cpp
index 814410e..e34d94d 100644
--- a/kcalc/knumber/tests/knumbertest.cpp
+++ b/kcalc/knumber/tests/knumbertest.cpp
@@ -6,29 +6,29 @@
#include <stdio.h>
#include <iostream>
-#include <qstring.h>
+#include <tqstring.h>
#include "knumbertest.h"
-QString const numtypeToString(KNumber::NumType arg)
+TQString const numtypeToString(KNumber::NumType arg)
{
switch(arg) {
case KNumber::SpecialType:
- return QString("Special");
+ return TQString("Special");
case KNumber::IntegerType:
- return QString("Integer");
+ return TQString("Integer");
case KNumber::FractionType:
- return QString("Fraction");
+ return TQString("Fraction");
case KNumber::FloatType:
- return QString("Float");
+ return TQString("Float");
default:
- return QString("Unknown:") + QString::number(static_cast<int>(arg));
+ return TQString("Unknown:") + TQString::number(static_cast<int>(arg));
}
}
-void checkResult(QString const &string, KNumber const & result,
- QString const & desired_string, KNumber::NumType desired)
+void checkResult(TQString const &string, KNumber const & result,
+ TQString const & desired_string, KNumber::NumType desired)
{
std::cout << "Testing result of: " << string.ascii() <<
" should give " << desired_string.ascii() << " and gives " <<
@@ -47,7 +47,7 @@ void checkResult(QString const &string, KNumber const & result,
exit(1);
}
-void checkTruth(QString const &string, bool computation,
+void checkTruth(TQString const &string, bool computation,
bool desired_result)
{
std::cout << "Testing truth of: " << string.ascii() <<
@@ -64,7 +64,7 @@ void checkTruth(QString const &string, bool computation,
}
-void checkType(QString const &string, KNumber::NumType test_arg,
+void checkType(TQString const &string, KNumber::NumType test_arg,
KNumber::NumType desired)
{
std::cout << "Testing type of: " << string.ascii() << " should give " <<