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
prefix.hpp
Go to the documentation of this file.
1#ifndef SCIFIR_UNITS_UNITS_PREFIX_HPP_INCLUDED
2#define SCIFIR_UNITS_UNITS_PREFIX_HPP_INCLUDED
3
4#include <cstdint>
5#include <iostream>
6#include <map>
7#include <string>
8
9using namespace std;
10
11namespace scifir
12{
13 class prefix
14 {
15 public:
17
18 prefix();
19 prefix(const prefix& x);
20 prefix(prefix&& x);
22 explicit prefix(const string& new_type);
23
24 prefix& operator =(const prefix& x);
26
27 int get_conversion_factor() const;
28 string get_name() const;
29 string get_symbol() const;
30
31 bool operator<(const scifir::prefix& x) const;
32
34 };
35
36 prefix::type prefix_string(const string& x);
37
40}
41
42bool operator ==(const scifir::prefix& x,const scifir::prefix& y);
43bool operator !=(const scifir::prefix& x,const scifir::prefix& y);
44bool operator <=(const scifir::prefix& x,const scifir::prefix& y);
45bool operator >(const scifir::prefix& x,const scifir::prefix& y);
46bool operator >=(const scifir::prefix& x,const scifir::prefix& y);
47
48ostream& operator <<(ostream& os, const scifir::prefix& x);
49
50#endif // SCIFIR_UNITS_UNITS_PREFIX_HPP_INCLUDED
Class that represents prefixes of the SI system of units. Each prefix sizes 1 byte....
Definition prefix.hpp:14
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
prefix::type prefix_type
It stores the prefix type currently being used.
Definition prefix.hpp:33
prefix()
Default constructor. The prefix_type is set to NONE.
Definition prefix.cpp:9
string get_symbol() const
Symbol of the prefix given the prefix_type. The symbol of micro is supported in his Unicode version.
Definition prefix.cpp:152
string get_name() const
Name of the prefix given the prefix_type.
Definition prefix.cpp:94
prefix & operator=(const prefix &x)
Copy assignment. The prefix_type is copied from the prefix x.
Definition prefix.cpp:24
bool operator<(const scifir::prefix &x) const
This operator allows to order the prefixes from the lower to the greather.
Definition prefix.cpp:210
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
@ 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
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
Definition address.cpp:6
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
prefix closest_prefix(const prefix &actual_prefix, int actual_scale)
Returns the closes prefix related to the scale of the current value. It is used when displaying a sca...
Definition prefix.cpp:323
prefix create_prefix_by_factor(int factor)
Creates the prefix of the factor given, which is always between a range.
Definition prefix.cpp:330
bool operator!=(const scifir::prefix &x, const scifir::prefix &y)
Comparison operator. Compares if two prefixes are different, that's, if they don't have the same pref...
Definition prefix.cpp:441
bool operator<=(const scifir::prefix &x, const scifir::prefix &y)
Checks if prefix x is of a lower or equal factor than prefix y.
Definition prefix.cpp:446
bool operator>=(const scifir::prefix &x, const scifir::prefix &y)
Checks if prefix x is of an equal or greather factor than prefix y.
Definition prefix.cpp:456
bool operator>(const scifir::prefix &x, const scifir::prefix &y)
Checks if prefix x is of a greather factor than prefix y.
Definition prefix.cpp:451
ostream & operator<<(ostream &os, const scifir::prefix &x)
Adds the string representation of the prefix x to an output stream.
Definition prefix.cpp:461
bool operator==(const scifir::prefix &x, const scifir::prefix &y)
Comparison operator. Compares if two prefixes are the same, that's, if they have the same prefix::typ...
Definition prefix.cpp:436