scifir-units 2.0.0
scifir-units is a library of units of measurement, angles, coordinates, fields, and related data, all lightweight, that help in the development of scientific software and scientific machines
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Attributes | List of all members
scifir::dimension Class Reference

Class that represents dimensions of the SI system of units. Each dimension sizes 6 bytes, 1 byte for the dimension type, 1 byte for the prefix, 1 byte for the position (which can be the NUMERATOR or the DENOMINATOR), and 3 bytes for the custom dimension (in case it's used one). A base dimension is a dimension that doesn't has more base dimensions, a derived dimension has always base dimensions from which it's defined. More...

#include <dimension.hpp>

Collaboration diagram for scifir::dimension:
Collaboration graph
[legend]

Public Types

enum  type : int8_t {
  NONE , METRE , DEGREE , RADIAN ,
  STERADIAN , SECOND , GRAM , COULOMB ,
  KELVIN , CELSIUS , MOLE , CANDELA ,
  BYTE , BIT , HERTZ , NEWTON ,
  PASCAL , JOULE , WATT , AMPERE ,
  VOLT , FARAD , OHM , SIEMENS ,
  WEBER , TESLA , HENRY , LUMEN ,
  LUX , BECQUEREL , GRAY , SIEVERT ,
  KATAL , ANGSTROM , LITRE , MINUTE ,
  HOUR , DAY , LIGHT_YEAR , ASTRONOMICAL_UNIT ,
  PARSEC , ELECTRON_VOLT , DALTON , ATOMIC_MASS_UNIT ,
  BARN , MOLARITY , PARTICLES , CUSTOM ,
  CUSTOM_BASIC , CUSTOM_FULL_SYMBOL , MONEY , PIXEL ,
  MEMO , INTERNATIONAL_UNIT , MILLIEQUIVALENT , DECIBEL
}
 Represents a dimension of the SI system of units. All the dimensions of the SI system of units are supported. There are also dimensions supported that aren't considered yet part of the SI system of units, but that are widely used. More...
 
enum  position : int8_t { NO_POSITION , NUMERATOR , DENOMINATOR }
 Represents the position of the dimension, which can be at the numerator or at the denominator. The value NO_POSITION is used when there's no position specified. More...
 

Public Member Functions

 dimension ()
 Default constructor. The dimension_type is NONE, the dimension_position is NO_POSITION, and the prefix is NONE, the symbol is empty.
 
 dimension (const dimension &x)
 Copy constructor. The dimension is initialized to be a copy of the dimension x.
 
 dimension (dimension &&x)
 Move constructor. The dimension is initialized with a move of the dimension x.
 
 dimension (dimension::type new_dimension_type, scifir::prefix::type new_prefix, dimension::position new_position)
 Constructor. The dimension is initialized to the dimension_type, the prefix type and the position given.
 
 dimension (dimension::type new_dimension_type, const scifir::prefix &new_prefix, dimension::position new_position)
 Constructor. The dimension is initialized to the dimension_type, the prefix and the position given.
 
 dimension (const string &init_dimension, dimension::position new_position)
 Constructor. The dimension is initialized with an initialization string of dimension and the position given.
 
dimensionoperator= (const dimension &x)
 Copy assignment. The dimension copies the dimension x.
 
dimensionoperator= (dimension &&x)
 Move assignment. The dimension values are all moved from the dimension x.
 
string get_name () const
 Returns the name of the dimension.
 
string get_fullname () const
 Returns the name of the dimension with the name of the prefix first.
 
string get_plural () const
 Returns the plural of the dimension.
 
string get_fullplural () const
 Returns the plural of the dimension with the name of the prefix first.
 
string get_symbol () const
 Returns the symbol of the dimension. In the case of a custom dimension, it returns the custom dimension defined.
 
long double get_conversion_factor () const
 Returns the conversion factor of the dimension.
 
long double prefix_math () const
 Returns the math between the prefix and the dimension, which varies if the dimension is a B or another. In the case of bytes the math with the prefix is different, it's done with 1024 instead of multiples of 10. It doesn't includes the conversion factor of dimensions.
 
long double prefix_math (const prefix &x_prefix) const
 Returns the math between some prefix and the dimension. The difference with the other prefix_math() function is that the prefix is given as parameter.
 
bool is_simple_dimension () const
 If the dimension doesn't has more base dimensions, it's a simple dimension.
 
bool is_composite_dimension () const
 If the dimension has more simple dimensions, it's a composite dimension.
 
bool is_base_dimension () const
 Returns true if the dimension is a base dimension, which includes all base dimensions of the SI system of units, excepting AMPERE, which has been changed for COULOMB. Additional to the base dimensions of the SI system of units, they are considered base dimensions too RADIAN, STERADIAN, BYTE, MONEY, MEMO, and all CUSTOM_BASIC dimensions.
 
bool is_derived_dimension () const
 If the dimension is not a base dimension, it's considered a derived dimension.
 
bool is_SI_base_dimension () const
 Returns true if the dimension is a SI base dimension. Following the SI system of units, only are base dimensions the METRE, the GRAM, the SECOND, the AMPERE, the KELVIN, the MOLE and the CANDELA.
 
bool is_SI_derived_dimension () const
 If the dimension is not a SI base dimension, it's considered a SI derived dimension.
 
bool is_dimensionless () const
 If the dimension_type is DEGREE, RADIAN or STERADIAN, it's considered dimensionless, following the SI system of units.
 
vector< dimensionget_base_dimensions () const
 Returns the base dimensions of the dimensions, which can be the same dimension or all the base dimension this dimension has, if it's a derived dimension.
 
void invert ()
 Changes the position of the dimension to the reverse, from the NUMERATOR to the DENOMINATOR, or from the DENOMINATOR to the NUMERATOR.
 

Static Public Member Functions

static void create_custom_dimension (const string &new_symbol, const string &init_dimensions)
 Creates a new custom dimension, that's stored with its symbol, which is given as an string, and the base dimensions it has, if this custom dimension is not a new base dimension.
 
static charcreate_full_symbol (const string &full_symbol)
 Creates a new dimension that's stored in the private static map dimension::full_symbols.
 
static string get_full_symbol (const char *x_symbol)
 Returns the symbol of a custom_full_symbol dimension stored in the private static map dimension::full_symbols.
 

Public Attributes

scifir::prefix prefix
 The prefix of the dimension. It's used along with the symbol of the dimension when printing it.
 
dimension::type dimension_type
 The type of the dimension.
 
dimension::position dimension_position
 The position of the dimension, which can be the NUMERATOR, the DENOMINATOR or NO_POSITION. NO_POSITION means that the dimension is not ready to be used, and must be changed if the dimension is intended to be used.
 
char symbol [3]
 The value of the position of the character of a custom dimension in the map of full_symbols.
 

Static Private Attributes

static map< string, vector< dimension > > base_dimensions = map<string,vector<dimension>>()
 
static map< int, stringfull_symbols = map<int,string>()
 
static int total_full_symbols = 0
 
static set< stringprefixes_options {"Q", "R", "Y", "Z", "E", "P", "T", "G", "M", "k", "h", "d", "c", "m", "\u00B5", "u", "n", "p", "f", "a", "z", "y", "r", "q"}
 

Detailed Description

Class that represents dimensions of the SI system of units. Each dimension sizes 6 bytes, 1 byte for the dimension type, 1 byte for the prefix, 1 byte for the position (which can be the NUMERATOR or the DENOMINATOR), and 3 bytes for the custom dimension (in case it's used one). A base dimension is a dimension that doesn't has more base dimensions, a derived dimension has always base dimensions from which it's defined.

Definition at line 30 of file dimension.hpp.

Member Enumeration Documentation

◆ position

Represents the position of the dimension, which can be at the numerator or at the denominator. The value NO_POSITION is used when there's no position specified.

Enumerator
NO_POSITION 

The dimension is not ready and yet being used.

NUMERATOR 

The dimension is at the numerator.

DENOMINATOR 

The dimension is at the denominator.

Definition at line 38 of file dimension.hpp.

@ DENOMINATOR
The dimension is at the denominator.
Definition dimension.hpp:38
@ NO_POSITION
The dimension is not ready and yet being used.
Definition dimension.hpp:38
@ NUMERATOR
The dimension is at the numerator.
Definition dimension.hpp:38

◆ type

Represents a dimension of the SI system of units. All the dimensions of the SI system of units are supported. There are also dimensions supported that aren't considered yet part of the SI system of units, but that are widely used.

Enumerator
NONE 

No dimension. Default value for the default constructor.

METRE 

Meter, plural meters. SI dimension of length. Symbol m.

DEGREE 

Degree, plural degrees. Dimension of angle. Symbol θ.

RADIAN 

Radian, plural radians. Dimension of angle. Special name. Symbol rad.

STERADIAN 

Steradian, plural steradians. Dimension of solid angle. A solid angle is an angle in volume. Special name. Symbol sr.

SECOND 

Second, plural seconds. SI dimension of time. Symbol s.

GRAM 

Gram, plural grams. SI dimension of mass. Symbol g.

COULOMB 

Coulomb, plural coulombs. SI dimension of charge. Special name. Symbol C.

KELVIN 

Kelvin, plural kelvins. SI dimension of temperature. Symbol K.

CELSIUS 

Celsius, plural celsius. SI dimension of temperature, derived from kelvin. Symbol °C. Formula: 1°C = K - 273.15.

MOLE 

Mole, plural moles. SI dimension of quantity. Symbol mol.

CANDELA 

Candela, plural candelas. SI dimension of luminous intensity. Symbol cd.

BYTE 

Byte, plural bytes. Dimension of amount of information. Symbol B.

BIT 

Bit, plural bits. Dimension of amount of information, of each binary digit. Symbol bit.

HERTZ 

Hertz, plural hertz. The derived dimensions are 1 / s. Dimension of frequency. Special name. Symbol Hz.

NEWTON 

Newton, plural newtons. The derived dimensions are kg * m / s2. Dimension of force. Special name. Symbol N.

PASCAL 

Pascal, plural pascals. The derived dimensions are kg / s2 * m. Dimension of pressure. Special name. Symbol Pa.

JOULE 

Joule, plural joules. The derived dimensions are kg * m2 / s2. Dimension of energy. Special name. Symbol J.

WATT 

Watt, plural watts. The derived dimensions are kg * m2 / s3. Dimension of power. Special name. Symbol W.

AMPERE 

Ampere, plural amperes. The derived dimensions are C / s. Dimension of electric current. Symbol A.

VOLT 

Volt, plural volts. The derived dimensions are J / C, W / A. Dimension of voltage. Special name. Symbol V.

FARAD 

Farad, plural farads. The derived dimensions are A * s / V. Dimension of electric capacitance. Special name. Symbol F.

OHM 

Ohm, plural ohms. The derived dimensions are V / A. Dimension of electric resistance. Special name. Symbol Ω.

SIEMENS 

Siemens, plural siemens. The derived dimensions are 1 / Ω. Dimension of electric conductance. Special name. Symbol S.

WEBER 

Weber, plural webers. The derived dimensions are T * m2. Dimension of magnetic flux. Special name. Symbol Wb.

TESLA 

Tesla, plural teslas. The derived dimensions are V * s / m2. Dimension of magnetic strength. Special name. Symbol T.

HENRY 

Henry, plural henries. The derived dimensions are V * s / A. Dimension of electric inductance. Special name. Symbol H.

LUMEN 

Lumen, plural lumens. The derived dimensions are cd * sr Dimension of luminous flux. Special name. Symbol lm.

LUX 

Lux, plural luxes. The derived dimensions are cd * sr / m2. Dimension of illuminance. Special name. Symbol lx.

BECQUEREL 

Becquerel, plural becquerels. The derived dimensions are 1 / s. Dimension of radioactivity. Special name. Symbol Bq.

GRAY 

Gray, plural grays. The derived dimensions are m2 / s2. Dimension of ionising radiation (absorbed dose). Special name. Symbol Gy.

SIEVERT 

Sievert, plural sieverts. The derived dimensions are J / kg. Dimension of ionising radiation (equivalent dose). Special name. Symbol Sv.

KATAL 

Katal, plural katals. The derived dimensions are mol / s. Dimension of catalytic activity. Special name. Symbol kat.

ANGSTROM 

Ángstrom, plural angstroms. The derived dimensions are 10^-10 m. Dimension of length, used mainly for wavelengths. Symbol Å.

LITRE 

Litre, plural litres. The derived dimensions are dm3. Dimension of volume. Symbol L.

MINUTE 

Minute, plural minutes. The derived dimensions are 60 s. Dimension of time. Symbol min.

HOUR 

Hour, plural hours. The derived dimensions are 3,600 s. Dimension of time. Symbol hour, the abbreviation "h" is not used because it would be easy to confuss it with the H of the Henry dimension.

DAY 

Day, plural days. The derived dimensions are 86,400 s. Dimension of time. Symbol day, the abbreviation "d" is not used because it would be easy to confuss it with the d of the deci prefix.

LIGHT_YEAR 

Light year, plural light years. Dimension of length. The derived dimensions are 9,460,730,472,580,800 m. Defined as all the distance travelled by light in one year. Symbol ly.

ASTRONOMICAL_UNIT 

Astronomical unit, plural astronomical units. Dimension of length. The derived dimensions are 149,597,870,700 m. Defined as the distance from the Sun to the Earth. Symbol AU.

PARSEC 

Parsec, plural parsecs. Dimension of length. The derived dimensions are 3.2616 ly. Defined as the distance where 1 AU subtends an angle of 1 second of arc. Equivalent to 3.26156 light years. Symbol pc.

ELECTRON_VOLT 

Electron volt, plural electron volts. The derived dimensions are 1.602176634 * 10^−19 J. Dimension of energy. Symbol eV.

DALTON 

Dalton, plural daltons. The derived dimensions are 1,66053886 * 10^-24. Dimension of mass. Used to measure the mass of atoms and molecules. Defined as 1/12 of a C-12. Symbol Da.

ATOMIC_MASS_UNIT 

Atomic mass unit, plural atomic mass units. The derived dimensions are Da. Equivalent to the Dalton. Dimension of mass. Used to measure the mass of atoms and molecules. Symbol amu.

BARN 

Barn, plural barns. Dimension of area. The derived dimensions are 10^-28 m2. It's used inside nuclear physics to express the transversal section of nucleus and nuclear reactions. Symbol barn.

MOLARITY 

Molarity, plural molarities. The derived dimensions are mol / L. Dimension of concentration of a chemical species. Symbol M.

PARTICLES 

Total of particles, the total amount that the mole represents. It's not exactly a dimension, it corresponds to the brute amount of particles. Symbol particles, it's not exactly a symbol but rather a name for the total of particles.

CUSTOM 

Custom dimension. It means the dimension is a custom dimension, which can have any value and meaning, defined freely by the programmer. Each custom dimension is unique to where it's defined and used.

CUSTOM_BASIC 
CUSTOM_FULL_SYMBOL 

Custom dimension. It's identical to a CUSTOM dimension in his use, but its symbol is stored in the static map full_symbols of dimension class. All symbols greather than two are stored there, because they don't fit in the member-variable char symbol[3] of dimension class.

MONEY 

Money, plural money. The money is not specified in a specific currency, you must use the ISO 4217 of currencies for that purpose. Don't mistake mixing different currencies. Symbol money.

PIXEL 

Pixel, plural pixels. it represents the amount of pixels, it can be used as a replacemet of the metre inside a screen. It can also be used as distance, in replacement of length dimensions, if in a virtual space it's thinked in pixels instead of normal dimensions of length. Symbol px.

MEMO 

Memo, plural memos. Invented unit inside Scifir, it's not part of the SI system of units. It represents a unit of human or animal memory. Each memory of the brain has some size hypothetically measurable in memos. Symbol memo.

INTERNATIONAL_UNIT 

International unit, plural international units. It measures the amount of effect or biological activity of a substance, for the purpose of easier comparison across similar forms of substances. The international units aren't part of the SI system of units. Symbol IU.

MILLIEQUIVALENT 

Milliequivalent, plural Milliequivalents. Amount of moles in a given chemical reaction needed to react with an amount of moles of another substance. Symbol mEq.

DECIBEL 

Definition at line 33 of file dimension.hpp.

34 {
36 };
@ MOLARITY
Molarity, plural molarities. The derived dimensions are mol / L. Dimension of concentration of a chem...
Definition dimension.hpp:35
@ NONE
No dimension. Default value for the default constructor.
Definition dimension.hpp:35
@ BECQUEREL
Becquerel, plural becquerels. The derived dimensions are 1 / s. Dimension of radioactivity....
Definition dimension.hpp:35
@ KATAL
Katal, plural katals. The derived dimensions are mol / s. Dimension of catalytic activity....
Definition dimension.hpp:35
@ LITRE
Litre, plural litres. The derived dimensions are dm3. Dimension of volume. Symbol L.
Definition dimension.hpp:35
@ LUMEN
Lumen, plural lumens. The derived dimensions are cd * sr Dimension of luminous flux....
Definition dimension.hpp:35
@ MEMO
Memo, plural memos. Invented unit inside Scifir, it's not part of the SI system of units....
Definition dimension.hpp:35
@ STERADIAN
Steradian, plural steradians. Dimension of solid angle. A solid angle is an angle in volume....
Definition dimension.hpp:35
@ TESLA
Tesla, plural teslas. The derived dimensions are V * s / m2. Dimension of magnetic strength....
Definition dimension.hpp:35
@ INTERNATIONAL_UNIT
International unit, plural international units. It measures the amount of effect or biological activi...
Definition dimension.hpp:35
@ BARN
Barn, plural barns. Dimension of area. The derived dimensions are 10^-28 m2. It's used inside nuclear...
Definition dimension.hpp:35
@ LIGHT_YEAR
Light year, plural light years. Dimension of length. The derived dimensions are 9,...
Definition dimension.hpp:35
@ HENRY
Henry, plural henries. The derived dimensions are V * s / A. Dimension of electric inductance....
Definition dimension.hpp:35
@ AMPERE
Ampere, plural amperes. The derived dimensions are C / s. Dimension of electric current....
Definition dimension.hpp:35
@ MOLE
Mole, plural moles. SI dimension of quantity. Symbol mol.
Definition dimension.hpp:35
@ CUSTOM_FULL_SYMBOL
Custom dimension. It's identical to a CUSTOM dimension in his use, but its symbol is stored in the st...
Definition dimension.hpp:35
@ VOLT
Volt, plural volts. The derived dimensions are J / C, W / A. Dimension of voltage....
Definition dimension.hpp:35
@ OHM
Ohm, plural ohms. The derived dimensions are V / A. Dimension of electric resistance....
Definition dimension.hpp:35
@ COULOMB
Coulomb, plural coulombs. SI dimension of charge. Special name. Symbol C.
Definition dimension.hpp:35
@ LUX
Lux, plural luxes. The derived dimensions are cd * sr / m2. Dimension of illuminance....
Definition dimension.hpp:35
@ GRAY
Gray, plural grays. The derived dimensions are m2 / s2. Dimension of ionising radiation (absorbed dos...
Definition dimension.hpp:35
@ ANGSTROM
Ángstrom, plural angstroms. The derived dimensions are 10^-10 m. Dimension of length,...
Definition dimension.hpp:35
@ ELECTRON_VOLT
Electron volt, plural electron volts. The derived dimensions are 1.602176634 * 10^−19 J....
Definition dimension.hpp:35
@ GRAM
Gram, plural grams. SI dimension of mass. Symbol g.
Definition dimension.hpp:35
@ SIEVERT
Sievert, plural sieverts. The derived dimensions are J / kg. Dimension of ionising radiation (equival...
Definition dimension.hpp:35
@ DALTON
Dalton, plural daltons. The derived dimensions are 1,66053886 * 10^-24. Dimension of mass....
Definition dimension.hpp:35
@ MILLIEQUIVALENT
Milliequivalent, plural Milliequivalents. Amount of moles in a given chemical reaction needed to reac...
Definition dimension.hpp:35
@ CELSIUS
Celsius, plural celsius. SI dimension of temperature, derived from kelvin. Symbol °C....
Definition dimension.hpp:35
@ DEGREE
Degree, plural degrees. Dimension of angle. Symbol θ.
Definition dimension.hpp:35
@ PASCAL
Pascal, plural pascals. The derived dimensions are kg / s2 * m. Dimension of pressure....
Definition dimension.hpp:35
@ PIXEL
Pixel, plural pixels. it represents the amount of pixels, it can be used as a replacemet of the metre...
Definition dimension.hpp:35
@ ATOMIC_MASS_UNIT
Atomic mass unit, plural atomic mass units. The derived dimensions are Da. Equivalent to the Dalton....
Definition dimension.hpp:35
@ ASTRONOMICAL_UNIT
Astronomical unit, plural astronomical units. Dimension of length. The derived dimensions are 149,...
Definition dimension.hpp:35
@ HERTZ
Hertz, plural hertz. The derived dimensions are 1 / s. Dimension of frequency. Special name....
Definition dimension.hpp:35
@ DAY
Day, plural days. The derived dimensions are 86,400 s. Dimension of time. Symbol day,...
Definition dimension.hpp:35
@ WATT
Watt, plural watts. The derived dimensions are kg * m2 / s3. Dimension of power. Special name....
Definition dimension.hpp:35
@ NEWTON
Newton, plural newtons. The derived dimensions are kg * m / s2. Dimension of force....
Definition dimension.hpp:35
@ HOUR
Hour, plural hours. The derived dimensions are 3,600 s. Dimension of time. Symbol hour,...
Definition dimension.hpp:35
@ PARTICLES
Total of particles, the total amount that the mole represents. It's not exactly a dimension,...
Definition dimension.hpp:35
@ MONEY
Money, plural money. The money is not specified in a specific currency, you must use the ISO 4217 of ...
Definition dimension.hpp:35
@ BIT
Bit, plural bits. Dimension of amount of information, of each binary digit. Symbol bit.
Definition dimension.hpp:35
@ SECOND
Second, plural seconds. SI dimension of time. Symbol s.
Definition dimension.hpp:35
@ MINUTE
Minute, plural minutes. The derived dimensions are 60 s. Dimension of time. Symbol min.
Definition dimension.hpp:35
@ CANDELA
Candela, plural candelas. SI dimension of luminous intensity. Symbol cd.
Definition dimension.hpp:35
@ RADIAN
Radian, plural radians. Dimension of angle. Special name. Symbol rad.
Definition dimension.hpp:35
@ BYTE
Byte, plural bytes. Dimension of amount of information. Symbol B.
Definition dimension.hpp:35
@ SIEMENS
Siemens, plural siemens. The derived dimensions are 1 / Ω. Dimension of electric conductance....
Definition dimension.hpp:35
@ JOULE
Joule, plural joules. The derived dimensions are kg * m2 / s2. Dimension of energy....
Definition dimension.hpp:35
@ FARAD
Farad, plural farads. The derived dimensions are A * s / V. Dimension of electric capacitance....
Definition dimension.hpp:35
@ WEBER
Weber, plural webers. The derived dimensions are T * m2. Dimension of magnetic flux....
Definition dimension.hpp:35
@ KELVIN
Kelvin, plural kelvins. SI dimension of temperature. Symbol K.
Definition dimension.hpp:35
@ METRE
Meter, plural meters. SI dimension of length. Symbol m.
Definition dimension.hpp:35
@ PARSEC
Parsec, plural parsecs. Dimension of length. The derived dimensions are 3.2616 ly....
Definition dimension.hpp:35
@ CUSTOM
Custom dimension. It means the dimension is a custom dimension, which can have any value and meaning,...
Definition dimension.hpp:35

Constructor & Destructor Documentation

◆ dimension() [1/6]

dimension::dimension ( )

Default constructor. The dimension_type is NONE, the dimension_position is NO_POSITION, and the prefix is NONE, the symbol is empty.

Definition at line 27 of file dimension.cpp.

28 {}
scifir::prefix prefix
The prefix of the dimension. It's used along with the symbol of the dimension when printing it.
Definition dimension.hpp:74
dimension::position dimension_position
The position of the dimension, which can be the NUMERATOR, the DENOMINATOR or NO_POSITION....
Definition dimension.hpp:76
char symbol[3]
The value of the position of the character of a custom dimension in the map of full_symbols.
Definition dimension.hpp:77
dimension::type dimension_type
The type of the dimension.
Definition dimension.hpp:75

◆ dimension() [2/6]

dimension::dimension ( const dimension x)

Copy constructor. The dimension is initialized to be a copy of the dimension x.

◆ dimension() [3/6]

dimension::dimension ( dimension &&  x)

Move constructor. The dimension is initialized with a move of the dimension x.

◆ dimension() [4/6]

dimension::dimension ( dimension::type  new_dimension_type,
scifir::prefix::type  new_prefix,
dimension::position  new_position 
)
explicit

Constructor. The dimension is initialized to the dimension_type, the prefix type and the position given.

Definition at line 52 of file dimension.cpp.

52 : prefix(new_prefix),dimension_type(new_dimension_type),dimension_position(new_position),symbol()
53 {}

◆ dimension() [5/6]

dimension::dimension ( dimension::type  new_dimension_type,
const scifir::prefix new_prefix,
dimension::position  new_position 
)
explicit

Constructor. The dimension is initialized to the dimension_type, the prefix and the position given.

Definition at line 55 of file dimension.cpp.

55 : prefix(new_prefix),dimension_type(new_dimension_type),dimension_position(new_position),symbol()
56 {}

◆ dimension() [6/6]

dimension::dimension ( const string init_dimension,
dimension::position  new_position 
)
explicit

Constructor. The dimension is initialized with an initialization string of dimension and the position given.

Definition at line 58 of file dimension.cpp.

59 {
60 string dimension_name;
61 string prefix_name;
62 if(dimension::prefixes_options.count(init_dimension.substr(0,1)) and init_dimension != "degree" and init_dimension != "rad" and init_dimension != "sr" and init_dimension != "m" and init_dimension != "Hz" and init_dimension != "Pa" and init_dimension.substr(0,2) != "da" and init_dimension != "°C" and init_dimension.substr(0,3) != "mol" and init_dimension != "cd" and init_dimension != "Ω" and init_dimension != "Ohm" and init_dimension != "ohm" and init_dimension != "T" and init_dimension != "Gy" and init_dimension != "kat" and init_dimension != "Å" and init_dimension != "angstrom" and init_dimension != "min" and init_dimension != "hour" and init_dimension != "day" and init_dimension != "pc" and init_dimension != "amu" and init_dimension != "M" and init_dimension != "particles" and init_dimension != "money" and init_dimension != "px" and init_dimension != "memo" and init_dimension != "mEq" and init_dimension != "dB")
63 {
64 prefix_name = init_dimension.substr(0,1);
65 dimension_name = init_dimension.substr(1);
66 }
67 else if(init_dimension == "day")
68 {
69 prefix_name = "";
70 dimension_name = init_dimension;
71 }
72 else if(init_dimension.substr(0,2) == "da")
73 {
74 prefix_name = "da";
75 dimension_name = init_dimension.substr(2);
76 }
77 else
78 {
79 prefix_name = "";
80 dimension_name = init_dimension;
81 }
82 prefix = scifir::prefix(prefix_name);
83 if(dimension_name == "m")
84 {
86 }
87 else if(dimension_name == "degree" or dimension_name == "θ")
88 {
90 }
91 else if(dimension_name == "rad")
92 {
94 }
95 else if(dimension_name == "sr")
96 {
98 }
99 else if(dimension_name == "s")
100 {
102 }
103 else if(dimension_name == "g")
104 {
106 }
107 else if(dimension_name == "C")
108 {
110 }
111 else if(dimension_name == "K")
112 {
114 }
115 else if(dimension_name == "°C")
116 {
118 }
119 else if(dimension_name == "mol")
120 {
122 }
123 else if(dimension_name == "cd")
124 {
126 }
127 else if(dimension_name == "B")
128 {
130 }
131 else if(dimension_name == "bit")
132 {
134 }
135 else if(dimension_name == "Hz")
136 {
138 }
139 else if(dimension_name == "N")
140 {
142 }
143 else if(dimension_name == "Pa")
144 {
146 }
147 else if(dimension_name == "J")
148 {
150 }
151 else if(dimension_name == "W")
152 {
154 }
155 else if(dimension_name == "A")
156 {
158 }
159 else if(dimension_name == "V")
160 {
162 }
163 else if(dimension_name == "F")
164 {
166 }
167 else if(dimension_name == "ohm" or dimension_name == "Ohm" or dimension_name == "Ω")
168 {
170 }
171 else if(dimension_name == "S")
172 {
174 }
175 else if(dimension_name == "Wb")
176 {
178 }
179 else if(dimension_name == "T")
180 {
182 }
183 else if(dimension_name == "H")
184 {
186 }
187 else if(dimension_name == "lm")
188 {
190 }
191 else if(dimension_name == "lx")
192 {
194 }
195 else if(dimension_name == "Bq")
196 {
198 }
199 else if(dimension_name == "Gy")
200 {
202 }
203 else if(dimension_name == "Sv")
204 {
206 }
207 else if(dimension_name == "kat")
208 {
210 }
211 else if(dimension_name == "angstrom" or dimension_name == "Å")
212 {
214 }
215 else if(dimension_name == "L")
216 {
218 }
219 else if(dimension_name == "min")
220 {
222 }
223 else if(dimension_name == "hour")
224 {
226 }
227 else if(dimension_name == "day")
228 {
230 }
231 else if(dimension_name == "ly")
232 {
234 }
235 else if(dimension_name == "AU")
236 {
238 }
239 else if(dimension_name == "pc")
240 {
242 }
243 else if(dimension_name == "eV")
244 {
246 }
247 else if(dimension_name == "Da")
248 {
250 }
251 else if(dimension_name == "amu")
252 {
254 }
255 else if(dimension_name == "barn")
256 {
258 }
259 else if(dimension_name == "M")
260 {
262 }
263 else if(dimension_name == "particles")
264 {
266 }
267 else if(dimension_name == "money")
268 {
270 }
271 else if(dimension_name == "px")
272 {
274 }
275 else if(dimension_name == "memo")
276 {
278 }
279 else if(dimension_name == "IU")
280 {
282 }
283 else if(dimension_name == "mEq")
284 {
286 }
287 else if(dimension_name == "dB")
288 {
290 }
291 else if(dimension_name == "")
292 {
294 }
295 else
296 {
298 if (init_dimension.size() > 2)
299 {
300 string symbol_abreviation = dimension::create_full_symbol(init_dimension);
301#ifdef IS_UNIX
302 std::strncpy(symbol, symbol_abreviation.c_str(), 2);
303#elif IS_WINDOWS
304 strncpy_s(symbol, 3, symbol_abreviation.c_str(), 2);
305#endif
307 }
308 else
309 {
310#ifdef IS_UNIX
311 std::strncpy(symbol, init_dimension.c_str(), 2);
312#elif IS_WINDOWS
313 strncpy_s(symbol, 3, init_dimension.c_str(), 2);
314#endif
316 }
317 }
318 }
static set< string > prefixes_options
static char * create_full_symbol(const string &full_symbol)
Creates a new dimension that's stored in the private static map dimension::full_symbols.
Definition dimension.hpp:87
Class that represents prefixes of the SI system of units. Each prefix sizes 1 byte....
Definition prefix.hpp:14
@ NONE
There is no prefix. Then, the dimension is not increased or decreased by some factor.
Definition prefix.hpp:16

Member Function Documentation

◆ create_custom_dimension()

static void dimension::create_custom_dimension ( const string new_symbol,
const string init_dimensions 
)
inlinestatic

Creates a new custom dimension, that's stored with its symbol, which is given as an string, and the base dimensions it has, if this custom dimension is not a new base dimension.

Definition at line 79 of file dimension.hpp.

80 {
81 if (dimension::base_dimensions.count(new_symbol) == 0)
82 {
83 dimension::base_dimensions[new_symbol] = create_base_dimensions(init_dimensions);
84 }
85 }
static map< string, vector< dimension > > base_dimensions
vector< dimension > create_base_dimensions(const string &init_dimensions)
Creates the base dimensions from an initialization string of dimensions.

◆ create_full_symbol()

static char * dimension::create_full_symbol ( const string full_symbol)
inlinestatic

Creates a new dimension that's stored in the private static map dimension::full_symbols.

Definition at line 87 of file dimension.hpp.

88 {
89 char symbol_abbreviation[3] = "";
91 if (total_full_symbols <= 255)
92 {
93 if (total_full_symbols <= 32)
94 {
96 }
97 symbol_abbreviation[0] = char(total_full_symbols);
98 symbol_abbreviation[1] = '\n';
99 symbol_abbreviation[2] = '\n';
100 }
101 else if (total_full_symbols <= 65535)
102 {
103 int char_code1 = (total_full_symbols / 256);
104 if (char_code1 <= 32)
105 {
106 char_code1 = 33;
107 }
108 symbol_abbreviation[0] += char(char_code1);
109 int closest_number = int(floor(total_full_symbols / 256.0)) * 256;
110 int char_code2 = total_full_symbols - closest_number;
111 if (char_code2 <= 32)
112 {
113 char_code2 = 33;
114 }
115 symbol_abbreviation[1] += char(char_code2);
116 symbol_abbreviation[2] = '\n';
117 }
118 else
119 {
120 int char_code1 = (total_full_symbols / 65536);
121 if (char_code1 <= 32)
122 {
123 char_code1 = 33;
124 }
125 symbol_abbreviation[0] += char(char_code1);
126 int closest_number = int(floor(total_full_symbols / 65536.0)) * 65536;
127 int char_code2 = total_full_symbols - closest_number;
128 if (char_code2 <= 32)
129 {
130 char_code2 = 33;
131 }
132 symbol_abbreviation[1] += char(char_code2);
133 int closest_number2 = int(floor(total_full_symbols / 256.0)) * 256;
134 int char_code3 = total_full_symbols - closest_number2;
135 if (char_code3 <= 32)
136 {
137 char_code3 = 33;
138 }
139 symbol_abbreviation[2] += char(char_code3);
140 }
141 full_symbols[total_full_symbols] = full_symbol;
142 return new char[3]{symbol_abbreviation[0],symbol_abbreviation[1],symbol_abbreviation[2]};
143 }
static int total_full_symbols
static map< int, string > full_symbols

◆ get_base_dimensions()

vector< dimension > dimension::get_base_dimensions ( ) const

Returns the base dimensions of the dimensions, which can be the same dimension or all the base dimension this dimension has, if it's a derived dimension.

Definition at line 1396 of file dimension.cpp.

1397 {
1398 vector<dimension> basic_dimensions = vector<dimension>();
1399 switch (dimension_type)
1400 {
1401 case dimension::NONE:
1402 basic_dimensions.push_back(dimension(dimension::NONE,prefix::NONE,dimension::NUMERATOR));
1403 break;
1404 case dimension::METRE:
1405 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1406 break;
1407 case dimension::DEGREE:
1408 basic_dimensions.push_back(dimension(dimension::RADIAN,prefix::NONE,dimension::NUMERATOR));
1409 break;
1410 case dimension::RADIAN:
1411 basic_dimensions.push_back(dimension(dimension::RADIAN,prefix::NONE,dimension::NUMERATOR));
1412 break;
1415 break;
1416 case dimension::SECOND:
1417 basic_dimensions.push_back(dimension(dimension::SECOND,prefix::NONE,dimension::NUMERATOR));
1418 break;
1419 case dimension::GRAM:
1420 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::NONE,dimension::NUMERATOR));
1421 break;
1422 case dimension::COULOMB:
1424 break;
1425 case dimension::KELVIN:
1426 basic_dimensions.push_back(dimension(dimension::KELVIN,prefix::NONE,dimension::NUMERATOR));
1427 break;
1428 case dimension::CELSIUS:
1429 basic_dimensions.push_back(dimension(dimension::KELVIN,prefix::NONE,dimension::NUMERATOR));
1430 break;
1431 case dimension::MOLE:
1432 basic_dimensions.push_back(dimension(dimension::MOLE,prefix::NONE,dimension::NUMERATOR));
1433 break;
1434 case dimension::CANDELA:
1436 break;
1437 case dimension::BYTE:
1438 basic_dimensions.push_back(dimension(dimension::BYTE,prefix::NONE,dimension::NUMERATOR));
1439 break;
1440 case dimension::BIT:
1441 basic_dimensions.push_back(dimension(dimension::BYTE,prefix::NONE,dimension::NUMERATOR));
1442 break;
1443 case dimension::HERTZ:
1445 break;
1446 case dimension::NEWTON:
1447 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::NUMERATOR));
1448 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1451 break;
1452 case dimension::PASCAL:
1453 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::NUMERATOR));
1457 break;
1458 case dimension::JOULE:
1459 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::NUMERATOR));
1460 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1461 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1464 break;
1465 case dimension::WATT:
1466 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::NUMERATOR));
1467 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1468 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1472 break;
1473 case dimension::AMPERE:
1476 break;
1477 case dimension::VOLT:
1478 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::NUMERATOR));
1479 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1480 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1484 break;
1485 case dimension::FARAD:
1486 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::DENOMINATOR));
1491 basic_dimensions.push_back(dimension(dimension::SECOND,prefix::NONE,dimension::NUMERATOR));
1492 basic_dimensions.push_back(dimension(dimension::SECOND,prefix::NONE,dimension::NUMERATOR));
1493 break;
1494 case dimension::OHM:
1495 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::NUMERATOR));
1496 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1497 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1501 break;
1502 case dimension::SIEMENS:
1505 basic_dimensions.push_back(dimension(dimension::SECOND,prefix::NONE,dimension::NUMERATOR));
1506 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::DENOMINATOR));
1509 break;
1510 case dimension::WEBER:
1511 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::NUMERATOR));
1512 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1513 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1516 break;
1517 case dimension::TESLA:
1518 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::NUMERATOR));
1521 break;
1522 case dimension::HENRY:
1523 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::NUMERATOR));
1524 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1525 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1528 break;
1529 case dimension::LUMEN:
1532 break;
1533 case dimension::LUX:
1538 break;
1541 break;
1542 case dimension::GRAY:
1543 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1544 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1547 break;
1548 case dimension::SIEVERT:
1549 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1550 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1553 break;
1554 case dimension::KATAL:
1555 basic_dimensions.push_back(dimension(dimension::MOLE,prefix::NONE,dimension::NUMERATOR));
1557 break;
1559 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1560 break;
1561 case dimension::LITRE:
1562 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1563 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1564 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1565 break;
1566 case dimension::MINUTE:
1567 basic_dimensions.push_back(dimension(dimension::SECOND,prefix::NONE,dimension::NUMERATOR));
1568 break;
1569 case dimension::HOUR:
1570 basic_dimensions.push_back(dimension(dimension::SECOND,prefix::NONE,dimension::NUMERATOR));
1571 break;
1572 case dimension::DAY:
1573 basic_dimensions.push_back(dimension(dimension::SECOND,prefix::NONE,dimension::NUMERATOR));
1574 break;
1576 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1577 break;
1579 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1580 break;
1581 case dimension::PARSEC:
1582 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1583 break;
1585 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1586 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1587 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::NUMERATOR));
1590 break;
1591 case dimension::DALTON:
1592 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::KILO,dimension::NUMERATOR));
1593 break;
1595 basic_dimensions.push_back(dimension(dimension::GRAM,prefix::NONE,dimension::NUMERATOR));
1596 break;
1597 case dimension::BARN:
1598 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1599 basic_dimensions.push_back(dimension(dimension::METRE,prefix::NONE,dimension::NUMERATOR));
1600 break;
1602 basic_dimensions.push_back(dimension(dimension::MOLE,prefix::NONE,dimension::NUMERATOR));
1606 break;
1608 basic_dimensions.push_back(dimension(dimension::MOLE,prefix::NONE,dimension::NUMERATOR));
1609 break;
1610 case dimension::CUSTOM:
1611 {
1612 //return dimension::base_dimensions[symbol];
1613 break;
1614 }
1616 {
1617 basic_dimensions.push_back(*this);
1618 break;
1619 }
1621 {
1622 break;
1623 //return dimension::base_dimensions[dimension::get_full_symbol(symbol)];
1624 }
1625 case dimension::MONEY:
1626 basic_dimensions.push_back(dimension(dimension::MONEY,prefix::NONE,dimension::NUMERATOR));
1627 break;
1628 case dimension::PIXEL:
1629 basic_dimensions.push_back(dimension(dimension::PIXEL,prefix::NONE,dimension::NUMERATOR));
1630 break;
1631 case dimension::MEMO:
1632 basic_dimensions.push_back(dimension(dimension::MEMO,prefix::NONE,dimension::NUMERATOR));
1633 break;
1636 break;
1639 break;
1640 case dimension::DECIBEL:
1642 break;
1643 }
1644 return basic_dimensions;
1645 }
dimension()
Default constructor. The dimension_type is NONE, the dimension_position is NO_POSITION,...
Definition dimension.cpp:27
@ KILO
Prefix of a factor of 10^3.
Definition prefix.hpp:16

