18 #ifndef HLIDAC_PES_UTILS_H 
   19 #define HLIDAC_PES_UTILS_H 
   31 #include <type_traits> 
   35 #include "SolverConfig.h" 
   62 typename C::mapped_type getValue(
const C& m, 
const typename C::key_type& key, std::string calledFrom)   {
 
   63         typename C::const_iterator it = m.find(key);
 
   67                 std::string msg = 
"Invalid key!\n\n";
 
   68                 msg += 
"Called from:\n"+calledFrom;
 
   74 void setValueHelper(C& m, 
const typename C::key_type& key, 
const typename C::mapped_type& value, std::string calledFrom)    {
 
   75         auto p = m.insert({key, value});
 
   76         if (p.second == 
false)  {
 
   77                 std::string msg = 
"Value with the same key already exists!\n\n";
 
   78                 msg += 
"Called from:\n"+calledFrom;
 
   83 template <
class C, 
class T = 
typename C::mapped_type>
 
   84 void setValue(C& m, 
const typename C::key_type& key, 
const typename std::enable_if<std::is_pointer<T>::value, T>::type& value, std::string calledFrom)  {
 
   85         if (value == 
nullptr)   {
 
   86                 std::string msg = 
"Attempt to store nullptr as a value!\n\n";
 
   87                 msg += 
"Called from:\n"+calledFrom;
 
   91         setValueHelper(m, key, value, calledFrom);
 
   94 template <
class C, 
class T = 
typename C::mapped_type>
 
   95 void setValue(C& m, 
const typename C::key_type& key, 
const typename std::enable_if<!std::is_pointer<T>::value, T>::type& value, std::string calledFrom) {
 
   96         setValueHelper(m, key, value, calledFrom);
 
  105 uint64_t 
pack(
const uint32_t& v1, 
const uint32_t& v2);
 
  111 std::pair<uint32_t, uint32_t> 
unpack(
const uint64_t& v);
 
  126 extern uint64_t 
hashOW(
const C& v);
 
  136 extern uintptr_t 
hashEW(
const C& v);
 
  145 bool fileExists(
const std::string& pathToFile);
 
A general exception of the program. 
 
bool fileExists(const std::string &pathToFile)
It checks the existence of the file. 
 
uint64_t hashOW(const C &v)
It calculates a hash of the container, the order of elements influences (Order Wise) the hash value...
 
uintptr_t hashEW(const C &v)
It calculates a hash of the container, the order of elements does not influence (Element Wise) the ha...
 
The file defines extended exceptions for the better error handling in the program. 
 
std::pair< uint32_t, uint32_t > unpack(const uint64_t &v)
It unpacks two uint32_t numbers from uint64_t data type. 
 
uint64_t pack(const uint32_t &v1, const uint32_t &v2)
It packs two uint32_t numbers to uint64_t data type.