#pragma once #include #include #include #include namespace Unvirt { namespace AccessibleValue { constexpr const char c_InvalidEnumName[] = "[undefined]"; #pragma region universal enum name template using EnumDescPairArray = std::vector>; namespace EnumDesc { extern const EnumDescPairArray CK_FILE_WRITEMODE; extern const EnumDescPairArray CK_LOAD_FLAGS; extern const EnumDescPairArray CK_FO_OPTIONS; extern const EnumDescPairArray CK_PLUGIN_TYPE; } template std::string GetEnumName(const EnumDescPairArray& desc, TEnum val) { std::string strl; for (auto it = desc.begin(); it != desc.end(); ++it) { if ((*it).first == val) { strl = (*it).second; return strl; } } strl = c_InvalidEnumName; return strl; } template std::string GetFlagEnumName(const EnumDescPairArray& desc, TEnum val) { std::string strl; for (auto it = desc.begin(); it != desc.end(); ++it) { // if it have exacelt same entry, return directly if ((*it).first == val) { strl = (*it).second; return strl; } // check flag match if (LibCmo::EnumsHelper::FlagEnumHas(val, (*it).first)) { // matched, add it if (strl.size() != 0u) strl += ", "; strl += (*it).second; } } if (strl.size() == 0u) { // nothing was gotten. set to undefined strl = c_InvalidEnumName; } // otherwise return directly return strl; } #pragma endregion std::string GetClassIdName(LibCmo::CK2::CK_CLASSID cls); std::string GetCkErrorName(LibCmo::CK2::CKERROR err); std::string GetClassIdHierarchy(LibCmo::CK2::CK_CLASSID cls); std::string GetCkErrorDescription(LibCmo::CK2::CKERROR err); std::string GetAccessibleFileSize(uint64_t size); } }