nicehash-api-cpp  0.0.1
algorithmNameToId.cpp
Go to the documentation of this file.
1 #include <map>
2 #include <algorithm>
3 #include <cctype>
4 #include <iostream>
5 
6 #include "../../include/nicehash-api.hpp"
7 
8 std::string strToUpper(std::string strToConvert);
9 
10 /**
11  * \brief Convert an algorithm name to its id
12  *
13  * See https://www.nicehash.com/?p=api for name->id mappings
14  *
15  */
16 int NiceHashApi::algorithmNameToId(std::string algorithm_name) {
17  std::map<std::string, int> mappings = {
18  {"SCRYPT", 0},
19  {"SHA256", 1},
20  {"SCRYPTNF", 2},
21  {"X11", 3},
22  {"X13", 4},
23  {"KECCAK", 5},
24  {"X15", 6},
25  {"NIST5", 7},
26  {"NEOSCRYPT", 8},
27  {"LYRA2RE", 9},
28  {"WHIRLPOOLX", 10},
29  {"QUBIT", 11},
30  {"QUARK", 12},
31  {"AXIOM", 13},
32  {"LYRA2REV2", 14},
33  {"SCRYPTJANENF16", 15},
34  {"BLAKE256R8", 16},
35  {"BLAKE256R14", 17},
36  {"BLAKE256R8VNL", 18},
37  {"HODL", 19},
38  {"DAGGERHASHIMOTO", 20},
39  {"DECRED", 21},
40  {"CRYPTONIGHT", 22},
41  {"LBRY", 23},
42  {"EQUIHASH", 24},
43  {"PASCAL", 25},
44  {"X11GOST", 26},
45  {"SIA", 27},
46  {"BLAKE2S", 28}
47  };
48 
49  return mappings[strToUpper(algorithm_name)];
50 }
51 
52 std::string strToUpper(std::string strToConvert)
53 {
54  std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::toupper);
55 
56  return strToConvert;
57 }
58 
std::string strToUpper(std::string strToConvert)
int algorithmNameToId(std::string algorithm_name)
Convert an algorithm name to its id.