Utils#

Useful/repetitive functions.

Functions

template<typename T1, typename T2>
bool check_map_id(std::map<T1, T2> map, T1 id, std::string message, bool halt_execution = true)#

Function for checking if the queried entry of a map exists (map[id]), and throw an error otherwise.

This is used to avoid undefined behaviour in the code and ease debugging.

Template Parameters:
  • T1 – The type of the ID.

  • T2 – The type of the map entry.

Parameters:
  • map – The map we want to verify.

  • id – The ID we want to verify.

  • message – A message containing the function that’s behind this call and the name of the map involved, in that function’s scope. This will be concatenated to the printed output if an error is thrown, like so: std::cout << "Function and map names: " << message << "; ID: " << id << std::endl;

inline std::string check_get_line(std::ifstream &open_file, std::string path)#

Checks if we’ve reached the end of a file we’re working on before we should (this is to be called when reading a specific numebr of lines from a given file). This function will throw runtime errors if so. The path is only used to aid debugging.

Parameters:
  • open_file – The open ifstream file.

  • path – The path (literally will only be used for debugging).