X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.databoard%2Fcpp%2FDataBoardTest%2FDataBoard%2FIntegerValue.cpp;h=6b0def71485e4699bfa3a18efe19e113a9958374;hp=b7bae2f8484f807bb7f79c8baa033a3befe1e197;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/IntegerValue.cpp b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/IntegerValue.cpp index b7bae2f84..6b0def714 100644 --- a/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/IntegerValue.cpp +++ b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/IntegerValue.cpp @@ -1,106 +1,106 @@ -#include "IntegerValue.h" - -#include "NumberType.h" -#include "IntegerType.h" -#include "Range.h" -#include "Limit.h" - -#include -#include "Constants.h" - -namespace Databoard { - namespace Value { - IntegerValue::IntegerValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard) - { - } - - IntegerValue::~IntegerValue() - { - } - - void IntegerValue::setValue(int value) - { - Databoard::Type::IntegerType* integerType = dynamic_cast(dataBoard); - - if(integerType != NULL) - { - this->value = value; - } - } - - int IntegerValue::getValue() - { - return value; - } - - std::string IntegerValue::writeOut(int /*indent*/) - { - std::string s; - - std::stringstream oss; - - oss << value; - - oss >> s; - - return s; - } - - bool IntegerValue::equals(const Value* other) - { - IntegerValue* o = (IntegerValue*)other; - - return (this->value < o->value); - } - - std::string IntegerValue::isValid() - { - if(dataBoard == NULL) - { - return "IntegerValue: There is no datatype."; - } - - Databoard::Type::IntegerType* integerType = (Databoard::Type::IntegerType*)dataBoard; - - if(integerType->getRange() == NULL) - { - return STR_EMPTY; - } - - int minValue = integerType->minValue(); - int maxValue = integerType->maxValue(); - - if(integerType->getRange()->getLower()->getInclusive() == true) - { - if(value < minValue) - { - return std::string("IntegerValue: ") + STR_ERROR_VALUE_SMALL; - } - } - else //if(integerType->getRange()->getLower()->getInclusive() == false) - { - if(value <= minValue) - { - return std::string("IntegerValue: ") + STR_ERROR_VALUE_SMALL; - } - } - - if(integerType->getRange()->getUpper()->getInclusive() == true) - { - if(value > maxValue) - { - return std::string("IntegerValue: ") + STR_ERROR_VALUE_LARGE; - } - } - else //if(integerType->getRange()->getUpper()->getInclusive() == false) - { - if(value >= maxValue) - { - return std::string("IntegerValue: ") + STR_ERROR_VALUE_LARGE; - } - } - - return STR_EMPTY; - } - } -} +#include "IntegerValue.h" + +#include "NumberType.h" +#include "IntegerType.h" +#include "Range.h" +#include "Limit.h" + +#include +#include "Constants.h" + +namespace Databoard { + namespace Value { + IntegerValue::IntegerValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard) + { + } + + IntegerValue::~IntegerValue() + { + } + + void IntegerValue::setValue(int value) + { + Databoard::Type::IntegerType* integerType = dynamic_cast(dataBoard); + + if(integerType != NULL) + { + this->value = value; + } + } + + int IntegerValue::getValue() + { + return value; + } + + std::string IntegerValue::writeOut(int /*indent*/) + { + std::string s; + + std::stringstream oss; + + oss << value; + + oss >> s; + + return s; + } + + bool IntegerValue::equals(const Value* other) + { + IntegerValue* o = (IntegerValue*)other; + + return (this->value < o->value); + } + + std::string IntegerValue::isValid() + { + if(dataBoard == NULL) + { + return "IntegerValue: There is no datatype."; + } + + Databoard::Type::IntegerType* integerType = (Databoard::Type::IntegerType*)dataBoard; + + if(integerType->getRange() == NULL) + { + return STR_EMPTY; + } + + int minValue = integerType->minValue(); + int maxValue = integerType->maxValue(); + + if(integerType->getRange()->getLower()->getInclusive() == true) + { + if(value < minValue) + { + return std::string("IntegerValue: ") + STR_ERROR_VALUE_SMALL; + } + } + else //if(integerType->getRange()->getLower()->getInclusive() == false) + { + if(value <= minValue) + { + return std::string("IntegerValue: ") + STR_ERROR_VALUE_SMALL; + } + } + + if(integerType->getRange()->getUpper()->getInclusive() == true) + { + if(value > maxValue) + { + return std::string("IntegerValue: ") + STR_ERROR_VALUE_LARGE; + } + } + else //if(integerType->getRange()->getUpper()->getInclusive() == false) + { + if(value >= maxValue) + { + return std::string("IntegerValue: ") + STR_ERROR_VALUE_LARGE; + } + } + + return STR_EMPTY; + } + } +}