◆ get_conversion_factor()

long double dimension::get_conversion_factor ( ) const

Returns the conversion factor of the dimension.

Definition at line 743 of file dimension.cpp.

744 {
745 switch(dimension_type)
746 {
747 case dimension::NONE:
748 return 1.0l;
749 case dimension::METRE:
750 return 1.0l;
752 return std::numbers::pi_v<float> / 180.0l;
754 return 1.0l;
756 return 1.0l;
757 case dimension::GRAM:
758 return 1.0l;
760 return 1.0l;
762 return 1.0l;
764 return 1.0l;
766 return 1.0l;
767 case dimension::MOLE:
768 return 1.0l;
770 return 1.0l;
771 case dimension::BYTE:
772 return 1.0l;
773 case dimension::BIT:
774 return 0.125l;
775 case dimension::HERTZ:
776 return 1.0l;
778 return 1.0l;
780 return 1.0l;
781 case dimension::JOULE:
782 return 1.0l;
783 case dimension::WATT:
784 return 1.0l;
786 return 1.0l;
787 case dimension::VOLT:
788 return 1.0l;
789 case dimension::FARAD:
790 return 1;
791 case dimension::OHM:
792 return 1.0l;
794 return 1.0l;
795 case dimension::WEBER:
796 return 1.0l;
797 case dimension::TESLA:
798 return 1.0l;
799 case dimension::HENRY:
800 return 1.0l;
801 case dimension::LUMEN:
802 return 1.0l;
803 case dimension::LUX:
804 return 1.0l;
806 return 1.0l;
807 case dimension::GRAY:
808 return 1.0l;
810 return 1.0l;
811 case dimension::KATAL:
812 return 1.0l;
814 return 1.0l;
815 case dimension::LITRE:
816 return 1.0l;
818 return 60l;
819 case dimension::HOUR:
820 return 3600l;
821 case dimension::DAY:
822 return 86400l;
824 return 9.4607379375591e15;
826 return 149597870700.0l;
828 return 30856775814913673.0l;
830 return 0.0000000000000000001602176634l;
832 return 0.00000000000000000000000000166053886l;
834 return 0.00000000000000000000000000166053886l;
835 case dimension::BARN:
836 return 0.0000000000000000000000000001l;
838 return 1.0l;
840 return 1.0l/AVOGADRO_CONSTANT;
842 return 1.0l;
844 return 1.0l;
846 return 1.0l;
847 case dimension::MONEY:
848 return 1.0l;
849 case dimension::PIXEL:
850 return 1.0l;
851 case dimension::MEMO:
852 return 1.0l;
854 return 1.0l;
856 return 1.0l;
858 return 1.0l;
859 }
860 return 1.0l;
861 }
const long double AVOGADRO_CONSTANT
Definition constants.hpp:15

