Physical Quantities  v1.0.0
C++ library of physical quantities, physical models, and units of measure for scientific computing. https://github.com/acodcha/phq
Namespaces | Functions | Variables
Base.hpp File Reference
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iterator>
#include <limits>
#include <map>
#include <optional>
#include <sstream>
#include <string>
#include <string_view>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces

 PhQ
 Namespace that encompasses all of the Physical Quantities library's content.
 
 PhQ::Dimension
 Namespace that contains base physical dimensions.
 

Functions

template<typename Enumeration >
std::string_view PhQ::Abbreviation (const Enumeration enumeration)
 Returns the abbreviation of a given enumeration value. For example, PhQ::Abbreviation(PhQ::Unit::Time::Hour) returns "hr". More...
 
template<typename Enumeration >
std::optional< Enumeration > PhQ::ParseEnumeration (const std::string_view spelling)
 Attempts to parse the given string as an enumeration of the given type. Returns a std::optional container that contains the resulting enumeration if successful, or std::nullopt if the given string could not be parsed into an enumeration of the given type. More...
 
template<typename NumericType = double>
std::optional< NumericType > PhQ::ParseNumber (const std::string &string)
 Parses the given string as a number of the given numeric type. Returns a std::optional container that contains the resulting number if successful, or std::nullopt if the string could not be parsed into the given numeric type. More...
 
template<>
std::optional< float > PhQ::ParseNumber (const std::string &string)
 Parses the given string as a single-precision floating-point number (a float). Returns a std::optional container that contains the resulting number if successful, or std::nullopt if the string could not be parsed into a float. More...
 
template<typename NumericType >
std::string PhQ::Print (const NumericType value)
 Prints a given floating-point number as a string. Prints enough digits to represent the number exactly. The printed number of digits depends on the type of the floating-point number. More...
 
std::string PhQ::Lowercase (const std::string_view string)
 Returns a copy of the given string where all characters are lowercase. More...
 
std::string PhQ::Uppercase (const std::string_view string)
 Returns a copy of the given string where all characters are uppercase. More...
 
std::string PhQ::SnakeCase (const std::string_view string)
 Returns a copy of the given string in snake case: all characters are lowercase and all spaces are replaced with underscores. More...
 

Variables

template<typename NumericType = double>
constexpr NumericType PhQ::Pi
 The mathematical constant π = 3.14... More...
 
template<>
constexpr float PhQ::Pi< float > {3.1415927F}
 The mathematical constant π = 3.14... expressed as a single-precision 32-bit binary floating-point number. More...
 
template<>
constexpr double PhQ::Pi< double > {3.14159265358979323846}
 The mathematical constant π = 3.14... expressed as a double-precision 64-bit binary floating-point number. More...
 
template<>
constexpr const long double PhQ::Pi< long double > {3.141592653589793238462643383279502884L}
 The mathematical constant π = 3.14... expressed as an extended-precision binary floating-point number. The exact implementation of the extended-precision type varies; the most common implementations are 64-bit, 80-bit, 96-bit, or 128-bit binary floating-point numbers. More...