Bayeux  3.4.1
Core Foundation library for SuperNEMO
Classes | Namespaces | Macros | Enumerations | Functions
units.h File Reference
#include <string>
#include <vector>
#include <set>
#include <map>
#include <limits>
#include <list>
#include <boost/cstdint.hpp>
#include <datatools/exception.h>
#include <datatools/i_tree_dump.h>
#include <datatools/reflection_interface.h>

Go to the source code of this file.

Classes

class  datatools::units::unit
 The description of an unit. More...
 
class  datatools::units::unit_dimension
 The description of an unit dimension. More...
 
class  datatools::units::registry
 A registry for units. More...
 

Namespaces

 datatools
 The Bayeux/datatools library top-level namespace.
 
 datatools::units
 Utilities for units based on the CLHEP library's implementation.
 

Macros

#define DT_THROW_BAD_UNIT(UnitType, UnitSymbol)
 Throw a special exception when UnitSymbol does not match UnitType. More...
 

Enumerations

enum  datatools::units::power_of_ten {
  datatools::units::YOCTO = -24, datatools::units::ZEPTO = -21, datatools::units::ATTO = -18, datatools::units::FEMTO = -15,
  datatools::units::PICO = -12, datatools::units::NANO = -9, datatools::units::MICRO = -6, datatools::units::MILLI = -3,
  datatools::units::CENTI = -2, datatools::units::DECI = -1, datatools::units::UNIT_POWER_OF_TEN = 0, datatools::units::DECA = 1,
  datatools::units::HECTO = 2, datatools::units::KILO = 3, datatools::units::MEGA = 6, datatools::units::GIGA = 9,
  datatools::units::TERA = 12, datatools::units::PETA = 15, datatools::units::EXA = 18, datatools::units::ZETTA = 21,
  datatools::units::YOTTA = 24
}
 SI powers of ten. More...
 
enum  datatools::units::power_of_two {
  datatools::units::UNIT_POWER_OF_TWO = 0, datatools::units::KIBI = 10, datatools::units::MEBI = 20, datatools::units::GIBI = 30,
  datatools::units::TEBI = 40, datatools::units::PEBI = 50, datatools::units::EXBI = 60, datatools::units::ZEBI = 70,
  datatools::units::YOBI = 80
}
 IEC powers of two (binary prefixes) More...
 

Functions

double datatools::units::yocto ()
 
double datatools::units::zepto ()
 
double datatools::units::atto ()
 
double datatools::units::femto ()
 
double datatools::units::pico ()
 
double datatools::units::nano ()
 
double datatools::units::micro ()
 
double datatools::units::milli ()
 
double datatools::units::centi ()
 
double datatools::units::deci ()
 
double datatools::units::deca ()
 
double datatools::units::hecto ()
 
double datatools::units::kilo ()
 
double datatools::units::mega ()
 
double datatools::units::giga ()
 
double datatools::units::tera ()
 
double datatools::units::peta ()
 
double datatools::units::exa ()
 
double datatools::units::zetta ()
 
double datatools::units::yotta ()
 
double datatools::units::power_of_ten_to_factor (power_of_ten)
 Return the SI prefix factor associated to a given SI power of ten. More...
 
std::string datatools::units::power_of_ten_to_name (power_of_ten)
 Return the SI name associated to a given SI power of ten. More...
 
std::string datatools::units::power_of_ten_to_symbol (power_of_ten)
 Return the SI symbol associated to a given SI power of ten. More...
 
double datatools::units::byte_to_bit_factor ()
 Return the IEC 80000-13 byte (octet 8 bits) to bit factor. More...
 
double datatools::units::power_of_two_to_factor (power_of_two)
 Return the IEC binary prefix approximated factor associated to a given IEC power of two. More...
 
std::string datatools::units::power_of_two_to_name (power_of_two)
 Return the IEC binary prefix name associated to a given IEC power of two. More...
 
std::string datatools::units::power_of_two_to_symbol (power_of_two)
 Return the IEC binary prefix symbol associated to a given IEC power of two. More...
 
size_t datatools::units::registered_unit_dimension_labels (std::vector< std::string > &dimension_labels_)
 
size_t datatools::units::registered_unit_names (std::vector< std::string > &unit_names_)
 
size_t datatools::units::registered_unit_symbols (std::vector< std::string > &unit_symbols_)
 
bool datatools::units::is_unit_in_dimension_from (const std::string &unit_id_, const std::string &unit_dimension_label_)
 
double datatools::units::get_unit_in_dimension_from (const std::string &unit_id_, const std::string &unit_dimension_label_)
 
