#include "Limit.h" #include "Constants.h" #include #ifdef max #undef max #endif #ifdef min #undef min #endif #include namespace Databoard { Limit::Limit(bool isLower) { this->isLower = isLower; isInclusive = false; } Limit::~Limit() { } void Limit::setValue(std::string value) { this->value = value; } std::string Limit::getValue() { return value; } double Limit::getDouble(double value) { if(this->value.size() > 0) { double c; std::istringstream iss(this->value); iss >> c; if(isLower == true) { c = std::max(value, c); } else { c = std::min(value, c); } return c; } else { return value; } } float Limit::getFloat(float value) { if(this->value.size() > 0) { float c; std::istringstream iss(this->value); iss >> c; if(isLower == true) { c = std::max(value, c); } else { c = std::min(value, c); } return c; } else { return value; } } int Limit::getInteger(int value) { if(this->value.size() > 0) { int c; std::istringstream iss(this->value); iss >> c; if(isLower == true) { c = std::max(value, c); } else { c = std::min(value, c); } return c; } else { return value; } } long Limit::getLong(long value) { if(this->value.size() > 0) { long c; std::istringstream iss(this->value); iss >> c; if(isLower == true) { c = std::max(value, c); } else { c = std::min(value, c); } return c; } else { return value; } } char Limit::getByte(char value) { if(this->value.size() > 0) { char c; std::istringstream iss(this->value); iss >> c; if(isLower == true) { c = std::max(value, c); } else { c = std::min(value, c); } return c; } else { return value; } } void Limit::setInclusive() { isInclusive = true; } bool Limit::getInclusive() { return isInclusive; } std::string Limit::writeOut() { std::string s; if(isLower == true) { if(isInclusive == true) { s += "["; } else { s += "("; } } s += value; if(isLower == false) { if(isInclusive == true) { s += "]"; } else { s += ")"; } } return s; } }