1 /* 2 Qalculate 3 4 Copyright (C) 2019 Hanna Knutsson (hanna.knutsson@protonmail.com) 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 */ 11 12 #if HAVE_UNORDERED_MAP 13 # include <unordered_map> 14 using std::unordered_map; 15 #elif defined(__GNUC__) 16 17 # ifndef __has_include 18 # define __has_include(x) 0 19 # endif 20 21 # if (defined(__clang__) && __has_include(<tr1/unordered_map>)) || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 3) 22 # include <tr1/unordered_map> 23 namespace Sgi = std; 24 # define unordered_map std::tr1::unordered_map 25 # else 26 # if __GNUC__ < 3 27 # include <hash_map.h> 28 namespace Sgi { using ::hash_map; }; // inherit globals 29 # else 30 # include <ext/hash_map> 31 # if __GNUC__ == 3 && __GNUC_MINOR__ == 0 32 namespace Sgi = std; // GCC 3.0 33 # else 34 namespace Sgi = ::__gnu_cxx; // GCC 3.1 and later 35 # endif 36 # endif 37 # define unordered_map Sgi::hash_map 38 # endif 39 #else // ... there are other compilers, right? 40 namespace Sgi = std; 41 # define unordered_map Sgi::hash_map 42 #endif 43 44 #ifndef CALCULATOR_P_H 45 #define CALCULATOR_P_H 46 47 enum { 48 PROC_RPN_ADD, 49 PROC_RPN_SET, 50 PROC_RPN_OPERATION_1, 51 PROC_RPN_OPERATION_2, 52 PROC_RPN_OPERATION_F, 53 PROC_NO_COMMAND 54 }; 55 56 class Calculator_p { 57 public: 58 unordered_map<size_t, MathStructure*> id_structs; 59 unordered_map<size_t, bool> ids_p; 60 vector<size_t> freed_ids; 61 size_t ids_i; 62 Number custom_input_base, custom_output_base; 63 long int custom_input_base_i; 64 Unit *local_currency; 65 int use_binary_prefixes; 66 MathFunction *f_cis, *f_erfi, *f_fresnels, *f_fresnelc; 67 Unit *u_byn; 68 Unit *u_kelvin, *u_rankine, *u_celsius, *u_fahrenheit; 69 unordered_map<int, MathFunction*> id_functions; 70 unordered_map<int, Variable*> id_variables; 71 unordered_map<int, Unit*> id_units; 72 time_t exchange_rates_time2[1], exchange_rates_check_time2[1]; 73 TemperatureCalculationMode temperature_calculation; 74 }; 75 76 class CalculateThread : public Thread { 77 protected: 78 virtual void run(); 79 }; 80 81 bool is_not_number(char c, int base); 82 83 #endif 84