21 #include <sbml/packages/render/sbml/RelAbsVector.h>
47 mAbs(source.getAbsoluteValue()),
48 mRel(source.getRelativeValue())
68 size_t i, iMax = coordString.size();
71 for (i = 0; i < iMax; ++i)
73 if (!(coordString[i] ==
' ' || coordString[i] ==
'\t' || coordString[i] ==
'\n' || coordString[i] ==
'\r'))
75 trimmed += coordString[i];
85 char* s =
new char[trimmed.size()+1];
86 strncpy(s, trimmed.c_str(), trimmed.size() + 1);
90 double value = strtod(p, &pp);
93 if ((*pp) ==
'%' && pp == (s + trimmed.size() - 1))
109 else if ((*pp) ==
'+' || (*pp) ==
'-')
113 double value = strtod(p, &pp);
116 if ((*pp) !=
'%' || pp != (s + trimmed.size() - 1))
137 this->
mAbs = std::numeric_limits<double>::quiet_NaN();
138 this->
mRel = std::numeric_limits<double>::quiet_NaN();
194 if (this->
mAbs == 0.0)
196 result = (fabs(other.
mAbs) < 1e-12);
200 result = (fabs((this->
mAbs - other.
mAbs) / this->mAbs) < 1e-12);
205 if (this->
mRel == 0.0)
207 result = (fabs(other.
mRel) < 1e-12);
211 result = (fabs((this->
mRel - other.
mRel) / this->mRel) < 1e-12);
220 return !((*this) == other);
225 std::ostringstream os;
227 if (this->
mAbs != 0.0 || this->
mRel == 0.0)
231 if (this->
mRel < 0.0)
233 os << this->
mRel <<
"%";
235 else if (this->
mRel > 0.0)
237 os <<
"+" << this->
mRel <<
"%";
242 os << this->
mRel <<
"%";
270 return new RelAbsVector(
mAbs,
mRel);
void setAbsoluteValue(double abs)
CLRelAbsVector(double a=0.0, double r=0.0)
bool operator==(const CLRelAbsVector &other) const
std::ostream & operator<<(std::ostream &os, const CLRelAbsVector &v)
double getRelativeValue() const
void setCoordinate(double abs, double rel=0.0)
CLRelAbsVector operator+(const CLRelAbsVector &other) const
CLRelAbsVector & operator=(const CLRelAbsVector &src)
void setRelativeValue(double rel)
RelAbsVector * toSBML() const
bool operator!=(const CLRelAbsVector &other) const
double getAbsoluteValue() const
std::string toString() const
CLRelAbsVector operator/(double x) const