X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.databoard%2Fcpp%2FDataBoardTest%2FDataBoard%2FNumberType.cpp;fp=bundles%2Forg.simantics.databoard%2Fcpp%2FDataBoardTest%2FDataBoard%2FNumberType.cpp;h=6cb9e164b6435f473e0c2f01590e2dba950f3f35;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/NumberType.cpp b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/NumberType.cpp new file mode 100644 index 000000000..6cb9e164b --- /dev/null +++ b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/NumberType.cpp @@ -0,0 +1,98 @@ +#include "NumberType.h" + +#include "Range.h" + +#include "Constants.h" + +namespace Databoard { + namespace Type { + + NumberType::NumberType() + { + range = NULL; + } + + NumberType::NumberType(std::string unit) + { + this->unit = unit; + range = new Range(); + } + + NumberType::NumberType(std::string unit, Range* range) + { + this->unit = unit; + this->range = range; + } + + NumberType::~NumberType() + { + if(range != NULL) + { + delete range; + } + } + + std::string NumberType::getUnit() + { + return unit; + } + + void NumberType::setUnit(std::string unit) + { + this->unit = unit; + } + + Range* NumberType::getRange() + { + return range; + } + + void NumberType::setRange(Range* value) + { + this->range = value; + } + + std::string NumberType::writeOut(int /*indent*/) + { + std::string s; + + bool parenthesis = false; + + if(unit.size() != 0) + { + s += "("; + s.append(STR_UNIT); + s += "=\"" + unit + "\""; + + + parenthesis = true; + } + + if(range != NULL) + { + if(parenthesis == false) + { + s += "("; + } + else + { + s += ", "; + } + + s.append(STR_RANGE); + s += "=" + range->writeOut(); + + parenthesis = true; + } + + if(parenthesis == true) + { + s += ")"; + } + + + + return s; + } + } +}