Elements 6.1.2
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
Storage.cpp
Go to the documentation of this file.
1
22
23#include <cmath> // for pow, round, log10
24#include <cstddef> // for size_t
25#include <cstdint> // for int64_t
26#include <map> // for map
27#include <string> // for string
28
29using std::int64_t;
30using std::map;
31using std::pow;
32using std::size_t;
33
34namespace Elements {
35inline namespace Kernel {
36namespace Units {
37
39 {StorageType::KiloByte, "KiB"},
40 {StorageType::MegaByte, "MiB"},
41 {StorageType::GigaByte, "GiB"},
42 {StorageType::TeraByte, "TiB"},
43 {StorageType::PetaByte, "PiB"},
49
51 {StorageType::KiloByte, pow(2, 10)},
52 {StorageType::MegaByte, pow(2, 20)},
53 {StorageType::GigaByte, pow(2, 30)},
54 {StorageType::TeraByte, pow(2, 40)},
55 {StorageType::PetaByte, pow(2, 50)},
56 {StorageType::MetricKiloByte, pow(10, 3)},
57 {StorageType::MetricMegaByte, pow(10, 6)},
58 {StorageType::MetricGigaByte, pow(10, 9)},
59 {StorageType::MetricTeraByte, pow(10, 12)},
60 {StorageType::MetricPetaByte, pow(10, 15)}};
61
62// explicit instantiation: without the template<>. Otherwise this is a template specialization
63template double roundToDigits<double>(const double& value, const size_t& max_digits);
64template float roundToDigits<float>(const float& value, const size_t& max_digits);
65
66template double storageConvert<double>(const double& size, StorageType source_unit, StorageType target_unit);
67template float storageConvert<float>(const float& size, StorageType source_unit, StorageType target_unit);
68template int64_t storageConvert<int64_t>(const int64_t& size, StorageType source_unit, StorageType target_unit);
69
70} // namespace Units
71} // namespace Kernel
72} // namespace Elements
template int64_t storageConvert< int64_t >(const int64_t &size, StorageType source_unit, StorageType target_unit)
template ELEMENTS_API float roundToDigits< float >(const float &value, const std::size_t &max_digits)
template ELEMENTS_API float storageConvert< float >(const float &size, StorageType source_unit, StorageType target_unit)
ELEMENTS_API std::map< StorageType, std::string > StorageShortName
Definition: Storage.cpp:38
template ELEMENTS_API double roundToDigits< double >(const double &value, const std::size_t &max_digits)
ELEMENTS_API std::map< StorageType, std::int64_t > StorageFactor
Definition: Storage.cpp:50
template ELEMENTS_API double storageConvert< double >(const double &size, StorageType source_unit, StorageType target_unit)
T pow(T... args)