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 | Public Attributes | List of all members
scifir::prefix Class Reference

Class that represents prefixes of the SI system of units. Each prefix sizes 1 byte. The prefix micro is added to a dimension with the symbol µ. More...

#include <prefix.hpp>

Public Types

enum  type : int8_t {
  NONE , QUETTA , RONNA , YOTTA ,
  ZETTA , EXA , PETA , TERA ,
  GIGA , MEGA , KILO , HECTO ,
  DECA , DECI , CENTI , MILLI ,
  MICRO , NANO , PICO , FEMTO ,
  ATTO , ZEPTO , YOCTO , RONTO ,
  QUECTO
}
 Represents a prefix of the SI system of units. All the prefixes of the SI system of units are supported. More...
 

Public Member Functions

 prefix ()
 Default constructor. The prefix_type is set to NONE.
 
 prefix (const prefix &x)
 Copy constructor. The prefix_type is copied from the prefix x.
 
 prefix (prefix &&x)
 Move constructor. The prefix_type is moved from the prefix x.
 
 prefix (prefix::type new_type)
 Constructor. The prefix_type is set to the new_type given.
 
 prefix (const string &new_type)
 Constructor. The prefix_type is set to the new_type specified in the string.
 
prefixoperator= (const prefix &x)
 Copy assignment. The prefix_type is copied from the prefix x.
 
prefixoperator= (prefix &&x)
 Move assignment. The prefix_type is moved from the prefix x.
 
int get_conversion_factor () const
 Returns the conversion factor of the prefix given the prefix_type. It uses the SI system of units for the value of each conversion factor.
 
string get_name () const
 Name of the prefix given the prefix_type.
 
string get_symbol () const
 Symbol of the prefix given the prefix_type. The symbol of micro is supported in his Unicode version.
 
bool operator< (const scifir::prefix &x) const
 This operator allows to order the prefixes from the lower to the greather.
 

Public Attributes

prefix::type prefix_type
 It stores the prefix type currently being used.
 

Detailed Description

Class that represents prefixes of the SI system of units. Each prefix sizes 1 byte. The prefix micro is added to a dimension with the symbol µ.

Definition at line 13 of file prefix.hpp.

Member Enumeration Documentation

◆ type

Represents a prefix of the SI system of units. All the prefixes of the SI system of units are supported.

Enumerator
NONE 

There is no prefix. Then, the dimension is not increased or decreased by some factor.

QUETTA 

Prefix of a factor of 10^30.

RONNA 

Prefix of a factor of 10^27.

YOTTA 

Prefix of a factor of 10^24.

ZETTA 

Prefix of a factor of 10^21.

EXA 

Prefix of a factor of 10^18.

PETA 

Prefix of a factor of 10^15.

TERA 

Prefix of a factor of 10^12.

GIGA 

Prefix of a factor of 10^9.

MEGA 

Prefix of a factor of 10^6.

KILO 

Prefix of a factor of 10^3.

HECTO 

Prefix of a factor of 10^2.

DECA 

Prefix of a factor of 10^1.

DECI 

Prefix of a factor of 10^-1.

CENTI 

Prefix of a factor of 10^-2.

MILLI 

Prefix of a factor of 10^-3.

MICRO 

Prefix of a factor of 10^-6.

NANO 

Prefix of a factor of 10^-9.

PICO 

Prefix of a factor of 10^-12.

FEMTO 

Prefix of a factor of 10^-15.

ATTO 

Prefix of a factor of 10^-18.

ZEPTO 

Prefix of a factor of 10^-21.

YOCTO 

Prefix of a factor of 10^-24.

RONTO 

Prefix of a factor of 10^-27.

QUECTO 

Prefix of a factor of 10^-30.

Definition at line 16 of file prefix.hpp.