◆ get_full_symbol()

static string dimension::get_full_symbol ( const char x_symbol)
inlinestatic

Returns the symbol of a custom_full_symbol dimension stored in the private static map dimension::full_symbols.

Definition at line 145 of file dimension.hpp.

146 {
147 int symbol_code;
148 if (x_symbol[1] == '\n')
149 {
150 symbol_code = int(x_symbol[0]);
151 }
152 else if (x_symbol[2] == '\n')
153 {
154 symbol_code = int(x_symbol[0]) * 256;
155 symbol_code += int(x_symbol[1]);
156 }
157 else
158 {
159 symbol_code = int(x_symbol[0]) * 65536;
160 symbol_code += int(x_symbol[1]) * 256;
161 symbol_code += int(x_symbol[2]);
162 }
163 return full_symbols[symbol_code];
164 }

◆ get_fullname()

string dimension::get_fullname ( ) const

Returns the name of the dimension with the name of the prefix first.

Definition at line 478 of file dimension.cpp.

479 {
480 return prefix.get_name() + get_name();
481 }
string get_name() const
Returns the name of the dimension.
string get_name() const
Name of the prefix given the prefix_type.
Definition prefix.cpp:94

◆ get_fullplural()

string dimension::get_fullplural ( ) const

Returns the plural of the dimension with the name of the prefix first.

