[rkward-cvs] SF.net SVN: rkward: [749] trunk/rkward/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Wed Sep 20 14:35:06 UTC 2006
Revision: 749
http://svn.sourceforge.net/rkward/?rev=749&view=rev
Author: tfry
Date: 2006-09-20 07:34:59 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
Cleanup: Move na_char and unknown_char from RKGlobals to RKVariable
Modified Paths:
--------------
trunk/rkward/rkward/core/rkvariable.cpp
trunk/rkward/rkward/core/rkvariable.h
trunk/rkward/rkward/rkglobals.cpp
trunk/rkward/rkward/rkglobals.h
Modified: trunk/rkward/rkward/core/rkvariable.cpp
===================================================================
--- trunk/rkward/rkward/core/rkvariable.cpp 2006-09-20 14:20:27 UTC (rev 748)
+++ trunk/rkward/rkward/core/rkvariable.cpp 2006-09-20 14:34:59 UTC (rev 749)
@@ -38,6 +38,9 @@
#include "../debug.h"
+QString *RKVariable::na_char = new QString ("");
+QString *RKVariable::unknown_char = new QString ("?");
+
RKVariable::RKVariable (RContainerObject *parent, const QString &name) : RObject (parent, name) {
RK_TRACE (OBJECTS);
type = Variable;
@@ -217,7 +220,7 @@
void RKVariable::deleteStringData (int row) {
RK_ASSERT (myData ());
- if (myData ()->cell_string_data[row] && (myData ()->cell_string_data[row] != RKGlobals::na_char) && (myData ()->cell_string_data[row] != RKGlobals::unknown_char)) {
+ if (myData ()->cell_string_data[row] && (myData ()->cell_string_data[row] != na_char) && (myData ()->cell_string_data[row] != unknown_char)) {
delete myData ()->cell_string_data[row];
if (getVarType () != String) {
myData ()->invalid_count--;
@@ -254,7 +257,7 @@
if (to_empty) {
for (int row=0; row < getLength (); ++row) {
- myData ()->cell_string_data[row] = RKGlobals::na_char;
+ myData ()->cell_string_data[row] = na_char;
myData ()->cell_double_data[row] = RKGlobals::na_double;
}
} else {
@@ -399,7 +402,7 @@
delete [] (myData ()->cell_double_data);
}
for (int i=myData ()->allocated_length; i < target; ++i) {
- new_string_data[i] = RKGlobals::unknown_char;
+ new_string_data[i] = unknown_char;
}
myData ()->cell_string_data = new_string_data;
@@ -427,7 +430,7 @@
QString RKVariable::getText (int row) {
if (row >= getLength ()) {
RK_ASSERT (false);
- return (*RKGlobals::unknown_char);
+ return (*unknown_char);
}
if (getVarType () == String) {
return (*(myData ()->cell_string_data[row]));
@@ -464,13 +467,13 @@
if (getVarType () == String) {
if (text.isNull ()) {
- myData ()->cell_string_data[row] = RKGlobals::na_char;
+ myData ()->cell_string_data[row] = na_char;
} else {
myData ()->cell_string_data[row] = new QString (text);
}
} else if (getVarType () == Factor) {
if (text.isNull ()) {
- myData ()->cell_string_data[row] = RKGlobals::na_char;
+ myData ()->cell_string_data[row] = na_char;
} else if (myData ()->value_labels && myData ()->value_labels->contains (text)) {
myData ()->cell_double_data[row] = text.toInt ();
} else {
@@ -483,7 +486,7 @@
myData ()->cell_double_data[row] = text.toDouble (&ok);
if (!ok) {
if (text.isNull ()) {
- myData ()->cell_string_data[row] = RKGlobals::na_char;
+ myData ()->cell_string_data[row] = na_char;
} else {
myData ()->invalid_count++;
myData ()->previously_valid = false;
@@ -498,7 +501,7 @@
QString RKVariable::getFormatted (int row) {
if (row >= getLength ()) {
RK_ASSERT (false);
- return (*RKGlobals::unknown_char);
+ return (*unknown_char);
}
if (myData ()->value_labels) {
@@ -574,7 +577,7 @@
int i = 0;
for (int row=from_row; row <= to_row; ++row) {
deleteStringData (row);
- if (isnan (data[i])) myData ()->cell_string_data[row] = RKGlobals::na_char;
+ if (isnan (data[i])) myData ()->cell_string_data[row] = na_char;
myData ()->cell_double_data[row] = data[i++];
}
}
@@ -630,14 +633,14 @@
for (int row=from_row; row <= to_row; ++row) {
deleteStringData (row);
- myData ()->cell_string_data[row] = RKGlobals::unknown_char;
+ myData ()->cell_string_data[row] = unknown_char;
}
}
RKVariable::Status RKVariable::cellStatus (int row) {
- if (myData ()->cell_string_data[row] == RKGlobals::na_char) {
+ if (myData ()->cell_string_data[row] == na_char) {
return ValueUnused;
- } else if (myData ()->cell_string_data[row] == RKGlobals::unknown_char) {
+ } else if (myData ()->cell_string_data[row] == unknown_char) {
return ValueUnknown;
} else if ((getVarType () != String) && (myData ()->cell_string_data[row] != 0)) {
return ValueInvalid;
@@ -666,7 +669,7 @@
}
for (int row = (myData ()->allocated_length - 1 - (to_row - from_row)); row < myData ()->allocated_length; ++row) {
- myData ()->cell_string_data[myData ()->allocated_length - 1] = RKGlobals::unknown_char;
+ myData ()->cell_string_data[myData ()->allocated_length - 1] = unknown_char;
myData ()->cell_double_data[myData ()->allocated_length - 1] = 0;
}
@@ -684,7 +687,7 @@
extendToLength (getLength () + count);
for (int i=old_len; i <= row+count; ++i) {
- myData ()->cell_string_data[i] = RKGlobals::na_char;
+ myData ()->cell_string_data[i] = na_char;
myData ()->cell_double_data[i] = 0;
}
@@ -697,7 +700,7 @@
}
for (int i=row+count-1; i >= row; --i) {
- myData ()->cell_string_data[i] = RKGlobals::na_char;
+ myData ()->cell_string_data[i] = na_char;
myData ()->cell_double_data[i] = 0;
}
}
Modified: trunk/rkward/rkward/core/rkvariable.h
===================================================================
--- trunk/rkward/rkward/core/rkvariable.h 2006-09-20 14:20:27 UTC (rev 748)
+++ trunk/rkward/rkward/core/rkvariable.h 2006-09-20 14:34:59 UTC (rev 749)
@@ -144,6 +144,12 @@
enum CellAlign { AlignCellLeft=0, AlignCellRight=1 };
/** returns alignment to use for this variable */
CellAlign getAlignment ();
+
+/// an empty char
+ static QString *na_char;
+/// an unknown value
+ static QString *unknown_char;
+
protected:
/** Extended from RObject::EditData to actually contain data. */
struct RKVarEditData : public EditData {
Modified: trunk/rkward/rkward/rkglobals.cpp
===================================================================
--- trunk/rkward/rkward/rkglobals.cpp 2006-09-20 14:20:27 UTC (rev 748)
+++ trunk/rkward/rkward/rkglobals.cpp 2006-09-20 14:34:59 UTC (rev 749)
@@ -27,8 +27,6 @@
KHelpDlg *RKGlobals::helpdlg;
RControlWindow *RKGlobals::rcontrol;
-QString *RKGlobals::na_char = new QString ("");
-QString *RKGlobals::unknown_char = new QString ("?");
double RKGlobals::na_double;
RKGlobals::RKGlobals () {
@@ -48,10 +46,3 @@
return KDialog::spacingHint ();
}
-void RKGlobals::deleteStrings (QString **strings, int count) {
- for (int i = (count-1); i >= 0; --i) {
- DELETE_STRING (strings[i]);
- }
- delete [] strings;
-}
-
Modified: trunk/rkward/rkward/rkglobals.h
===================================================================
--- trunk/rkward/rkward/rkglobals.h 2006-09-20 14:20:27 UTC (rev 748)
+++ trunk/rkward/rkward/rkglobals.h 2006-09-20 14:34:59 UTC (rev 749)
@@ -27,9 +27,6 @@
class RControlWindow;
class QString;
-// deletes the given char*, if it is not a special value. Does not set to 0.
-#define DELETE_STRING(x) if (x && (x != RKGlobals::na_char) && (x != RKGlobals::unknown_char)) { delete x; };
-
/**
This class basically keeps some static pointers which are needed all over the place, so they won't have to be passed around.
@@ -61,10 +58,6 @@
/// static pointer to the RControlWindow
static RControlWindow *controlWindow () { return rcontrol; };
-/// an empty char
- static QString *na_char;
-/// an unknown value
- static QString *unknown_char;
/// a NA double
static double na_double;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list