Browse Source

Minor tweaks to GBUdb.* to remove compiler warnings.

Minor tweaks to snf_engine.* to remove compiler warnings.
Refactored Evaluator objects to use unsigned ints for positions.

git-svn-id: https://svn.microneil.com/svn/SNFMulti/trunk@6 dc71a809-1921-45c4-985c-09c81d0142d9
wx
madscientist 15 years ago
parent
commit
9675a9036d
3 changed files with 19 additions and 19 deletions
  1. 6
    6
      GBUdb.cpp
  2. 3
    3
      snf_engine.cpp
  3. 10
    10
      snf_engine.hpp

+ 6
- 6
GBUdb.cpp View File

@@ -43,11 +43,11 @@ GBUdbDataset::GBUdbDataset(const char* SetFileName) :
}

GBUdbDataset::GBUdbDataset(GBUdbDataset& Original) : // Copy constructor.
MyFileName(Original.MyFileName), // Copy the name pointer.
DataArray(NULL), // The array pointer starts as NULL.
MyArraySize(Original.MyArraySize) { // We copy the ArraySize
DataArray = new GBUdbRecord[MyArraySize]; // then allocate a new Array that size.
memcpy(DataArray, Original.DataArray, sizeof(GBUdbRecord) * MyArraySize); // Then we copy the data wholesale.
DataArray(NULL), // The array pointer starts as NULL.
MyArraySize(Original.MyArraySize), // Copy the ArraySize
MyFileName(Original.MyFileName) { // Copy the name pointer.
DataArray = new GBUdbRecord[MyArraySize]; // Allocate a new Array.
memcpy(DataArray, Original.DataArray, sizeof(GBUdbRecord) * MyArraySize); // Copy the data wholesale.
}

const char* GBUdbDataset::FileName(const char* NewName) { // (Re) Set the file name.
@@ -514,7 +514,7 @@ char* getTimestamp(char* TimestampBfr) {
time(&rawtime); // Grab the current time and
gmt=gmtime(&rawtime); // convert it to GMT.

sprintf(TimestampBfr,"%04d%02d%02d%02d%02d%02d\0", // Format yyyymmddhhmmss
sprintf(TimestampBfr,"%04d%02d%02d%02d%02d%02d", // Format yyyymmddhhmmss
gmt->tm_year+1900,
gmt->tm_mon+1,
gmt->tm_mday,

+ 3
- 3
snf_engine.cpp View File

@@ -224,7 +224,7 @@ inline bool Evaluator::i_isAlpha() { return myEvaluationMatrix->i_isAlpha; }

// Evaluator::Evaluator(position,evalmatrix) Constructor

Evaluator::Evaluator(int s, EvaluationMatrix* m) { // Constructor...
Evaluator::Evaluator(unsigned int s, EvaluationMatrix* m) { // Constructor...

myEvaluationMatrix = m; // Capture the matrix I live in.
Matrix = myEvaluationMatrix->getTokens(); // Capture the token matrix I walk in.
@@ -610,7 +610,7 @@ MatchRecord* EvaluationMatrix::AddMatchRecord(int sp, int ep, int sym) {
// and which has the only difference of putting the new evaluator after the current one
// in the chain in order to support branch-out operations for loop sequences in the matrix.

Evaluator* EvaluationMatrix::AddEvaluator(int s, int m) { // Adds a new evaluator at top.
Evaluator* EvaluationMatrix::AddEvaluator(int s, unsigned int m) { // Adds a new evaluator at top.

if(!isNoDuplicate(m)) return NULL; // If there is a duplicate do nothing.

@@ -637,7 +637,7 @@ Evaluator* EvaluationMatrix::AddEvaluator(int s, int m) {

// EvaluationMatrix::InsEvaluator()

Evaluator* EvaluationMatrix::InsEvaluator(int s, int m) { // Inserts a new evaluator.
Evaluator* EvaluationMatrix::InsEvaluator(int s, unsigned int m) { // Inserts a new evaluator.

if(!isNoDuplicate(m)) return NULL; // If there is a duplicate do nothing.


+ 10
- 10
snf_engine.hpp View File

@@ -198,12 +198,12 @@ class TokenMatrix {
// Constructors...

TokenMatrix() :
MatrixSize(0),
Matrix(NULL) { }
Matrix(NULL),
MatrixSize(0) { }

TokenMatrix(ifstream& F) :
MatrixSize(0),
Matrix(NULL) {
Matrix(NULL),
MatrixSize(0) {
Load(F);
}

@@ -281,7 +281,7 @@ class Evaluator { // Evaluator class for following threads through the matrix.
States Condition; // What state am I in? How's my health?

Evaluator* NextEvaluator; // Linked List Pointer.
int StreamStartPosition; // Indexes the position where we started.
unsigned int StreamStartPosition; // Indexes the position where we started.
unsigned int CurrentPosition; // Indexes the node we are surfing.

int WildRunLength; // Wildcard run length so far.
@@ -296,7 +296,7 @@ class Evaluator { // Evaluator class for following threads through the matrix.
// key to creating buddies when working with wildcards. It prevents us from recursively
// proliferating evaluators at each new character when running in a wildcard loop.

int isNoDuplicate(int Position) { // Returns false if there is a duplicate.
bool isNoDuplicate(unsigned int Position) { // Returns false if there is a duplicate.
if(CurrentPosition == Position) // Obviously, if I match, then there's a dup.
return false;
// If I don't match and I'm the last one then
@@ -306,7 +306,7 @@ class Evaluator { // Evaluator class for following threads through the matrix.
return NextEvaluator->isNoDuplicate(Position);
}

Evaluator(int s, EvaluationMatrix* m); // Constructor...
Evaluator(unsigned int s, EvaluationMatrix* m); // Constructor...

~Evaluator(){
if(NextEvaluator!=NULL){ // If there's more to this list then
@@ -431,16 +431,16 @@ class EvaluationMatrix {
return myTokenMatrix->Size(); // for use when creating evaluators.
}

Evaluator* AddEvaluator(int s, int m); // Adds a new evaluator to the top.
Evaluator* AddEvaluator(int s, unsigned int m); // Adds a new evaluator to the top.

Evaluator* InsEvaluator(int s, int m); // Inserts a new evaluator after the
Evaluator* InsEvaluator(int s, unsigned int m); // Inserts a new evaluator after the
// current evaluator. (Only called by
// an existing evaluator in process...)


// isNoDuplicate(int p) checks for duplicate evaulators

int isNoDuplicate(int p) { // If there's no list there can be no
bool isNoDuplicate(unsigned int p) { // If there's no list there can be no
if(EvaluatorList == NULL) // duplicates so we're true. If there is
return true; // a list then we'll let the list answer.
else

Loading…
Cancel
Save