1 #ifndef COOLPROPTOOLS_H 2 #define COOLPROPTOOLS_H 4 #ifndef _CRT_SECURE_NO_WARNINGS 5 # define _CRT_SECURE_NO_WARNINGS 8 #include "PlatformDetermination.h" 9 #include "Exceptions.h" 15 #include "CPstrings.h" 16 #include "CPnumerics.h" 17 #include "CPfilepaths.h" 19 #ifndef __has_feature // Optional of course. 20 # define __has_feature(x) 0 // Compatibility with non-clang compilers. 29 # if __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__ 30 # define thread_local _Thread_local 31 # elif defined _WIN32 && (defined _MSC_VER || defined __ICL || defined __DMC__ || defined __BORLANDC__) 32 # define thread_local __declspec(thread) 33 # elif defined(__ISAPPLE__) && (defined(__llvm__) || defined(__clang__)) && !__has_feature(cxx_thread_local) 36 # elif defined __GNUC__ || defined __SUNPRO_C || defined __xlC__ 37 # define thread_local __thread 39 # error "Cannot define thread_local" 44 #define COOLPROPDBL_MAPS_TO_DOUBLE 45 #ifdef COOLPROPDBL_MAPS_TO_DOUBLE 46 typedef double CoolPropDbl;
48 typedef long double CoolPropDbl;
53 # define DEPRECATED(func) func __attribute__((deprecated)) 54 #elif defined(_MSC_VER) 55 # define DEPRECATED(func) __declspec(deprecated) func 57 # pragma message("WARNING: You need to implement DEPRECATED for this compiler") 58 # define DEPRECATED(func) func 64 typedef std::map<std::string, double> numbers_map;
66 typedef std::map<std::string, std::string> strings_map;
68 typedef std::map<std::string, std::vector<double>> double_vectors_map;
69 double_vectors_map double_vectors;
70 typedef std::map<std::string, std::vector<std::string>> string_vectors_map;
71 string_vectors_map string_vectors;
75 bool is_empty(
void)
const {
76 return numbers.empty() && strings.empty() && double_vectors.empty() && string_vectors.empty();
78 void add_string(
const std::string& s1,
const std::string& s2) {
79 strings.insert(std::pair<std::string, std::string>(s1, s2));
81 void add_number(
const std::string& s1,
double d) {
83 numbers.insert(std::pair<std::string, double>(s1, d));
85 bool has_number(
const std::string& s1) {
86 return numbers.find(s1) != numbers.end();
88 void add_double_vector(
const std::string& s1,
const std::vector<double>& d) {
89 double_vectors.insert(std::pair<std::string, std::vector<double>>(s1, d));
91 void add_string_vector(
const std::string& s1,
const std::vector<std::string>& d) {
92 string_vectors.insert(std::pair<std::string, std::vector<std::string>>(s1, d));
94 std::string get_string(
const std::string& s)
const {
95 strings_map::const_iterator i = strings.find(s);
96 if (i != strings.end()) {
102 double get_double(
const std::string& s)
const {
103 numbers_map::const_iterator i = numbers.find(s);
104 if (i != numbers.end()) {
111 double get_double(
const std::string& s,
const double default_value)
const {
112 numbers_map::const_iterator i = numbers.find(s);
113 if (i != numbers.end()) {
116 return default_value;
119 double get_number(
const std::string& s)
const {
120 return get_double(s);
122 const std::vector<double>& get_double_vector(
const std::string& s)
const {
123 double_vectors_map::const_iterator i = double_vectors.find(s);
124 if (i != double_vectors.end()) {
130 const std::vector<std::string>& get_string_vector(
const std::string& s)
const {
131 string_vectors_map::const_iterator i = string_vectors.find(s);
132 if (i != string_vectors.end()) {
141 template <
typename M>
142 void freeClear(M& amap) {
143 for (
typename M::iterator it = amap.begin(); it != amap.end(); ++it) {
149 #define CATCH_ALL_ERRORS_RETURN_HUGE(x) \ 152 } catch (const std::exception& e) { \ 163 void miniz(
const std::string& inFile,
const std::string& outFile, miniz_mode mode);
Definition: CoolPropTools.h:61
Definition: Exceptions.h:45
double get_double(const std::string &s, const double default_value) const
Get a double, or return the default value if not found.
Definition: CoolPropTools.h:111