Definition at line 603 of file dimension.cpp.

604 {
605 return prefix.get_name() + get_plural();
606 }
string get_plural() const
Returns the plural of the dimension.

◆ get_name()

string dimension::get_name ( ) const

Returns the name of the dimension.

Definition at line 358 of file dimension.cpp.

359 {
360 switch(dimension_type)
361 {
362 case dimension::NONE:
363 return "empty";
364 case dimension::METRE:
365 return "metre";
367 return "degree";
369 return "radian";
371 return "steradian";
373 return "second";
374 case dimension::GRAM:
375 return "gram";
377 return "coulomb";
379 return "kelvin";
381 return "celsius";
382 case dimension::MOLE:
383 return "mole";
385 return "candela";
386 case dimension::BYTE:
387 return "byte";
388 case dimension::BIT:
389 return "bit";
390 case dimension::HERTZ:
391 return "hertz";
393 return "newton";
395 return "pascal";
396 case dimension::JOULE:
397 return "joule";
398 case dimension::WATT:
399 return "watt";
401 return "ampere";
402 case dimension::VOLT:
403 return "volt";
404 case dimension::FARAD:
405 return "farad";
406 case dimension::OHM:
407 return "ohm";
409 return "siemens";
410 case dimension::WEBER:
411 return "weber";
412 case dimension::TESLA:
413 return "tesla";
414 case dimension::HENRY:
415 return "henry";
416 case dimension::LUMEN:
417 return "lumen";
418 case dimension::LUX:
419 return "lux";
421 return "becquerel";
422 case dimension::GRAY:
423 return "gray";
425 return "sievert";
426 case dimension::KATAL:
427 return "katal";
429 return "angstrom";
430 case dimension::LITRE:
431 return "litre";
433 return "minute";
434 case dimension::HOUR:
435 return "hour";
436 case dimension::DAY:
437 return "day";
439 return "light year";
441 return "astronomical unit";
443 return "parsec";
445 return "electron volt";
447 return "dalton";
449 return "atomic mass unit";
450 case dimension::BARN:
451 return "barn";
453 return "molarity";
455 return "particles";
457 return "custom-dimension";
459 return "custom-basic";
461 return "custom-full-symbol";
462 case dimension::MONEY:
463 return "money";
464 case dimension::PIXEL:
465 return "pixel";
466 case dimension::MEMO:
467 return "memo";
469 return "international-unit";
471 return "milliequivalent";
473 return "decibel";
474 }
475 return "";
476 }

