Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Names.hpp File Reference
#include "details/utils.hpp"
#include <unordered_map>
#include <stdexcept>
#include <string>
Include dependency graph for Names.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  shamunits
 namespace containing the units library

Macros

#define XMAC_UNITS
 Definition of all units.
#define XMAC_UNIT_PREFIX
 Definition of all prefixes.
#define X(longname, shortname, value)
 Macro expending to all units prefixes in the enum.
#define X(longname, shortname, value)
 Macro expending to all units prefixes in the enum.
#define X(longname, shortname, value)
 Macro expending to all units prefixes in the enum.
#define X1(longname, shortname)
 Macro expanding to all unit names.
#define X1(longname, shortname)
 Macro expanding to all unit names.
#define X1(longname, shortname)
 Macro expanding to all unit names.

Enumerations

enum  shamunits::UnitPrefix {
  tera = 12 , T = 12 , giga = 9 , G = 9 ,
  mega = 6 , M = 6 , kilo = 3 , k = 3 ,
  hecto = 2 , hect = 2 , deca = 1 , dec = 1 ,
  None = 0 , _ = 0 , centi = -2 , c = -2 ,
  milli = -3 , m = -3 , micro = -6 , mu = -6 ,
  nano = -9 , n = -9 , pico = -12 , p = -12 ,
  femto = -15 , f = -15
}
 Enum of all prefixes. More...
enum  shamunits::units::UnitName {
  second , s = second , metre , m = metre ,
  kilogram , kg = kilogram , Ampere , A = Ampere ,
  Kelvin , K = Kelvin , mole , mol = mole ,
  candela , cd = candela , Hertz , Hz = Hertz ,
  Newton , N = Newton , Pascal , Pa = Pascal ,
  Joule , J = Joule , Watt , W = Watt ,
  Coulomb , C = Coulomb , Volt , V = Volt ,
  Farad , F = Farad , Ohm , ohm = Ohm ,
  Siemens , S = Siemens , Weber , Wb = Weber ,
  Tesla , T = Tesla , Henry , H = Henry ,
  lumens , lm = lumens , lux , lx = lux ,
  Bequerel , Bq = Bequerel , Gray , Gy = Gray ,
  Sievert , Sv = Sievert , katal , kat = katal ,
  minutes , mn = minutes , hours , hr = hours ,
  days , dy = days , years , yr = years ,
  astronomical_unit , au = astronomical_unit , light_year , ly = light_year ,
  parsec , pc = parsec , solar_radius , rsol = solar_radius ,
  earth_radius , rearth = earth_radius , electron_volt , eV = electron_volt ,
  ergs , erg = ergs , british_pint , pint = british_pint
}
 List of all units name. More...

Functions

template<class T, UnitPrefix p>
constexpr T shamunits::get_prefix_val ()
 Get the value of a prefix.
const std::string shamunits::get_unit_prefix_name (UnitPrefix p)
 Get the prefix name for a UnitPrefix enum value.
const UnitPrefix shamunits::unit_prefix_from_name (std::string p)
 Get the UnitPrefix enum value from a prefix name as a string.
const std::string shamunits::units::get_unit_name (UnitName p)
 Get the unit name for a UnitName enum value.
const UnitName shamunits::units::unit_from_name (std::string p)
 Get the UnitName enum value from a unit name as a string.

Detailed Description

Macro Definition Documentation

◆ X [1/3]

#define X ( longname,
shortname,
value )
Value:
{shortname, #shortname},

Macro expending to all units prefixes in the enum.

Definition at line 92 of file Names.hpp.

◆ X [2/3]

#define X ( longname,
shortname,
value )
Value:
{#longname, longname}, {#shortname, shortname},

Macro expending to all units prefixes in the enum.

Definition at line 92 of file Names.hpp.

◆ X [3/3]

#define X ( longname,
shortname,
value )
Value:
longname = value, shortname = value,

Macro expending to all units prefixes in the enum.

Definition at line 92 of file Names.hpp.

◆ X1 [1/3]

#define X1 ( longname,
shortname )
Value:
{shortname, #shortname},

Macro expanding to all unit names.

Definition at line 156 of file Names.hpp.

◆ X1 [2/3]

#define X1 ( longname,
shortname )
Value:
{#longname, longname}, {#shortname, shortname},

Macro expanding to all unit names.

Definition at line 156 of file Names.hpp.

◆ X1 [3/3]

#define X1 ( longname,
shortname )
Value:
longname, shortname = longname,

Macro expanding to all unit names.

Definition at line 156 of file Names.hpp.

◆ XMAC_UNIT_PREFIX

#define XMAC_UNIT_PREFIX
Value:
X(tera, T, 12) \
X(giga, G, 9) \
X(mega, M, 6) \
X(kilo, k, 3) \
X(hecto, hect, 2) \
X(deca, dec, 1) \
X(None, _, 0) \
/*X(deci ,deci_, -1)*/ \
X(centi, c, -2) \
X(milli, m, -3) \
X(micro, mu, -6) \
X(nano, n, -9) \
X(pico, p, -12) \
X(femto, f, -15)
#define X
Temp definition for the X macro call to define the log levels.
Definition logs.hpp:132

Definition of all prefixes.

Definition at line 70 of file Names.hpp.

◆ XMAC_UNITS

#define XMAC_UNITS

Definition of all units.

This defines units and their short name

Definition at line 27 of file Names.hpp.

Enumeration Type Documentation

◆ UnitName

List of all units name.

Definition at line 154 of file Names.hpp.

Function Documentation

◆ get_unit_name()

const std::string shamunits::units::get_unit_name ( UnitName p)
inline

Get the unit name for a UnitName enum value.

Definition at line 179 of file Names.hpp.

◆ unit_from_name()

const UnitName shamunits::units::unit_from_name ( std::string p)
inline

Get the UnitName enum value from a unit name as a string.

Definition at line 191 of file Names.hpp.