00001 // Cell.cpp 00002 00003 00004 #include <cassert> 00005 #include <sstream> 00006 00007 #include "Cell.h" 00008 #include "EmptyValue.h" 00009 00010 using namespace Yosokumo; 00011 00012 00013 Cell::Cell() 00014 { 00015 nameOrKey = 0; 00016 value = EmptyValue(); 00017 } 00018 00019 Cell::Cell(uint64_t nameOrKey, const Value &value) 00020 { 00021 assert(nameOrKey >= 0); 00022 00023 this->nameOrKey = nameOrKey; 00024 this->value = value; 00025 } 00026 00027 // Setters and getters 00028 00029 void Cell::setName(uint64_t name) 00030 { 00031 nameOrKey = name; 00032 } 00033 00034 uint64_t Cell::getName() const 00035 { 00036 return nameOrKey; 00037 } 00038 00039 void Cell::setKey(uint64_t key) 00040 { 00041 nameOrKey = key; 00042 } 00043 00044 uint64_t Cell::getKey() const 00045 { 00046 return nameOrKey; 00047 } 00048 00049 void Cell::setValue(const Value &value) 00050 { 00051 this->value = value; 00052 } 00053 00054 Value Cell::getValue() const 00055 { 00056 return value; 00057 } 00058 00059 // Equality operators 00060 00061 bool Cell::operator==(const Cell &rhs) const 00062 { 00063 return 00064 ( 00065 nameOrKey == rhs.nameOrKey && 00066 value == rhs.value 00067 ); 00068 } 00069 00070 bool Cell::operator!=(const Cell &rhs) const 00071 { 00072 return !(*this == rhs); 00073 } 00074 00075 std::string Cell::toString() const 00076 { 00077 std::stringstream s; 00078 s << 00079 "Cell: nameOrKey=" << nameOrKey << " value=" << value.toString() << "\n"; 00080 return s.str(); 00081 } 00082 00083 // end Cell.cpp