◆ get_plural()

string dimension::get_plural ( ) const

Returns the plural of the dimension.

Definition at line 483 of file dimension.cpp.

484 {
485 switch(dimension_type)
486 {
487 case dimension::NONE:
488 return "empty";
489 case dimension::METRE:
490 return "metres";
492 return "degrees";
494 return "radians";
496 return "steradians";
498 return "seconds";
499 case dimension::GRAM:
500 return "grams";
502 return "coulombs";
504 return "kelvins";
506 return "celsius";
507 case dimension::MOLE:
508 return "moles";
510 return "candelas";
511 case dimension::BYTE:
512 return "bytes";
513 case dimension::BIT:
514 return "bits";
515 case dimension::HERTZ:
516 return "hertz";
518 return "newtons";
520 return "pascals";
521 case dimension::JOULE:
522 return "joules";
523 case dimension::WATT:
524 return "watts";
526 return "amperes";
527 case dimension::VOLT:
528 return "volts";
529 case dimension::FARAD:
530 return "farads";
531 case dimension::OHM:
532 return "ohms";
534 return "siemens";
535 case dimension::WEBER:
536 return "webers";
537 case dimension::TESLA:
538 return "teslas";
539 case dimension::HENRY:
540 return "henries";
541 case dimension::LUMEN:
542 return "lumens";
543 case dimension::LUX:
544 return "luxes";
546 return "becquerels";
547 case dimension::GRAY:
548 return "grays";
550 return "sieverts";
551 case dimension::KATAL:
552 return "katals";
554 return "angstroms";
555 case dimension::LITRE:
556 return "litres";
558 return "minutes";
559 case dimension::HOUR:
560 return "hours";
561 case dimension::DAY:
562 return "days";
564 return "light years";
566 return "astronomical units";
568 return "parsecs";
570 return "electron volts";
572 return "daltons";
574 return "atomic mass units";
575 case dimension::BARN:
576 return "barns";
578 return "molarities";
580 return "particles";
582 return "custom-dimension";
584 return "custom-basic";
586 return "custom-full-symbol";
587 case dimension::MONEY:
588 return "money";
589 case dimension::PIXEL:
590 return "pixels";
591 case dimension::MEMO:
592 return "memos";
594 return "international-units";
596 return "milliequivalents";
598 return "decibels";
599 }
600 return "";
601 }