double datatools::units::get_length_unit_from (const std::string &unit_id_)
 
double datatools::units::get_surface_unit_from (const std::string &)
 Get the surface unit value from a string. More...
 
double datatools::units::get_volume_unit_from (const std::string &)
 Get the volume unit value from a string. More...
 
double datatools::units::get_time_unit_from (const std::string &)
 Get the time unit value from a string. More...
 
double datatools::units::get_angle_unit_from (const std::string &)
 Get the angle unit value from a string. More...
 
double datatools::units::get_solid_angle_unit_from (const std::string &)
 Get the solid angle unit value from a string. More...
 
double datatools::units::get_energy_unit_from (const std::string &)
 Get the energy unit from a string. More...
 
double datatools::units::get_mass_unit_from (const std::string &)
 Get the mass unitvalue from a string. More...
 
double datatools::units::get_pressure_unit_from (const std::string &)
 Get the pressure unit value from a string. More...
 
double datatools::units::get_magnetic_flux_density_unit_from (const std::string &)
 Get the magnetic field unit value from a string. More...
 
double datatools::units::get_magnetic_field_unit_from (const std::string &)
 
double datatools::units::get_electric_field_unit_from (const std::string &)
 Get the electric field unit value from a string. More...
 
double datatools::units::get_electric_potential_unit_from (const std::string &)
 Get the electric potential unit value from a string. More...
 
double datatools::units::get_electric_tension_unit_from (const std::string &)
 
double datatools::units::get_temperature_unit_from (const std::string &)
 Get the temperature unit value from a string. More...
 
double datatools::units::get_density_unit_from (const std::string &)
 Get the density unit value from a string. More...
 
double datatools::units::get_activity_unit_from (const std::string &)
 Get the activity unit value from a string. More...
 
double datatools::units::get_surface_activity_unit_from (const std::string &)
 Get the surface activity unit value from a string. More...
 
double datatools::units::get_volume_activity_unit_from (const std::string &)
 Get the volume activity unit value from a string. More...
 
double datatools::units::get_mass_activity_unit_from (const std::string &)
 Get the mass activity unit value from a string. More...
 
double datatools::units::get_frequency_unit_from (const std::string &)
 Get the frequency unit value from a string. More...
 
double datatools::units::get_electric_charge_unit_from (const std::string &)
 Get the electric charge unit value from a string. More...
 
double datatools::units::get_electric_current_unit_from (const std::string &)
 Get the electric current unit value from a string. More...
 
double datatools::units::get_velocity_unit_from (const std::string &)
 Get the velocity unit value from a string. More...
 
double datatools::units::get_speed_unit_from (const std::string &)
 
double datatools::units::get_unit_from (const std::string &unit_type_, const std::string &unit_str_)
 Get the CLHEP unit value from a string specifiying the unit type. More...
 
double datatools::units::get_unit (const std::string &unit_str_, bool throw_=false)
 Get the CLHEP unspecified unit value from a string. More...
 
bool datatools::units::is_unit_label_valid (const std::string &unit_label_)
 Return an array containing the labels associated to all type of units supported by the datatools::units class. More...
 
std::string datatools::units::get_default_unit_symbol_from_label (const std::string &unit_label_)
 Return the symbol of the default unit associated to a unit label supported by the datatools::units class. More...
 
bool datatools::units::find_unit (const std::string &unit_str_, double &unit_value_, std::string &unit_label_)
 Find the specified unit and the associated unit label from a string. More...
 
double datatools::units::get_value_with_unit (const std::string &word_)
 Get a value from a string taking into account the unit symbol. More...
 
bool datatools::units::find_value_with_unit (const std::string &word_, double &value_, std::string &unit_label_, double default_unit_=std::numeric_limits< double >::quiet_NaN())
 Get a value from a string taking into account the unit symbol. More...
 
bool datatools::units::parse_value_with_unit (const std::string &word, double &value, std::string &unit_symbol, std::string &unit_label, uint32_t flags=0)
 Parse a value from a string taking into account the unit symbol, set the value, the unit symbol and unit label. More...
 

Macro Definition Documentation

◆ DT_THROW_BAD_UNIT

#define DT_THROW_BAD_UNIT (   UnitType,
  UnitSymbol 
)
Value:
DT_THROW_IF(true,std::logic_error, \
"Invalid '" << UnitType << "' unit for symbol '" << UnitSymbol << "' !")
#define DT_THROW_IF(Condition, ExceptionType, Message)
Definition: exception.h:76

Throw a special exception when UnitSymbol does not match UnitType.