#pragma once #include "data.h" #include #include template inline rettype::type getmapvalue(std::string strvalue, std::map& tmapvalue, T& tValue) { if (strvalue.empty()) { return rettype::except; } std::map::iterator ifindvalue; ifindvalue = tmapvalue.find(strvalue); if (ifindvalue == tmapvalue.end()) { return rettype::except; } try { using F = std::decay_t; if constexpr (std::is_same_v) { tValue = std::stoi(ifindvalue->second); } else if constexpr (std::is_same_v) { tValue = std::stoll(ifindvalue->second); } if constexpr (std::is_same_v) { tValue = std::stoul(ifindvalue->second); } else if constexpr (std::is_same_v) { tValue = std::stoull(ifindvalue->second); } else if constexpr (std::is_same_v) { tValue = ifindvalue->second; } else if constexpr (std::is_same_v) { tValue = std::stod(ifindvalue->second); } return rettype::exist; } catch (std::exception) { return rettype::except; } return rettype::absent; } template inline rettype::type getvaluedata(std::map tmapdata, T& tdata) { rettype::type rettype; boost::pfr::for_each_field(tdata, [&rettype, &tdata, &tmapdata](auto& member, size_t index) { rettype = getmapvalue(tdata.getfieldvalue(index), tmapdata, member); if (rettype != rettype::exist) { rettype = rettype::absent; } }); tdata.getdata(); return rettype; } template inline void Random_Shuffle(T a, T b) { std::random_device rd; std::mt19937 g(rd()); std::shuffle(a, b, g); } inline std::double_t getdouble_t(__int64 itemp) { std::double_t dscore = itemp; dscore = itemp; dscore /= 10000; return dscore; } //±£ΑτΑ½Ξ» inline std::double_t getdouble_t_two(__int64 itemp) { itemp /= 100; itemp *= 100; std::double_t dscore = itemp; dscore = itemp; dscore /= 10000; return dscore; } inline std::string sha256_to_base16(const std::string& input) { unsigned char hash[SHA256_DIGEST_LENGTH]; SHA256_CTX sha256_ctx; SHA256_Init(&sha256_ctx); SHA256_Update(&sha256_ctx, input.c_str(), input.length()); SHA256_Final(hash, &sha256_ctx); std::stringstream oss; for (int i = 0; i < SHA256_DIGEST_LENGTH; ++i) { oss << std::setw(2) << std::setfill('0') << std::hex << (int)hash[i]; } return oss.str(); }