#include <Unit.h>
Public Member Functions | |
Unit (string cat_, string name_, string plural_="", string singular_="", string title_="", bool is_local=true, bool is_builtin=false, bool is_active=true) | |
Unit (const Unit *unit) | |
virtual ExpressionItem * | copy () const |
virtual void | set (const ExpressionItem *item) |
bool | isSIUnit () const |
void | setAsSIUnit () |
void | setSystem (string s_system) |
const string & | system () const |
bool | isCurrency () const |
virtual string | print (bool plural_, bool short_, bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const |
virtual const string & | plural (bool return_singular_if_no_plural=true, bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const |
virtual const string & | singular (bool return_abbreviation_if_no_singular=true, bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const |
virtual const string & | abbreviation (bool return_singular_if_no_abbreviation=true, bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const |
virtual bool | isUsedByOtherUnits () const |
virtual Unit * | baseUnit () const |
virtual MathStructure & | convertToBaseUnit (MathStructure &mvalue, MathStructure &mexp) const |
virtual MathStructure & | convertFromBaseUnit (MathStructure &mvalue, MathStructure &mexp) const |
virtual MathStructure & | convertToBaseUnit (MathStructure &mvalue) const |
virtual MathStructure & | convertFromBaseUnit (MathStructure &mvalue) const |
virtual MathStructure | convertToBaseUnit () const |
virtual MathStructure | convertFromBaseUnit () const |
virtual int | baseExponent (int exp=1) const |
virtual int | type () const |
virtual int | subtype () const |
virtual bool | isChildOf (Unit *u) const |
virtual bool | isParentOf (Unit *u) const |
virtual bool | hasComplexRelationTo (Unit *u) const |
bool | convert (Unit *u, MathStructure &mvalue, MathStructure &exp) const |
bool | convert (Unit *u, MathStructure &mvalue) const |
MathStructure | convert (Unit *u, bool *converted=NULL) const |
Protected Attributes | |
string | ssystem |
bool | b_si |
The Unit class both represents a base unit and is the base class for other unit types. Base units are units defined as basis for other units. Meters and seconds are typical base units.
For base units, a name is all that is needed. Base units do however normally have three different names defined for use in expressions - abbreviation (ex. "m"), singular ("meter") and plural ("meters").
bool Unit::isSIUnit | ( | ) | const |
Returns if the unit is part of the SI standard.
void Unit::setAsSIUnit | ( | ) |
State that the unit is part of the SI standard. Sets system to "SI".
void Unit::setSystem | ( | string | s_system | ) |
Sets which system/standard ("SI", "SGC", etc.) the unit is part of. Setting system to "SI" (case-insensitive), is equivalent to setAsSIUnit().
const string& Unit::system | ( | ) | const |
Returns the system/standard that the unit is part of.
bool Unit::isCurrency | ( | ) | const |
Returns if the unit is a currency (Euro is base unit).
virtual string Unit::print | ( | bool | plural_, | |
bool | short_, | |||
bool | use_unicode = false , |
|||
bool(*)(const char *, void *) | can_display_unicode_string_function = NULL , |
|||
void * | can_display_unicode_string_arg = NULL | |||
) | const [virtual] |
Returns a display string representing the unit in an expression.
Equivalent to preferredName() for Unit and AliasUnit, but closer to MathStructure::print() for CompositeUnit (prints out base expression).
Reimplemented in AliasUnit_Composite, and CompositeUnit.
virtual int Unit::type | ( | ) | const [virtual] |
Returns the type of the expression item, corresponding to which subclass the object belongs to.
Implements ExpressionItem.
virtual int Unit::subtype | ( | ) | const [virtual] |
Returns the subtype of the unit, corresponding to which subsubclass the object belongs to.
Implements ExpressionItem.
Reimplemented in AliasUnit, and CompositeUnit.
virtual bool Unit::isChildOf | ( | Unit * | u | ) | const [virtual] |
If specified unit is a base unit for this unit, directly or with other units in between. Equivalent to u->isParentOf(this).
Reimplemented in AliasUnit.
virtual bool Unit::isParentOf | ( | Unit * | u | ) | const [virtual] |
If this unit is a base unit for specified unit, directly or with other units in between. Equivalent to u->isChildOf(this).
Reimplemented in AliasUnit.
bool Unit::convert | ( | Unit * | u, | |
MathStructure & | mvalue, | |||
MathStructure & | exp | |||
) | const |
Converts a value from specified unit and exponent to this unit. value * (unit^exponent) = new value * (this^new exponent) This function cannot convert to or from CompositeUnit.
u | Unit to convert from. | |
[in,out] | mvalue | Quantity value. |
[in,out] | exp | Exponent. |
bool Unit::convert | ( | Unit * | u, | |
MathStructure & | mvalue | |||
) | const |
Converts a value from specified unit and exponent to this unit. value * unit = new value * this This function cannot convert to or from CompositeUnit.
u | Unit to convert from. | |
[in,out] | mvalue | Quantity value. |