@ ATTO
Prefix of a factor of 10^-18.
Definition prefix.hpp:16
@ YOCTO
Prefix of a factor of 10^-24.
Definition prefix.hpp:16
@ RONNA
Prefix of a factor of 10^27.
Definition prefix.hpp:16
@ NANO
Prefix of a factor of 10^-9.
Definition prefix.hpp:16
@ MILLI
Prefix of a factor of 10^-3.
Definition prefix.hpp:16
@ NONE
There is no prefix. Then, the dimension is not increased or decreased by some factor.
Definition prefix.hpp:16
@ EXA
Prefix of a factor of 10^18.
Definition prefix.hpp:16
@ QUETTA
Prefix of a factor of 10^30.
Definition prefix.hpp:16
@ KILO
Prefix of a factor of 10^3.
Definition prefix.hpp:16
@ MEGA
Prefix of a factor of 10^6.
Definition prefix.hpp:16
@ HECTO
Prefix of a factor of 10^2.
Definition prefix.hpp:16
@ CENTI
Prefix of a factor of 10^-2.
Definition prefix.hpp:16
@ PETA
Prefix of a factor of 10^15.
Definition prefix.hpp:16
@ RONTO
Prefix of a factor of 10^-27.
Definition prefix.hpp:16
@ DECA
Prefix of a factor of 10^1.
Definition prefix.hpp:16
@ ZEPTO
Prefix of a factor of 10^-21.
Definition prefix.hpp:16
@ YOTTA
Prefix of a factor of 10^24.
Definition prefix.hpp:16
@ FEMTO
Prefix of a factor of 10^-15.
Definition prefix.hpp:16
@ DECI
Prefix of a factor of 10^-1.
Definition prefix.hpp:16
@ MICRO
Prefix of a factor of 10^-6.
Definition prefix.hpp:16
@ GIGA
Prefix of a factor of 10^9.
Definition prefix.hpp:16
@ QUECTO
Prefix of a factor of 10^-30.
Definition prefix.hpp:16
@ PICO
Prefix of a factor of 10^-12.
Definition prefix.hpp:16
@ ZETTA
Prefix of a factor of 10^21.
Definition prefix.hpp:16
@ TERA
Prefix of a factor of 10^12.
Definition prefix.hpp:16

Constructor & Destructor Documentation

◆ prefix() [1/5]

prefix::prefix ( )

Default constructor. The prefix_type is set to NONE.

Definition at line 9 of file prefix.cpp.

10 {}
prefix::type prefix_type
It stores the prefix type currently being used.
Definition prefix.hpp:33

◆ prefix() [2/5]

prefix::prefix ( const prefix x)

Copy constructor. The prefix_type is copied from the prefix x.

Definition at line 12 of file prefix.cpp.

12 : prefix_type(x.prefix_type)
13 {}

◆ prefix() [3/5]

prefix::prefix ( prefix &&  x)

Move constructor. The prefix_type is moved from the prefix x.

Definition at line 15 of file prefix.cpp.

15 : prefix_type(std::move(x.prefix_type))
16 {}

◆ prefix() [4/5]

prefix::prefix ( prefix::type  new_type)
explicit

Constructor. The prefix_type is set to the new_type given.

Definition at line 18 of file prefix.cpp.

18 : prefix_type(new_type)
19 {}

◆ prefix() [5/5]

prefix::prefix ( const string new_type)
explicit

Constructor. The prefix_type is set to the new_type specified in the string.

Definition at line 21 of file prefix.cpp.

21 : prefix_type(prefix_string(new_type))
22 {}
prefix::type prefix_string(const string &x)
Returns the value of the enum prefix::type associated with the string x given.
Definition prefix.cpp:215

Member Function Documentation

◆ get_conversion_factor()

int prefix::get_conversion_factor ( ) const

Returns the conversion factor of the prefix given the prefix_type. It uses the SI system of units for the value of each conversion factor.

Definition at line 36 of file prefix.cpp.

37 {
38 switch (prefix_type)
39 {
40 case prefix::QUETTA:
41 return 30;
42 case prefix::RONNA:
43 return 27;
44 case prefix::YOTTA:
45 return 24;
46 case prefix::ZETTA:
47 return 21;
48 case prefix::EXA:
49 return 18;
50 case prefix::PETA:
51 return 15;
52 case prefix::TERA:
53 return 12;
54 case prefix::GIGA:
55 return 9;
56 case prefix::MEGA:
57 return 6;
58 case prefix::KILO:
59 return 3;
60 case prefix::HECTO:
61 return 2;
62 case prefix::DECA:
63 return 1;
64 case prefix::NONE:
65 return 0;
66 case prefix::DECI:
67 return -1;
68 case prefix::CENTI:
69 return -2;
70 case prefix::MILLI:
71 return -3;
72 case prefix::MICRO:
73 return -6;
74 case prefix::NANO:
75 return -9;
76 case prefix::PICO:
77 return -12;
78 case prefix::FEMTO:
79 return -15;
80 case prefix::ATTO:
81 return -18;
82 case prefix::ZEPTO:
83 return -21;
84 case prefix::YOCTO:
85 return -24;
86 case prefix::RONTO:
87 return -27;
88 case prefix::QUECTO:
89 return -30;
90 }
91 return 0;
92 }

