libqalculate-0.9.8

- Main Page
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Attributes | List of all members
Prefix Class Referenceabstract

Abstract class for prefixes. More...

`#include <Prefix.h>`

Inheritance diagram for Prefix:

## Public Member Functions
| Prefix (string long_name, string short_name="", string unicode_name="")
const string & | shortName (bool return_long_if_no_short=true, bool use_unicode=false) const
const string & | longName (bool return_short_if_no_long=true, bool use_unicode=false) const
const string & | unicodeName (bool return_short_if_no_uni=true) const
void | setShortName (string short_name)
void | setLongName (string long_name)
void | setUnicodeName (string unicode_name)
const string & | name (bool short_default=true, bool use_unicode=false, bool(*can_display_unicode_string_function)(const char *, void *)=NULL, void *can_display_unicode_string_arg=NULL) const
virtual Number | value (const Number &nexp) const =0
virtual Number | value (int iexp) const =0
virtual Number | value () const =0
virtual int | type () const =0

## Protected Attributes
string | l_name
string | s_name
string | u_name

## Detailed Description

Abstract class for prefixes.

A prefix is prepended to a unit to specificy a quantity multiplicator. A prefix has a numerical value which raised to the units power defines the quantity. In for example the expression "3 kilometers", meter is the unit, 3 is regular quantity, and kilo is a prefix with a value 1000, thus the example equals "3000 meters". If the unit instead had been squared, the value of the prefix would have been raised by two and the total quantity would have been 3.000.000.

Prefixes can have up to free different three names – a long name, a short name and a short unicode name. The unicode name is an alternative to the short name that is preferred if unicode characters can be displayed. The names or used to reference the prefix in mathematical expressions and to display a prefix in a result.

## Constructor & Destructor Documentation

Prefix::Prefix | ( | string | long_name,
|  | string | short_name = `""`,
|  | string | unicode_name = `""`
| ) |  |

Create a prefix.

Parameters

  long_name | Long name.
  short_name | Short name.
  unicode_name | Unicode name.

## Member Function Documentation

const string& Prefix::longName | ( | bool | return_short_if_no_long = `true`,
|  | bool | use_unicode = `false`
| ) |  | const

Returns the long name of the prefix.

Parameters

  return_short_if_no_long | If the short name shall be returned if the prefix has not got a long name (if it is empty).
  use_unicode | If a unicode version of the name is allowed and preferred.

Returns
  The long name of the prefix.

const string& Prefix::name | ( | bool | short_default = `true`,
|  | bool | use_unicode = `false`,
|  | bool(*)(const char *, void *) | can_display_unicode_string_function = `NULL`,
|  | void * | can_display_unicode_string_arg = `NULL`
| ) |  | const

Returns a preferred name of the prefix.

Parameters

  short_default | If a short name is preferred.
  use_unicode | If a unicode name is preferred.
  can_display_unicode_string_function | Function that tests if the unicode characters in a name can be displayed. If the function returns false, the name will be rejected.
  can_display_unicode_string_arg | Argument to pass to the above test function.

Returns
  A preferred name.

void Prefix::setLongName | ( | string | long_name | ) |

Sets the long name of the prefix.

Parameters

  long_name | The new long name for the prefix.

void Prefix::setShortName | ( | string | short_name | ) |

Sets the short name of the prefix.

Parameters

  short_name | The new short name for the prefix.

void Prefix::setUnicodeName | ( | string | unicode_name | ) |

Sets the unicode name of the prefix. The unicode name is an alternative to the short name that is preferred if unicode characters can be displayed.

Parameters

  unicode_name | The new unicode name for the prefix.

const string& Prefix::shortName | ( | bool | return_long_if_no_short = `true`,
|  | bool | use_unicode = `false`
| ) |  | const

Returns the short name of the prefix.

Parameters

  return_long_if_no_short | If the long name shall be returned if the prefix has not got a short name (if it is empty).
  use_unicode | If a unicode version of the name is allowed and preferred.

Returns
  The short name of the prefix.

virtual int Prefix::type | ( |  | ) | const
| pure virtual

Returns type, subclass, of the prefix. This can be PREFIX_DECIMAL for prefixes of the class DecimalPrefix, PREFIX_BINARY for BinaryPrefix, or PREFIX_NUMBER for NumberPrefix.

Returns
  The type of the prefix.

Implemented in NumberPrefix, BinaryPrefix, and DecimalPrefix.

const string& Prefix::unicodeName | ( | bool | return_short_if_no_uni = `true` | ) | const

Returns the unicode name of the prefix.

Parameters

  return_short_if_no_uni | If the short name shall be returned if the prefix has not got a unicode name (if it is empty).

Returns
  The unicode name of the prefix.

virtual Number Prefix::value | ( | const Number & | nexp | ) | const
| pure virtual

Returns the value of the prefix.

Parameters

  nexp | The power of the prefixed unit.

Returns
  The value of the prefix.

Implemented in NumberPrefix, BinaryPrefix, and DecimalPrefix.

virtual Number Prefix::value | ( | int | iexp | ) | const
| pure virtual

Returns the value of the prefix.

Parameters

  iexp | The power of the prefixed unit.

Returns
  The value of the prefix.

Implemented in NumberPrefix, BinaryPrefix, and DecimalPrefix.

virtual Number Prefix::value | ( |  | ) | const
| pure virtual

Returns the value of the prefix.

Returns
  The value of the prefix.

Implemented in NumberPrefix, BinaryPrefix, and DecimalPrefix.

The documentation for this class was generated from the following file:

- libqalculate/Prefix.h