nicehash-api-cpp  0.0.1
throwExceptionIfAlgorithmInvalid.cpp
Go to the documentation of this file.
1 #include <stdexcept>
2 #include <set>
3 
4 #include "../../include/nicehash-api.hpp"
5 
6 
7 /**
8  * \brief Throw an exception if the algorithm id is invalid
9  *
10  * Throw a std::invalid_argument exception if the algorithm id is invalid.
11  * Valid algorithm ids can be found here https://www.nicehash.com/?p=api
12  *
13  */
14 void NiceHashApi::throwExceptionIfAlgorithmInvalid (int algorithm_id) {
15  // Manually declare these algorithm ids (rather than using a loop) because
16  // certain algorithms might be invalidated in the future.
17  const std::set<int> valid_algorithm_ids = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
18  13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
19  23, 24, 25, 26, 27};
20 
21  const bool algorithm_id_is_valid = valid_algorithm_ids.count(algorithm_id);
22 
23  if (!algorithm_id_is_valid)
24  throw std::invalid_argument("Algorithm ID is invalid");
25 }