#pragma once #include #include #include namespace Unvirt { namespace AccessibleValue { constexpr const char c_InvalidEnumName[] = "[undefined]"; struct GeneralReflection { const char* mName; }; template using GeneralReflectionArray = std::vector>; template std::string GetEnumName(_Ty val, const GeneralReflectionArray<_Ty>& desc) { std::string strl; for (auto& item : desc) { if (item.first == val) { strl = item.second.mName; return strl; } } strl = c_InvalidEnumName; return strl; } template std::string GetFlagEnumName(_Ty val, const GeneralReflectionArray<_Ty>& desc) { std::string strl; for (auto& item : desc) { // if it have exacelt same entry, return directly if (item.first == val) { strl = item.second.mName; return strl; } // check flag match if (LibCmo::EnumsHelper::Has(val, item.first)) { if (strl.size() != 0u) strl += ", "; strl += item.second.mName; } } // if nothing was gotten. set to undefined if (strl.size() == 0u) { strl = c_InvalidEnumName; } return strl; } 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 GetReadableFileSize(uint64_t size); namespace EnumDesc { extern const GeneralReflectionArray CK_FILE_WRITEMODE; extern const GeneralReflectionArray CK_LOAD_FLAGS; extern const GeneralReflectionArray CK_FO_OPTIONS; extern const GeneralReflectionArray CK_LOADMODE; extern const GeneralReflectionArray CK_OBJECTCREATION_OPTIONS; extern const GeneralReflectionArray CK_PLUGIN_TYPE; extern const GeneralReflectionArray CK_STATECHUNK_CHUNKOPTIONS; extern const GeneralReflectionArray CK_OBJECT_FLAGS; extern const GeneralReflectionArray CK_STATECHUNK_DATAVERSION; extern const GeneralReflectionArray CK_STATECHUNK_CHUNKVERSION; } } }