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