dmi_unit
Synopsis
#include <opendmi/value.h>
typedef enum dmi_unit {
DMI_UNIT_NONE,
DMI_UNIT_HOUR,
DMI_UNIT_MINUTE,
DMI_UNIT_SECOND,
DMI_UNIT_MILLISECOND,
DMI_UNIT_MICROSECOND,
DMI_UNIT_NANOSECOND,
DMI_UNIT_AMPERE,
DMI_UNIT_MILLIAMPERE,
DMI_UNIT_VOLT,
DMI_UNIT_MILLIVOLT,
DMI_UNIT_WATT,
DMI_UNIT_MILLIWATT,
DMI_UNIT_WATT_HOUR,
DMI_UNIT_CELSIUS,
DMI_UNIT_BIT,
DMI_UNIT_BYTE,
DMI_UNIT_KILOBYTE,
DMI_UNIT_MEGABYTE,
DMI_UNIT_GIGABYTE,
DMI_UNIT_KIBIBYTE,
DMI_UNIT_MEBIBYTE,
DMI_UNIT_GIBIBYTE,
DMI_UNIT_TEBIBYTE,
DMI_UNIT_PEBIBYTE,
DMI_UNIT_EXBIBYTE,
DMI_UNIT_ZEBIBYTE,
DMI_UNIT_YOBIBYTE,
DMI_UNIT_ROBIBYTE,
DMI_UNIT_QUEBIBYTE,
DMI_UNIT_BAUD,
DMI_UNIT_MEGAXA_SECOND,
DMI_UNIT_KILOBIT_SECOND,
DMI_UNIT_MEGABIT_SECOND,
DMI_UNIT_GIGABIT_SECOND,
DMI_UNIT_PERCENT,
DMI_UNIT_REVOLUTION,
DMI_UNIT_RACK,
DMI_UNIT_MHZ,
DMI_UNIT_MILLIMETER
} dmi_unit_t;
const char *dmi_unit_code(dmi_unit_t value);
const char *dmi_unit_name(dmi_unit_t value);
Description
The dmi_unit_t enumeration tells the measurement units of an integer or a
decimal attribute, and is the type of the .unit member of an attribute,
see DMI_ATTRIBUTE.
The dmi_unit_code function returns the code of a unit, a machine-readable
identifier which is the same in every language, e.g. millivolt, as the
XML output of the command line tool gives it.
The dmi_unit_name function returns the symbol of a unit, as the command
line tool prints it after a value, e.g. mV. The name is translated to the
locale set with dmi_set_locale if the library is built with ICU4C
support and the locale has a translation of it, and is in English otherwise.
Decimal units of size are powers of 1000, and binary ones are powers of 1024.
Values
DMI_UNIT_NONE-
No measurement units, e.g. of a count. The value has neither a code nor a name.
DMI_UNIT_HOUR-
Hours, code
hour, nameh. DMI_UNIT_MINUTE-
Minutes, code
minute, namem. DMI_UNIT_SECOND-
Seconds, code
second, names. DMI_UNIT_MILLISECOND-
Milliseconds, code
millisecond, namems. DMI_UNIT_MICROSECOND-
Microseconds, code
microsecond, nameus. DMI_UNIT_NANOSECOND-
Nanoseconds, code
nanosecond, namens. DMI_UNIT_AMPERE-
Amperes, code
ampere, nameA. DMI_UNIT_MILLIAMPERE-
Milliamperes, code
milliampere, namemA. DMI_UNIT_VOLT-
Volts, code
volt, nameV. DMI_UNIT_MILLIVOLT-
Millivolts, code
millivolt, namemV. DMI_UNIT_WATT-
Watts, code
watt, nameW. DMI_UNIT_MILLIWATT-
Milliwatts, code
milliwatt, namemW. DMI_UNIT_WATT_HOUR-
Watt-hours, code
watt-hour, nameW*h. DMI_UNIT_CELSIUS-
Degrees Celsius, code
celsius, name°C. DMI_UNIT_BIT-
Bits, code
bit, namebits. DMI_UNIT_BYTE-
Bytes, code
byte, namebytes. DMI_UNIT_KILOBYTE-
Kilobytes, 1000 bytes, code
kilobyte, nameKB. DMI_UNIT_MEGABYTE-
Megabytes, 1000 kilobytes, code
megabyte, nameMB. DMI_UNIT_GIGABYTE-
Gigabytes, 1000 megabytes, code
gigabyte, nameGB. DMI_UNIT_KIBIBYTE-
Kibibytes, 1024 bytes, code
kibibyte, nameKiB. DMI_UNIT_MEBIBYTE-
Mebibytes, 1024 kibibytes, code
mebibyte, nameMiB. DMI_UNIT_GIBIBYTE-
Gibibytes, 1024 mebibytes, code
gibibyte, nameGiB. DMI_UNIT_TEBIBYTE-
Tebibytes, 1024 gibibytes, code
tebibyte, nameTiB. DMI_UNIT_PEBIBYTE-
Pebibytes, 1024 tebibytes, code
pebibyte, namePiB. DMI_UNIT_EXBIBYTE-
Exbibytes, 1024 pebibytes, code
exbibyte, nameEiB. DMI_UNIT_ZEBIBYTE-
Zebibytes, 1024 exbibytes, code
zebibyte, nameZiB. DMI_UNIT_YOBIBYTE-
Yobibytes, 1024 zebibytes, code
yobibyte, nameYiB. DMI_UNIT_ROBIBYTE-
Robibytes, 1024 yobibytes, code
robibyte, nameRiB. DMI_UNIT_QUEBIBYTE-
Quebibytes, 1024 robibytes, code
quebibyte, nameQiB. DMI_UNIT_BAUD-
Symbols per second, code
baud, namebaud. DMI_UNIT_MEGAXA_SECOND-
Megatransfers per second, code
megaxa-second, nameMT/s. DMI_UNIT_KILOBIT_SECOND-
Kilobits per second, code
kilobit-second, nameKbps. DMI_UNIT_MEGABIT_SECOND-
Megabits per second, code
megabit-second, nameMbps. DMI_UNIT_GIGABIT_SECOND-
Gigabits per second, code
gigabit-second, nameGbps. DMI_UNIT_PERCENT-
Percents, code
percent, name%. DMI_UNIT_REVOLUTION-
Revolutions per minute, code
revolution, namerpm. DMI_UNIT_RACK-
Rack units, code
rack, nameU. DMI_UNIT_MHZ-
Megahertz, code
mhz, nameMHz. DMI_UNIT_MILLIMETER-
Millimeters, code
millimeter, namemm.
Return value
The functions return the code or the name of the unit, or nullptr if the
unit has none, e.g. DMI_UNIT_NONE, or if the value is not a unit. The
string belongs to the library and must not be modified or freed; a
translated name may become invalid once the locale is changed.