◆ get_symbol()

string dimension::get_symbol ( ) const

Returns the symbol of the dimension. In the case of a custom dimension, it returns the custom dimension defined.

Definition at line 608 of file dimension.cpp.

609 {
610 switch(dimension_type)
611 {
612 case dimension::NONE:
613 return "empty";
614 case dimension::METRE:
615 return "m";
616#ifdef IS_UNIX
618 return "θ";
619#elif IS_WINDOWS
621 return "θ";
622#endif
624 return "rad";
626 return "sr";
628 return "s";
629 case dimension::GRAM:
630 return "g";
632 return "C";
634 return "K";
636 return "°C";
637 case dimension::MOLE:
638 return "mol";
640 return "cd";
641 case dimension::BYTE:
642 return "B";
643 case dimension::BIT:
644 return "bit";
645 case dimension::HERTZ:
646 return "Hz";
648 return "N";
650 return "Pa";
651 case dimension::JOULE:
652 return "J";
653 case dimension::WATT:
654 return "W";
656 return "A";
657 case dimension::VOLT:
658 return "V";
659 case dimension::FARAD:
660 return "F";
661#ifdef IS_UNIX
662 case dimension::OHM:
663 return "Ω";
664#elif IS_WINDOWS
665 case dimension::OHM:
666 return "Ω";
667#endif
669 return "S";
670 case dimension::WEBER:
671 return "Wb";
672 case dimension::TESLA:
673 return "T";
674 case dimension::HENRY:
675 return "H";
676 case dimension::LUMEN:
677 return "lm";
678 case dimension::LUX:
679 return "lx";
681 return "Bq";
682 case dimension::GRAY:
683 return "Gy";
685 return "Sv";
686 case dimension::KATAL:
687 return "kat";
688#ifdef IS_UNIX
690 return "Å";
691#elif IS_WINDOWS
693 return "Å";
694#endif
695 case dimension::LITRE:
696 return "L";
698 return "min";
699 case dimension::HOUR:
700 return "hour";
701 case dimension::DAY:
702 return "day";
704 return "ly";
706 return "AU";
708 return "pc";
710 return "eV";
712 return "Da";
714 return "amu";
715 case dimension::BARN:
716 return "barn";
718 return "M";
720 return "particles";
722 return string("").assign(symbol, symbol + 3);
724 return "custom-basic";
727 case dimension::MONEY:
728 return "money";
729 case dimension::PIXEL:
730 return "px";
731 case dimension::MEMO:
732 return "memo";
734 return "IU";
736 return "mEq";
738 return "dB";
739 }
740 return "";
741 }
static string get_full_symbol(const char *x_symbol)
Returns the symbol of a custom_full_symbol dimension stored in the private static map dimension::full...

