1 #ifndef COOLPROPTOOLS_H
2 #define COOLPROPTOOLS_H
4 #ifndef _CRT_SECURE_NO_WARNINGS
5 # define _CRT_SECURE_NO_WARNINGS
20 # define __has_feature(x) 0
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
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;
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));
83 numbers.insert(std::pair<std::string, double>(s1, d));
86 return numbers.find(s1) != numbers.end();
89 double_vectors.insert(std::pair<std::string, std::vector<double>>(s1, d));
92 string_vectors.insert(std::pair<std::string, std::vector<std::string>>(s1, d));
95 strings_map::const_iterator i = strings.find(s);
96 if (i != strings.end()) {
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;
123 double_vectors_map::const_iterator i = double_vectors.find(s);
124 if (i != double_vectors.end()) {
131 string_vectors_map::const_iterator i = string_vectors.find(s);
132 if (i != string_vectors.end()) {
141 template <
typename M>
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) { \