◆ get_name()

string prefix::get_name ( ) const

Name of the prefix given the prefix_type.

Definition at line 94 of file prefix.cpp.

95 {
96 switch (prefix_type)
97 {
98 case prefix::QUETTA:
99 return "quetta";
100 case prefix::RONNA:
101 return "ronna";
102 case prefix::YOTTA:
103 return "yotta";
104 case prefix::ZETTA:
105 return "zetta";
106 case prefix::EXA:
107 return "exa";
108 case prefix::PETA:
109 return "peta";
110 case prefix::TERA:
111 return "tera";
112 case prefix::GIGA:
113 return "giga";
114 case prefix::MEGA:
115 return "mega";
116 case prefix::KILO:
117 return "kilo";
118 case prefix::HECTO:
119 return "hecto";
120 case prefix::DECA:
121 return "deca";
122 case prefix::NONE:
123 return "";
124 case prefix::DECI:
125 return "deci";
126 case prefix::CENTI:
127 return "centi";
128 case prefix::MILLI:
129 return "milli";
130 case prefix::MICRO:
131 return "micro";
132 case prefix::NANO:
133 return "nano";
134 case prefix::PICO:
135 return "pico";
136 case prefix::FEMTO:
137 return "femto";
138 case prefix::ATTO:
139 return "atto";
140 case prefix::ZEPTO:
141 return "zepto";
142 case prefix::YOCTO:
143 return "yocto";
144 case prefix::RONTO:
145 return "ronto";
146 case prefix::QUECTO:
147 return "quecto";
148 }
149 return "";
150 }

◆ get_symbol()

string prefix::get_symbol ( ) const

Symbol of the prefix given the prefix_type. The symbol of micro is supported in his Unicode version.

Definition at line 152 of file prefix.cpp.

153 {
154 switch (prefix_type)
155 {
156 case prefix::QUETTA:
157 return "Q";
158 case prefix::RONNA:
159 return "R";
160 case prefix::YOTTA:
161 return "Y";
162 case prefix::ZETTA:
163 return "Z";
164 case prefix::EXA:
165 return "E";
166 case prefix::PETA:
167 return "P";
168 case prefix::TERA:
169 return "T";
170 case prefix::GIGA:
171 return "G";
172 case prefix::MEGA:
173 return "M";
174 case prefix::KILO:
175 return "k";
176 case prefix::HECTO:
177 return "h";
178 case prefix::DECA:
179 return "da";
180 case prefix::NONE:
181 return "";
182 case prefix::DECI:
183 return "d";
184 case prefix::CENTI:
185 return "c";
186 case prefix::MILLI:
187 return "m";
188 case prefix::MICRO:
189 return "µ";
190 case prefix::NANO:
191 return "n";
192 case prefix::PICO:
193 return "p";
194 case prefix::FEMTO:
195 return "f";
196 case prefix::ATTO:
197 return "a";
198 case prefix::ZEPTO:
199 return "z";
200 case prefix::YOCTO:
201 return "y";
202 case prefix::RONTO:
203 return "r";
204 case prefix::QUECTO:
205 return "q";
206 }
207 return "";
208 }

◆ operator<()

bool prefix::operator< ( const scifir::prefix x) const

This operator allows to order the prefixes from the lower to the greather.

Definition at line 210 of file prefix.cpp.

211 {
213 }
int get_conversion_factor() const
Returns the conversion factor of the prefix given the prefix_type. It uses the SI system of units for...
Definition prefix.cpp:36

◆ operator=() [1/2]

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

Copy assignment. The prefix_type is copied from the prefix x.

Definition at line 24 of file prefix.cpp.

25 {
26 prefix_type = x.prefix_type;
27 return *this;
28 }

◆ operator=() [2/2]

prefix & prefix::operator= ( prefix &&  x)

Move assignment. The prefix_type is moved from the prefix x.

Definition at line 30 of file prefix.cpp.

31 {
32 prefix_type = std::move(x.prefix_type);
33 return *this;
34 }

Member Data Documentation

◆ prefix_type

prefix::prefix_type

It stores the prefix type currently being used.

Definition at line 33 of file prefix.hpp.


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