◆ invert()

void dimension::invert ( )

Changes the position of the dimension to the reverse, from the NUMERATOR to the DENOMINATOR, or from the DENOMINATOR to the NUMERATOR.

Definition at line 1647 of file dimension.cpp.

1648 {
1650 {
1652 }
1653 else
1654 {
1656 }
1657 }

◆ is_base_dimension()

bool dimension::is_base_dimension ( ) const

Returns true if the dimension is a base dimension, which includes all base dimensions of the SI system of units, excepting AMPERE, which has been changed for COULOMB. Additional to the base dimensions of the SI system of units, they are considered base dimensions too RADIAN, STERADIAN, BYTE, MONEY, MEMO, and all CUSTOM_BASIC dimensions.

Definition at line 1012 of file dimension.cpp.

1013 {
1014 switch(dimension_type)
1015 {
1016 case dimension::NONE:
1017 return false;
1018 case dimension::METRE:
1019 return true;
1020 case dimension::DEGREE:
1021 return false;
1022 case dimension::RADIAN:
1023 return true;
1025 return true;
1026 case dimension::GRAM:
1027 return true;
1028 case dimension::SECOND:
1029 return true;
1030 case dimension::COULOMB:
1031 return true;
1032 case dimension::KELVIN:
1033 return true;
1034 case dimension::CELSIUS:
1035 return false;
1036 case dimension::MOLE:
1037 return true;
1038 case dimension::CANDELA:
1039 return true;
1040 case dimension::BYTE:
1041 return true;
1042 case dimension::BIT:
1043 return false;
1044 case dimension::HERTZ:
1045 return false;
1046 case dimension::NEWTON:
1047 return false;
1048 case dimension::PASCAL:
1049 return false;
1050 case dimension::JOULE:
1051 return false;
1052 case dimension::WATT:
1053 return false;
1054 case dimension::AMPERE:
1055 return false;
1056 case dimension::VOLT:
1057 return false;
1058 case dimension::FARAD:
1059 return false;
1060 case dimension::OHM:
1061 return false;
1062 case dimension::SIEMENS:
1063 return false;
1064 case dimension::WEBER:
1065 return false;
1066 case dimension::TESLA:
1067 return false;
1068 case dimension::HENRY:
1069 return false;
1070 case dimension::LUMEN:
1071 return false;
1072 case dimension::LUX:
1073 return false;
1075 return false;
1076 case dimension::GRAY:
1077 return false;
1078 case dimension::SIEVERT:
1079 return false;
1080 case dimension::KATAL:
1081 return false;
1083 return false;
1084 case dimension::LITRE:
1085 return false;
1086 case dimension::MINUTE:
1087 return false;
1088 case dimension::HOUR:
1089 return false;
1090 case dimension::DAY:
1091 return false;
1093 return false;
1095 return false;
1096 case dimension::PARSEC:
1097 return false;
1099 return false;
1100 case dimension::DALTON:
1101 return false;
1103 return false;
1104 case dimension::BARN:
1105 return false;
1107 return false;
1109 return false;
1110 case dimension::CUSTOM:
1111 return false;
1113 return true;
1115 return false;
1116 case dimension::MONEY:
1117 return true;
1118 case dimension::PIXEL:
1119 return true;
1120 case dimension::MEMO:
1121 return true;
1123 return true;
1125 return true;
1126 case dimension::DECIBEL:
1127 return true;
1128 }
1129 return false;
1130 }

◆ is_composite_dimension()

bool dimension::is_composite_dimension ( ) const

If the dimension has more simple dimensions, it's a composite dimension.

Definition at line 1000 of file dimension.cpp.

1001 {
1003 {
1004 return false;
1005 }
1006 else
1007 {
1008 return !is_simple_dimension();
1009 }
1010 }
bool is_simple_dimension() const
If the dimension doesn't has more base dimensions, it's a simple dimension.

◆ is_derived_dimension()

bool dimension::is_derived_dimension ( ) const

If the dimension is not a base dimension, it's considered a derived dimension.

Definition at line 1132 of file dimension.cpp.

1133 {
1135 {
1136 return false;
1137 }
1138 else
1139 {
1140 return !is_base_dimension();
1141 }
1142 }
bool is_base_dimension() const
Returns true if the dimension is a base dimension, which includes all base dimensions of the SI syste...

◆ is_dimensionless()

bool dimension::is_dimensionless ( ) const

If the dimension_type is DEGREE, RADIAN or STERADIAN, it's considered dimensionless, following the SI system of units.

Definition at line 1384 of file dimension.cpp.

1385 {
1387 {
1388 return true;
1389 }
1390 else
1391 {
1392 return false;
1393 }
1394 }

◆ is_SI_base_dimension()

bool dimension::is_SI_base_dimension ( ) const

Returns true if the dimension is a SI base dimension. Following the SI system of units, only are base dimensions the METRE, the GRAM, the SECOND, the AMPERE, the KELVIN, the MOLE and the CANDELA.

Definition at line 1144 of file dimension.cpp.

1145 {
1146 switch(dimension_type)
1147 {
1148 case dimension::NONE:
1149 return false;
1150 case dimension::METRE:
1151 return true;
1152 case dimension::DEGREE:
1153 return false;
1154 case dimension::RADIAN:
1155 return false;
1157 return false;
1158 case dimension::GRAM:
1159 return true;
1160 case dimension::SECOND:
1161 return true;
1162 case dimension::COULOMB:
1163 return false;
1164 case dimension::KELVIN:
1165 return true;
1166 case dimension::CELSIUS:
1167 return false;
1168 case dimension::MOLE:
1169 return true;
1170 case dimension::CANDELA:
1171 return true;
1172 case dimension::BYTE:
1173 return false;
1174 case dimension::BIT:
1175 return false;
1176 case dimension::HERTZ:
1177 return false;
1178 case dimension::NEWTON:
1179 return false;
1180 case dimension::PASCAL:
1181 return false;
1182 case dimension::JOULE:
1183 return false;
1184 case dimension::WATT:
1185 return false;
1186 case dimension::AMPERE:
1187 return true;
1188 case dimension::VOLT:
1189 return false;
1190 case dimension::FARAD:
1191 return false;
1192 case dimension::OHM:
1193 return false;
1194 case dimension::SIEMENS:
1195 return false;
1196 case dimension::WEBER:
1197 return false;
1198 case dimension::TESLA:
1199 return false;
1200 case dimension::HENRY:
1201 return false;
1202 case dimension::LUMEN:
1203 return false;
1204 case dimension::LUX:
1205 return false;
1207 return false;
1208 case dimension::GRAY:
1209 return false;
1210 case dimension::SIEVERT:
1211 return false;
1212 case dimension::KATAL:
1213 return false;
1215 return false;
1216 case dimension::LITRE:
1217 return false;
1218 case dimension::MINUTE:
1219 return false;
1220 case dimension::HOUR:
1221 return false;
1222 case dimension::DAY:
1223 return false;
1225 return false;
1227 return false;
1228 case dimension::PARSEC:
1229 return false;
1231 return false;
1232 case dimension::DALTON:
1233 return false;
1235 return false;
1236 case dimension::BARN:
1237 return false;
1239 return false;
1241 return false;
1242 case dimension::CUSTOM:
1243 return false;
1245 return false;
1247 return false;
1248 case dimension::MONEY:
1249 return false;
1250 case dimension::PIXEL:
1251 return false;
1252 case dimension::MEMO:
1253 return false;
1255 return false;
1257 return false;
1258 case dimension::DECIBEL:
1259 return false;
1260 }
1261 return false;
1262 }

