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
base_units.hpp
Go to the documentation of this file.
1#ifndef SCIFIR_UNITS_UNITS_BASE_UNITS_HPP_INCLUDED
2#define SCIFIR_UNITS_UNITS_BASE_UNITS_HPP_INCLUDED
3
4#include "./prefix.hpp"
5#include "./scalar_unit.hpp"
6#include "../meca_number/percentage.hpp"
7
8#include <chrono>
9#include <iostream>
10#include <sstream>
11
12using namespace std;
13
14namespace scifir
15{
17
19 {
20 public:
28 explicit time_duration(float new_value, const string& init_dimensions);
29 explicit time_duration(double new_value, const string& init_dimensions);
30 explicit time_duration(long double new_value, const string& init_dimensions);
31 explicit time_duration(int new_value, const string& init_dimensions);
34 explicit time_duration(long double new_value, const vector<dimension>& new_dimensions);
36 explicit time_duration(const string& init_time);
37
38 explicit operator std::chrono::seconds() const;
39
40 int get_years() const;
41 int get_months() const;
42 int get_weeks() const;
43 int get_days() const;
44 int get_hours() const;
45 int get_minutes() const;
46 int get_seconds() const;
47
48 string get_finish_date() const;
49 string display_as_time() const;
50
51 string display_years() const;
52 string display_months() const;
53 string display_weeks() const;
54 string display_days() const;
55 string display_hours() const;
56 string display_minutes() const;
57 string display_seconds() const;
58
59 template<typename T1,typename T2>
60 scifir::time_duration& operator+=(chrono::duration<T1,T2> x)
61 {
62 chrono::seconds d = chrono::duration_cast<chrono::seconds>(x);
63 scifir::time_duration x_second = scifir::time_duration((long double)d.count(),"s");
65 return *this;
66 }
67
68 template<typename T1,typename T2>
69 scifir::time_duration& operator-=(chrono::duration<T1,T2> x)
70 {
71 chrono::seconds d = chrono::duration_cast<chrono::seconds>(x);
72 scifir::time_duration x_second = scifir::time_duration((long double)d.count(),"s");
74 return *this;
75 }
76
77 using scalar_unit::operator =;
78 using scalar_unit::operator+=;
79 using scalar_unit::operator-=;
80
81 public:
82 static const string dimensions_match;
84 };
85
87 public:
89 mass(const string& init_percentage,const string& init_mass);
90
92
95
97 public:
99 mole(const string& init_percentage,const string& init_mole);
100
101 int get_number_of_particles() const;
103
106}
107
108scifir::length operator"" _Qm(unsigned long long int);
109scifir::length operator"" _Rm(unsigned long long int);
110scifir::length operator"" _Ym(unsigned long long int);
111scifir::length operator"" _Zm(unsigned long long int);
112scifir::length operator"" _Em(unsigned long long int);
113scifir::length operator"" _Pm(unsigned long long int);
114scifir::length operator"" _Tm(unsigned long long int);
115scifir::length operator"" _Gm(unsigned long long int);
116scifir::length operator"" _Mm(unsigned long long int);
117scifir::length operator"" _km(unsigned long long int);
118scifir::length operator"" _hm(unsigned long long int);
119scifir::length operator"" _dam(unsigned long long int);
120scifir::length operator"" _m(unsigned long long int);
121scifir::length operator"" _dm(unsigned long long int);
122scifir::length operator"" _cm(unsigned long long int);
123scifir::length operator"" _mm(unsigned long long int);
124scifir::length operator"" _um(unsigned long long int);
125scifir::length operator"" _nm(unsigned long long int);
126scifir::length operator"" _pm(unsigned long long int);
127scifir::length operator"" _fm(unsigned long long int);
128scifir::length operator"" _am(unsigned long long int);
129scifir::length operator"" _zm(unsigned long long int);
130scifir::length operator"" _ym(unsigned long long int);
131scifir::length operator"" _rm(unsigned long long int);
132scifir::length operator"" _qm(unsigned long long int);
133
134scifir::time_duration operator"" _s(unsigned long long int);
135scifir::time_duration operator"" _ms(unsigned long long int);
136scifir::time_duration operator"" _us(unsigned long long int);
137scifir::time_duration operator"" _ns(unsigned long long int);
138scifir::time_duration operator"" _ps(unsigned long long int);
139scifir::time_duration operator"" _fs(unsigned long long int);
140scifir::time_duration operator"" _as(unsigned long long int);
141scifir::time_duration operator"" _zs(unsigned long long int);
142scifir::time_duration operator"" _ys(unsigned long long int);
143scifir::time_duration operator"" _rs(unsigned long long int);
144scifir::time_duration operator"" _qs(unsigned long long int);
145
146scifir::mass operator"" _Qg(unsigned long long int);
147scifir::mass operator"" _Rg(unsigned long long int);
148scifir::mass operator"" _Yg(unsigned long long int);
149scifir::mass operator"" _Zg(unsigned long long int);
150scifir::mass operator"" _Eg(unsigned long long int);
151scifir::mass operator"" _Pg(unsigned long long int);
152scifir::mass operator"" _Tg(unsigned long long int);
153scifir::mass operator"" _Gg(unsigned long long int);
154scifir::mass operator"" _Mg(unsigned long long int);
155scifir::mass operator"" _kg(unsigned long long int);
156scifir::mass operator"" _hg(unsigned long long int);
157scifir::mass operator"" _dag(unsigned long long int);
158scifir::mass operator"" _g(unsigned long long int);
159scifir::mass operator"" _dg(unsigned long long int);
160scifir::mass operator"" _cg(unsigned long long int);
161scifir::mass operator"" _mg(unsigned long long int);
162scifir::mass operator"" _ug(unsigned long long int);
163scifir::mass operator"" _ng(unsigned long long int);
164scifir::mass operator"" _pg(unsigned long long int);
165scifir::mass operator"" _fg(unsigned long long int);
166scifir::mass operator"" _ag(unsigned long long int);
167scifir::mass operator"" _zg(unsigned long long int);
168scifir::mass operator"" _yg(unsigned long long int);
169scifir::mass operator"" _rg(unsigned long long int);
170scifir::mass operator"" _qg(unsigned long long int);
171
172scifir::charge operator"" _QC(unsigned long long int);
173scifir::charge operator"" _RC(unsigned long long int);
174scifir::charge operator"" _YC(unsigned long long int);
175scifir::charge operator"" _ZC(unsigned long long int);
176scifir::charge operator"" _EC(unsigned long long int);
177scifir::charge operator"" _PC(unsigned long long int);
178scifir::charge operator"" _TC(unsigned long long int);
179scifir::charge operator"" _GC(unsigned long long int);
180scifir::charge operator"" _MC(unsigned long long int);
181scifir::charge operator"" _kC(unsigned long long int);
182scifir::charge operator"" _hC(unsigned long long int);
183scifir::charge operator"" _daC(unsigned long long int);
184scifir::charge operator"" _C(unsigned long long int);
185scifir::charge operator"" _dC(unsigned long long int);
186scifir::charge operator"" _cC(unsigned long long int);
187scifir::charge operator"" _mC(unsigned long long int);
188scifir::charge operator"" _uC(unsigned long long int);
189scifir::charge operator"" _nC(unsigned long long int);
190scifir::charge operator"" _pC(unsigned long long int);
191scifir::charge operator"" _fC(unsigned long long int);
192scifir::charge operator"" _aC(unsigned long long int);
193scifir::charge operator"" _zC(unsigned long long int);
194scifir::charge operator"" _yC(unsigned long long int);
195scifir::charge operator"" _rC(unsigned long long int);
196scifir::charge operator"" _qC(unsigned long long int);
197
198scifir::temperature operator"" _QK(unsigned long long int);
199scifir::temperature operator"" _RK(unsigned long long int);
200scifir::temperature operator"" _YK(unsigned long long int);
201scifir::temperature operator"" _ZK(unsigned long long int);
202scifir::temperature operator"" _EK(unsigned long long int);
203scifir::temperature operator"" _PK(unsigned long long int);
204scifir::temperature operator"" _TK(unsigned long long int);
205scifir::temperature operator"" _GK(unsigned long long int);
206scifir::temperature operator"" _MK(unsigned long long int);
207scifir::temperature operator"" _kK(unsigned long long int);
208scifir::temperature operator"" _hK(unsigned long long int);
209scifir::temperature operator"" _daK(unsigned long long int);
210scifir::temperature operator"" _K(unsigned long long int);
211scifir::temperature operator"" _dK(unsigned long long int);
212scifir::temperature operator"" _cK(unsigned long long int);
213scifir::temperature operator"" _mK(unsigned long long int);
214scifir::temperature operator"" _uK(unsigned long long int);
215scifir::temperature operator"" _nK(unsigned long long int);
216scifir::temperature operator"" _pK(unsigned long long int);
217scifir::temperature operator"" _fK(unsigned long long int);
218scifir::temperature operator"" _aK(unsigned long long int);
219scifir::temperature operator"" _zK(unsigned long long int);
220scifir::temperature operator"" _yK(unsigned long long int);
221scifir::temperature operator"" _rK(unsigned long long int);
222scifir::temperature operator"" _qK(unsigned long long int);
223
224scifir::mole operator"" _Qmol(unsigned long long int);
225scifir::mole operator"" _Rmol(unsigned long long int);
226scifir::mole operator"" _Ymol(unsigned long long int);
227scifir::mole operator"" _Zmol(unsigned long long int);
228scifir::mole operator"" _Emol(unsigned long long int);
229scifir::mole operator"" _Pmol(unsigned long long int);
230scifir::mole operator"" _Tmol(unsigned long long int);
231scifir::mole operator"" _Gmol(unsigned long long int);
232scifir::mole operator"" _Mmol(unsigned long long int);
233scifir::mole operator"" _kmol(unsigned long long int);
234scifir::mole operator"" _hmol(unsigned long long int);
235scifir::mole operator"" _damol(unsigned long long int);
236scifir::mole operator"" _mol(unsigned long long int);
237scifir::mole operator"" _dmol(unsigned long long int);
238scifir::mole operator"" _cmol(unsigned long long int);
239scifir::mole operator"" _mmol(unsigned long long int);
240scifir::mole operator"" _umol(unsigned long long int);
241scifir::mole operator"" _nmol(unsigned long long int);
242scifir::mole operator"" _pmol(unsigned long long int);
243scifir::mole operator"" _fmol(unsigned long long int);
244scifir::mole operator"" _amol(unsigned long long int);
245scifir::mole operator"" _zmol(unsigned long long int);
246scifir::mole operator"" _ymol(unsigned long long int);
247scifir::mole operator"" _rmol(unsigned long long int);
248scifir::mole operator"" _qmol(unsigned long long int);
249
250scifir::light_intensity operator"" _Qcd(unsigned long long int);
251scifir::light_intensity operator"" _Rcd(unsigned long long int);
252scifir::light_intensity operator"" _Ycd(unsigned long long int);
253scifir::light_intensity operator"" _Zcd(unsigned long long int);
254scifir::light_intensity operator"" _Ecd(unsigned long long int);
255scifir::light_intensity operator"" _Pcd(unsigned long long int);
256scifir::light_intensity operator"" _Tcd(unsigned long long int);
257scifir::light_intensity operator"" _Gcd(unsigned long long int);
258scifir::light_intensity operator"" _Mcd(unsigned long long int);
259scifir::light_intensity operator"" _kcd(unsigned long long int);
260scifir::light_intensity operator"" _hcd(unsigned long long int);
261scifir::light_intensity operator"" _dacd(unsigned long long int);
262scifir::light_intensity operator"" _cd(unsigned long long int);
263scifir::light_intensity operator"" _dcd(unsigned long long int);
264scifir::light_intensity operator"" _ccd(unsigned long long int);
265scifir::light_intensity operator"" _mcd(unsigned long long int);
266scifir::light_intensity operator"" _ucd(unsigned long long int);
267scifir::light_intensity operator"" _ncd(unsigned long long int);
268scifir::light_intensity operator"" _pcd(unsigned long long int);
269scifir::light_intensity operator"" _fcd(unsigned long long int);
270scifir::light_intensity operator"" _acd(unsigned long long int);
271scifir::light_intensity operator"" _zcd(unsigned long long int);
272scifir::light_intensity operator"" _ycd(unsigned long long int);
273scifir::light_intensity operator"" _rcd(unsigned long long int);
274scifir::light_intensity operator"" _qcd(unsigned long long int);
275
276scifir::information_size operator"" _QB(unsigned long long int);
277scifir::information_size operator"" _RB(unsigned long long int);
278scifir::information_size operator"" _YB(unsigned long long int);
279scifir::information_size operator"" _ZB(unsigned long long int);
280scifir::information_size operator"" _EB(unsigned long long int);
281scifir::information_size operator"" _PB(unsigned long long int);
282scifir::information_size operator"" _TB(unsigned long long int);
283scifir::information_size operator"" _GB(unsigned long long int);
284scifir::information_size operator"" _MB(unsigned long long int);
285scifir::information_size operator"" _kB(unsigned long long int);
286scifir::information_size operator"" _B(unsigned long long int);
287
288scifir::information_size operator"" _Qbit(unsigned long long int);
289scifir::information_size operator"" _Rbit(unsigned long long int);
290scifir::information_size operator"" _Ybit(unsigned long long int);
291scifir::information_size operator"" _Zbit(unsigned long long int);
292scifir::information_size operator"" _Ebit(unsigned long long int);
293scifir::information_size operator"" _Pbit(unsigned long long int);
294scifir::information_size operator"" _Tbit(unsigned long long int);
295scifir::information_size operator"" _Gbit(unsigned long long int);
296scifir::information_size operator"" _Mbit(unsigned long long int);
297scifir::information_size operator"" _kbit(unsigned long long int);
298scifir::information_size operator"" _bit(unsigned long long int);
299
300scifir::length operator"" _Qm(long double);
301scifir::length operator"" _Rm(long double);
302scifir::length operator"" _Ym(long double);
303scifir::length operator"" _Zm(long double);
304scifir::length operator"" _Em(long double);
305scifir::length operator"" _Pm(long double);
306scifir::length operator"" _Tm(long double);
307scifir::length operator"" _Gm(long double);
308scifir::length operator"" _Mm(long double);
309scifir::length operator"" _km(long double);
310scifir::length operator"" _hm(long double);
311scifir::length operator"" _dam(long double);
312scifir::length operator"" _m(long double);
313scifir::length operator"" _dm(long double);
314scifir::length operator"" _cm(long double);
315scifir::length operator"" _mm(long double);
316scifir::length operator"" _um(long double);
317scifir::length operator"" _nm(long double);
318scifir::length operator"" _pm(long double);
319scifir::length operator"" _fm(long double);
320scifir::length operator"" _am(long double);
321scifir::length operator"" _zm(long double);
322scifir::length operator"" _ym(long double);
323scifir::length operator"" _rm(long double);
324scifir::length operator"" _qm(long double);
325
326scifir::time_duration operator"" _s(long double);
327scifir::time_duration operator"" _ms(long double);
328scifir::time_duration operator"" _us(long double);
329scifir::time_duration operator"" _ns(long double);
330scifir::time_duration operator"" _ps(long double);
331scifir::time_duration operator"" _fs(long double);
332scifir::time_duration operator"" _as(long double);
333scifir::time_duration operator"" _zs(long double);
334scifir::time_duration operator"" _ys(long double);
335scifir::time_duration operator"" _rs(long double);
336scifir::time_duration operator"" _qs(long double);
337
338scifir::mass operator"" _Qg(long double);
339scifir::mass operator"" _Rg(long double);
340scifir::mass operator"" _Yg(long double);
341scifir::mass operator"" _Zg(long double);
342scifir::mass operator"" _Eg(long double);
343scifir::mass operator"" _Pg(long double);
344scifir::mass operator"" _Tg(long double);
345scifir::mass operator"" _Gg(long double);
346scifir::mass operator"" _Mg(long double);
347scifir::mass operator"" _kg(long double);
348scifir::mass operator"" _hg(long double);
349scifir::mass operator"" _dag(long double);
350scifir::mass operator"" _g(long double);
351scifir::mass operator"" _dg(long double);
352scifir::mass operator"" _cg(long double);
353scifir::mass operator"" _mg(long double);
354scifir::mass operator"" _ug(long double);
355scifir::mass operator"" _ng(long double);
356scifir::mass operator"" _pg(long double);
357scifir::mass operator"" _fg(long double);
358scifir::mass operator"" _ag(long double);
359scifir::mass operator"" _zg(long double);
360scifir::mass operator"" _yg(long double);
361scifir::mass operator"" _rg(long double);
362scifir::mass operator"" _qg(long double);
363
364scifir::charge operator"" _QC(long double);
365scifir::charge operator"" _RC(long double);
366scifir::charge operator"" _YC(long double);
367scifir::charge operator"" _ZC(long double);
368scifir::charge operator"" _EC(long double);
369scifir::charge operator"" _PC(long double);
370scifir::charge operator"" _TC(long double);
371scifir::charge operator"" _GC(long double);
372scifir::charge operator"" _MC(long double);
373scifir::charge operator"" _kC(long double);
374scifir::charge operator"" _hC(long double);
375scifir::charge operator"" _daC(long double);
376scifir::charge operator"" _C(long double);
377scifir::charge operator"" _dC(long double);
378scifir::charge operator"" _cC(long double);
379scifir::charge operator"" _mC(long double);
380scifir::charge operator"" _uC(long double);
381scifir::charge operator"" _nC(long double);
382scifir::charge operator"" _pC(long double);
383scifir::charge operator"" _fC(long double);
384scifir::charge operator"" _aC(long double);
385scifir::charge operator"" _zC(long double);
386scifir::charge operator"" _yC(long double);
387scifir::charge operator"" _rC(long double);
388scifir::charge operator"" _qC(long double);
389
390scifir::temperature operator"" _QK(long double);
391scifir::temperature operator"" _RK(long double);
392scifir::temperature operator"" _YK(long double);
393scifir::temperature operator"" _ZK(long double);
394scifir::temperature operator"" _EK(long double);
395scifir::temperature operator"" _PK(long double);
396scifir::temperature operator"" _TK(long double);
397scifir::temperature operator"" _GK(long double);
398scifir::temperature operator"" _MK(long double);
399scifir::temperature operator"" _kK(long double);
400scifir::temperature operator"" _hK(long double);
401scifir::temperature operator"" _daK(long double);
402scifir::temperature operator"" _K(long double);
403scifir::temperature operator"" _dK(long double);
404scifir::temperature operator"" _cK(long double);
405scifir::temperature operator"" _mK(long double);
406scifir::temperature operator"" _uK(long double);
407scifir::temperature operator"" _nK(long double);
408scifir::temperature operator"" _pK(long double);
409scifir::temperature operator"" _fK(long double);
410scifir::temperature operator"" _aK(long double);
411scifir::temperature operator"" _zK(long double);
412scifir::temperature operator"" _yK(long double);
413scifir::temperature operator"" _rK(long double);
414scifir::temperature operator"" _qK(long double);
415
416scifir::mole operator"" _Qmol(long double);
417scifir::mole operator"" _Rmol(long double);
418scifir::mole operator"" _Ymol(long double);
419scifir::mole operator"" _Zmol(long double);
420scifir::mole operator"" _Emol(long double);
421scifir::mole operator"" _Pmol(long double);
422scifir::mole operator"" _Tmol(long double);
423scifir::mole operator"" _Gmol(long double);
424scifir::mole operator"" _Mmol(long double);
425scifir::mole operator"" _kmol(long double);
426scifir::mole operator"" _hmol(long double);
427scifir::mole operator"" _damol(long double);
428scifir::mole operator"" _mol(long double);
429scifir::mole operator"" _dmol(long double);
430scifir::mole operator"" _cmol(long double);
431scifir::mole operator"" _mmol(long double);
432scifir::mole operator"" _umol(long double);
433scifir::mole operator"" _nmol(long double);
434scifir::mole operator"" _pmol(long double);
435scifir::mole operator"" _fmol(long double);
436scifir::mole operator"" _amol(long double);
437scifir::mole operator"" _zmol(long double);
438scifir::mole operator"" _ymol(long double);
439scifir::mole operator"" _rmol(long double);
440scifir::mole operator"" _qmol(long double);
441
442scifir::light_intensity operator"" _Qcd(long double);
443scifir::light_intensity operator"" _Rcd(long double);
444scifir::light_intensity operator"" _Ycd(long double);
445scifir::light_intensity operator"" _Zcd(long double);
446scifir::light_intensity operator"" _Ecd(long double);
447scifir::light_intensity operator"" _Pcd(long double);
448scifir::light_intensity operator"" _Tcd(long double);
449scifir::light_intensity operator"" _Gcd(long double);
450scifir::light_intensity operator"" _Mcd(long double);
451scifir::light_intensity operator"" _kcd(long double);
452scifir::light_intensity operator"" _hcd(long double);
453scifir::light_intensity operator"" _dacd(long double);
454scifir::light_intensity operator"" _cd(long double);
455scifir::light_intensity operator"" _dcd(long double);
456scifir::light_intensity operator"" _ccd(long double);
457scifir::light_intensity operator"" _mcd(long double);
458scifir::light_intensity operator"" _ucd(long double);
459scifir::light_intensity operator"" _ncd(long double);
460scifir::light_intensity operator"" _pcd(long double);
461scifir::light_intensity operator"" _fcd(long double);
462scifir::light_intensity operator"" _acd(long double);
463scifir::light_intensity operator"" _zcd(long double);
464scifir::light_intensity operator"" _ycd(long double);
465scifir::light_intensity operator"" _rcd(long double);
466scifir::light_intensity operator"" _qcd(long double);
467
468scifir::information_size operator"" _QB(long double);
469scifir::information_size operator"" _RB(long double);
470scifir::information_size operator"" _YB(long double);
471scifir::information_size operator"" _ZB(long double);
472scifir::information_size operator"" _EB(long double);
473scifir::information_size operator"" _PB(long double);
474scifir::information_size operator"" _TB(long double);
475scifir::information_size operator"" _GB(long double);
476scifir::information_size operator"" _MB(long double);
477scifir::information_size operator"" _kB(long double);
478scifir::information_size operator"" _B(long double);
479
480scifir::information_size operator"" _Qbit(long double);
481scifir::information_size operator"" _Rbit(long double);
482scifir::information_size operator"" _Ybit(long double);
483scifir::information_size operator"" _Zbit(long double);
484scifir::information_size operator"" _Ebit(long double);
485scifir::information_size operator"" _Pbit(long double);
486scifir::information_size operator"" _Tbit(long double);
487scifir::information_size operator"" _Gbit(long double);
488scifir::information_size operator"" _Mbit(long double);
489scifir::information_size operator"" _kbit(long double);
490scifir::information_size operator"" _bit(long double);
491
492#endif // SCIFIR_UNITS_UNITS_BASE_UNITS_HPP_INCLUDED
position
Represents the position of the dimension, which can be at the numerator or at the denominator....
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 su...
Definition dimension.hpp:34
Class that allows to handle percentages and do calculations with it easy. It supports normal percenta...
type
Represents a prefix of the SI system of units. All the prefixes of the SI system of units are support...
Definition prefix.hpp:16
Class that allows to create scalar units, which are composed of a value (as a float) and dimensions....
void operator+=(scalar_unit x)
Addition operator, it adds a scalar_unit class to another, by converting their dimensions to be equal...
void operator-=(scalar_unit x)
Substraction operator, it substracts a scalar_unit class to another, by converting their dimensions t...
static const vector< dimension > real_dimensions
scifir::time_duration & operator+=(chrono::duration< T1, T2 > x)
string display_hours() const
string get_finish_date() const
string display_minutes() const
string display_seconds() const
string display_weeks() const
string display_months() const
string display_days() const
static const string dimensions_match
string display_as_time() const
scifir::time_duration & operator-=(chrono::duration< T1, T2 > x)
string display_years() const
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
Definition address.cpp:6
SCALAR_UNIT_HPP_END()
int get_number_of_particles() const
mole(const percentage &new_percentage, const mole &new_mole)
mass(const percentage &new_percentage, const mass &new_mass)
#define SCALAR_UNIT_HPP(name)
#define SCALAR_UNIT_HPP_BEGIN(name)