Project
Loading...
Searching...
No Matches
conversions.h File Reference

Defines conversion functions, e.g. to_string(12_m). More...

#include <string>
#include <SI/literals.h>

Go to the source code of this file.

Namespaces

namespace  SI

Functions

bool SI::from_string (const std::string &str, length &result)
 The from_string() function.
bool SI::from_string (const std::string &str, time &result)
bool SI::from_string (const std::string &str, mass &result)
std::string SI::_join (long double quantity, const char *unit, const char *formatString)
std::string SI::to_string (const length d)
 Returns the given length as string using SI units.
std::string SI::to_equivalent (const length d)
 Returns a length equivalent as string, e.g. in Imperial units.
std::ostream & SI::operator<< (std::ostream &os, const length d)
std::string SI::to_string (const time t)
 Returns the given time as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const time t)
std::string SI::to_string (const mass m)
 Returns the given mass as string using SI units.
std::string SI::to_equivalent (const mass m)
 Returns a mass equivalent as string, e.g. in Imperial units.
std::ostream & SI::operator<< (std::ostream &os, const mass m)
std::string SI::to_string (const temperature T)
 Returns the given temperature as string using SI units.
std::string SI::to_equivalent (const temperature T)
 Returns a temperature equivalent as string, e.g. in Fahrenheit.
std::ostream & SI::operator<< (std::ostream &os, const temperature T)
std::string SI::to_string (const electric_current I)
 Returns the electric current (I) as string using SI units.
std::string SI::to_string (const area a)
 Returns the given area as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const area a)
std::string SI::to_string (const per_area a)
 Returns the per area as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const per_area a)
std::string SI::to_string (const volume v)
 Returns the given volume as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const volume v)
std::string SI::to_string (const velocity v)
 Returns velocity as string using SI units.
std::string SI::to_equivalent (const velocity V)
 Returns a velocity equivalent as string, e.g. in Imperial units.
std::ostream & SI::operator<< (std::ostream &os, const velocity v)
std::string SI::to_string (const acceleration a)
 Returns the acceleration as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const acceleration a)
std::string SI::to_string (const frequency f)
 Returns the frequency as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const frequency f)
std::string SI::to_string (const force F)
 Returns the force as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const force F)
std::string SI::to_string (const energy E)
 Returns the energy as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const energy E)
std::string SI::to_string (const power P)
 Returns the power as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const power P)
std::string SI::to_string (const power_intensity I)
 Returns the power intensity as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const power_intensity I)
std::string SI::to_string (const pressure p)
 Returns the pressure as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const pressure p)
std::string SI::to_string (const electric_potential U)
 Returns the electric potential as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const electric_potential U)
std::string SI::to_string (const electric_charge Q)
 Returns the electric charge as string using SI units.
std::string SI::to_string (const mass_per_area m)
std::string SI::to_string (const mass_per_power m)
 Returns the mass per power as string using SI units.
std::ostream & SI::operator<< (std::ostream &os, const mass_per_power m)
std::string SI::to_string (const density d)
 Returns density as string using SI units.
std::string SI::to_string (const angle a)
 Returns the angle as string in degree.
std::string SI::to_string (const dimensionless value)
std::string SI::to_string (const unsigned char byte)
std::string SI::to_string (const char glyph)
std::string SI::to_string (const std::string &text)
std::string SI::to_equivalent (const power_intensity I)
 Returns a power intensity equivalent as string, e.g. in dB.
std::string SI::to_equivalent (const energy E)
 Returns an energy equivalent as string, e.g. kg TNT.
std::string SI::to_percentage (length part, length total)
 Returns the percentage as string, e.g. 50.0%.

Variables

auto SI::to_string_format = "%.2Lf %s"
 configurable, SI standard formatting by default
auto SI::to_equivalent_format = "%.2Lf %s"
 configurable, SI standard formatting by default
auto SI::to_percentage_format = "%.0Lf %s"
 configurable

Detailed Description

Defines conversion functions, e.g. to_string(12_m).

Provides from_string(), to_string(), to_equivalent(), and to_percentage().