◆ is_SI_derived_dimension()

bool dimension::is_SI_derived_dimension ( ) const

If the dimension is not a SI base dimension, it's considered a SI derived dimension.

Definition at line 1264 of file dimension.cpp.

1265 {
1266 switch(dimension_type)
1267 {
1268 case dimension::NONE:
1269 return false;
1270 case dimension::METRE:
1271 return false;
1272 case dimension::DEGREE:
1273 return true;
1274 case dimension::RADIAN:
1275 return true;
1277 return true;
1278 case dimension::GRAM:
1279 return false;
1280 case dimension::SECOND:
1281 return false;
1282 case dimension::COULOMB:
1283 return true;
1284 case dimension::KELVIN:
1285 return false;
1286 case dimension::CELSIUS:
1287 return true;
1288 case dimension::MOLE:
1289 return false;
1290 case dimension::CANDELA:
1291 return false;
1292 case dimension::BYTE:
1293 return false;
1294 case dimension::BIT:
1295 return false;
1296 case dimension::HERTZ:
1297 return true;
1298 case dimension::NEWTON:
1299 return true;
1300 case dimension::PASCAL:
1301 return true;
1302 case dimension::JOULE:
1303 return true;
1304 case dimension::WATT:
1305 return true;
1306 case dimension::AMPERE:
1307 return false;
1308 case dimension::VOLT:
1309 return true;
1310 case dimension::FARAD:
1311 return true;
1312 case dimension::OHM:
1313 return true;
1314 case dimension::SIEMENS:
1315 return true;
1316 case dimension::WEBER:
1317 return true;
1318 case dimension::TESLA:
1319 return true;
1320 case dimension::HENRY:
1321 return true;
1322 case dimension::LUMEN:
1323 return true;
1324 case dimension::LUX:
1325 return true;
1327 return true;
1328 case dimension::GRAY:
1329 return true;
1330 case dimension::SIEVERT:
1331 return true;
1332 case dimension::KATAL:
1333 return true;
1335 return false;
1336 case dimension::LITRE:
1337 return false;
1338 case dimension::MINUTE:
1339 return false;
1340 case dimension::HOUR:
1341 return false;
1342 case dimension::DAY:
1343 return false;
1345 return false;
1347 return false;
1348 case dimension::PARSEC:
1349 return false;
1351 return false;
1352 case dimension::DALTON:
1353 return false;
1355 return false;
1356 case dimension::BARN:
1357 return false;
1359 return false;
1361 return false;
1362 case dimension::CUSTOM:
1363 return false;
1365 return false;
1367 return false;
1368 case dimension::MONEY:
1369 return false;
1370 case dimension::PIXEL:
1371 return false;
1372 case dimension::MEMO:
1373 return false;
1375 return false;
1377 return false;
1378 case dimension::DECIBEL:
1379 return false;
1380 }
1381 return false;
1382 }

◆ is_simple_dimension()

bool dimension::is_simple_dimension ( ) const

If the dimension doesn't has more base dimensions, it's a simple dimension.

Definition at line 880 of file dimension.cpp.

881 {
882 switch(dimension_type)
883 {
884 case dimension::NONE:
885 return false;
886 case dimension::METRE:
887 return true;
889 return true;
891 return true;
893 return true;
894 case dimension::GRAM:
895 return true;
897 return true;
899 return true;
901 return true;
903 return true;
904 case dimension::MOLE:
905 return true;
907 return true;
908 case dimension::BYTE:
909 return true;
910 case dimension::BIT:
911 return true;
912 case dimension::HERTZ:
913 return true;
915 return false;
917 return false;
918 case dimension::JOULE:
919 return false;
920 case dimension::WATT:
921 return false;
923 return true;
924 case dimension::VOLT:
925 return false;
926 case dimension::FARAD:
927 return false;
928 case dimension::OHM:
929 return false;
931 return false;
932 case dimension::WEBER:
933 return false;
934 case dimension::TESLA:
935 return false;
936 case dimension::HENRY:
937 return false;
938 case dimension::LUMEN:
939 return false;
940 case dimension::LUX:
941 return false;
943 return true;
944 case dimension::GRAY:
945 return false;
947 return false;
948 case dimension::KATAL:
949 return false;
951 return true;
952 case dimension::LITRE:
953 return false;
955 return true;
956 case dimension::HOUR:
957 return true;
958 case dimension::DAY:
959 return true;
961 return true;
963 return true;
965 return true;
967 return false;
969 return true;
971 return true;
972 case dimension::BARN:
973 return false;
975 return false;
977 return true;
979 return false;
981 return true;
983 return false;
984 case dimension::MONEY:
985 return true;
986 case dimension::PIXEL:
987 return true;
988 case dimension::MEMO:
989 return true;
991 return true;
993 return true;
995 return true;
996 }
997 return false;
998 }

◆ operator=() [1/2]

dimension & dimension::operator= ( const dimension x)

Copy assignment. The dimension copies the dimension x.

◆ operator=() [2/2]

dimension & dimension::operator= ( dimension &&  x)

Move assignment. The dimension values are all moved from the dimension x.

◆ prefix_math() [1/2]

long double dimension::prefix_math ( ) const

Returns the math between the prefix and the dimension, which varies if the dimension is a B or another. In the case of bytes the math with the prefix is different, it's done with 1024 instead of multiples of 10. It doesn't includes the conversion factor of dimensions.

Definition at line 863 of file dimension.cpp.

864 {
865 return prefix_math(prefix);
866 }
long double prefix_math() const
Returns the math between the prefix and the dimension, which varies if the dimension is a B or anothe...

◆ prefix_math() [2/2]

long double dimension::prefix_math ( const prefix x_prefix) const

Returns the math between some prefix and the dimension. The difference with the other prefix_math() function is that the prefix is given as parameter.

Definition at line 868 of file dimension.cpp.

869 {
871 {
872 return std::pow(1024, x_prefix.get_conversion_factor() / 3);
873 }
874 else
875 {
876 return std::pow(10, x_prefix.get_conversion_factor());
877 }
878 }

Member Data Documentation

◆ base_dimensions

map< string, vector< dimension > > scifir::dimension::base_dimensions = map<string,vector<dimension>>()
staticprivate

Definition at line 167 of file dimension.hpp.

◆ dimension_position

dimension::position dimension::dimension_position

The position of the dimension, which can be the NUMERATOR, the DENOMINATOR or NO_POSITION. NO_POSITION means that the dimension is not ready to be used, and must be changed if the dimension is intended to be used.

Definition at line 76 of file dimension.hpp.

◆ dimension_type

dimension::type dimension::dimension_type

The type of the dimension.

Definition at line 75 of file dimension.hpp.

◆ full_symbols

map< int, string > scifir::dimension::full_symbols = map<int,string>()
staticprivate

Definition at line 168 of file dimension.hpp.

◆ prefix

scifir::prefix dimension::prefix

The prefix of the dimension. It's used along with the symbol of the dimension when printing it.

Definition at line 74 of file dimension.hpp.

◆ prefixes_options

set< string > scifir::dimension::prefixes_options {"Q", "R", "Y", "Z", "E", "P", "T", "G", "M", "k", "h", "d", "c", "m", "\u00B5", "u", "n", "p", "f", "a", "z", "y", "r", "q"}
staticprivate

Definition at line 170 of file dimension.hpp.

◆ symbol

char dimension::symbol[3]

The value of the position of the character of a custom dimension in the map of full_symbols.

Definition at line 77 of file dimension.hpp.

◆ total_full_symbols

int scifir::dimension::total_full_symbols = 0
staticprivate

Definition at line 169 of file dimension.hpp.


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