diff --git a/src/Grid.cpp b/src/Grid.cpp index ce6c21357..dcee7154e 100644 --- a/src/Grid.cpp +++ b/src/Grid.cpp @@ -377,6 +377,36 @@ Grid::Cell::operator std::string () const return std::string (""); } +//////////////////////////////////////////////////////////////////////////////// +bool Grid::Cell::operator== (const Grid::Cell& rhs) const +{ + switch (mType) + { + case CELL_BOOL: return mBool == rhs.mBool ? true : false; + case CELL_CHAR: return mChar == rhs.mChar ? true : false; + case CELL_INT: return mInt == rhs.mInt ? true : false; + case CELL_FLOAT: return mFloat == rhs.mFloat ? true : false; + case CELL_DOUBLE: return mDouble == rhs.mDouble ? true : false; + case CELL_STRING: return mString == rhs.mString ? true : false; + default: break; // To prevent warnings. + } +} + +//////////////////////////////////////////////////////////////////////////////// +bool Grid::Cell::operator!= (const Grid::Cell& rhs) const +{ + switch (mType) + { + case CELL_BOOL: return mBool != rhs.mBool ? true : false; + case CELL_CHAR: return mChar != rhs.mChar ? true : false; + case CELL_INT: return mInt != rhs.mInt ? true : false; + case CELL_FLOAT: return mFloat != rhs.mFloat ? true : false; + case CELL_DOUBLE: return mDouble != rhs.mDouble ? true : false; + case CELL_STRING: return mString != rhs.mString ? true : false; + default: break; // To prevent warnings. + } +} + //////////////////////////////////////////////////////////////////////////////// Grid::Cell::cellType Grid::Cell::type () const { diff --git a/src/Grid.h b/src/Grid.h index 8c36d682d..571aecc3f 100644 --- a/src/Grid.h +++ b/src/Grid.h @@ -29,6 +29,8 @@ public: operator float () const; operator double () const; operator std::string () const; + bool operator== (const Cell&) const; + bool operator!= (const Cell&) const; enum cellType {CELL_BOOL, CELL_CHAR, CELL_INT, CELL_FLOAT, CELL_DOUBLE, CELL_STRING};