Performs Unit math in full precision. More...
#include <unitAlgebra.h>
Public Member Functions | |
UnitAlgebra (std::string val) | |
Create a new UnitAlgebra instance, and pre-populate with a parsed value. | |
void | print (std::ostream &stream) |
Print to an ostream the value. | |
void | printWithBestSI (std::ostream &stream) |
Print to an ostream the value Formats the number using SI-prefixes. | |
std::string | toString () const |
Return a string representation of this value. | |
std::string | toStringBestSI () const |
Return a string representation of this value Formats the number using SI-prefixes. | |
UnitAlgebra & | operator= (const std::string &v) |
UnitAlgebra & | operator*= (const UnitAlgebra &v) |
Multiply by an argument;. | |
template<typename T > | |
UnitAlgebra & | operator*= (const T &v) |
Multiply by an argument;. | |
UnitAlgebra & | operator/= (const UnitAlgebra &v) |
Divide by an argument;. | |
template<typename T > | |
UnitAlgebra & | operator/= (const T &v) |
Divide by an argument;. | |
bool | operator> (const UnitAlgebra &v) |
Compare if this object is greater than the argument. | |
bool | operator>= (const UnitAlgebra &v) |
Compare if this object is greater than, or equal to, the argument. | |
bool | operator< (const UnitAlgebra &v) |
Compare if this object is less than the argument. | |
bool | operator<= (const UnitAlgebra &v) |
Compare if this object is less than, or equal to, the argument. | |
UnitAlgebra & | invert () |
Apply a reciprocal operation to the object. | |
bool | hasUnits (std::string u) const |
Returns true if the units in the parameter string are found in this object. | |
sst_dec_float | getValue () const |
Return the raw value. | |
int64_t | getRoundedValue () const |
Return the rounded value as a 64bit integer. | |
Friends | |
class | boost::serialization::access |
Performs Unit math in full precision.
Allows operations such as multiplying a frequency by 2.
UnitAlgebra::UnitAlgebra | ( | std::string | val | ) |
Create a new UnitAlgebra instance, and pre-populate with a parsed value.
val | Value to parse. It is of the following format:
val := NUMBER( )?UNITS
NUMBER := (-)?[0-9]+(.[0-9]+)?
UNITS := UNITGROUP(/UNITGROUP)
UNITGROUP := UNIT(-UNIT)*
UNIT := (SIPREFIX)?(BASEUNIT|COMPUNIT)
SIPREFIX := {a,f,p,n,u,m,[kKMGTPE]i?}
BASEUNIT := {s,B,b,events}
COMPUNIT := {Hz,hz,Bps,bps,event}
|