#pragma once #include #include #include #include namespace Unvirt { namespace AccessibleValue { constexpr const char8_t c_InvalidEnumName[] = u8"[undefined]"; #pragma region Size Formatter std::u8string GetReadableFileSize(uint64_t _size); #pragma endregion #pragma region CKERROR CK_CLASSID Data std::u8string GetCkErrorName(LibCmo::CK2::CKERROR err); std::u8string GetCkErrorDescription(LibCmo::CK2::CKERROR err); std::u8string GetClassIdName(LibCmo::CK2::CK_CLASSID cls); std::u8string GetClassIdHierarchy(LibCmo::CK2::CK_CLASSID cls); #pragma endregion #pragma region Other Enums struct GeneralReflection { const char8_t* mName; }; template, int> = 0> using GeneralReflectionArray = std::vector>; template, int> = 0> std::u8string GetEnumName(_Ty val, const GeneralReflectionArray<_Ty>& desc) { std::u8string strl; for (auto& item : desc) { if (item.first == val) { strl = item.second.mName; return strl; } } YYCC::StringHelper::Printf(strl, u8"%s (0x%08" PRIXCKDWORD ")", c_InvalidEnumName, static_cast(val) ); return strl; } template, int> = 0> std::u8string GetFlagEnumName(_Ty val, const GeneralReflectionArray<_Ty>& desc, const char8_t* splitor = u8" ", const char8_t* indent = u8"") { std::u8string strl, cache; for (auto& item : desc) { // if it have exacelt same entry, return directly if (item.first == val) { YYCC::StringHelper::Printf(strl, u8"%s (0x%08" PRIXCKDWORD ")", item.second.mName, static_cast(item.first) ); return strl; } // check flag match if (YYCC::EnumHelper::Has(val, item.first)) { // add splittor if it not the first entry if (strl.size() != 0u && splitor != nullptr) { strl += splitor; } // add indent if possible if (indent != nullptr) { strl += indent; } // add value self. YYCC::StringHelper::Printf(cache, u8"%s (0x%08" PRIXCKDWORD ")", item.second.mName, static_cast(item.first) ); strl += cache; } } // if nothing was gotten. set to undefined if (strl.size() == 0u) { YYCC::StringHelper::Printf(strl, u8"%s (0x%08" PRIXCKDWORD ")", c_InvalidEnumName, static_cast(val) ); } return strl; } namespace EnumDesc { extern const GeneralReflectionArray CK_FILE_WRITEMODE; extern const GeneralReflectionArray CK_FO_OPTIONS; extern const GeneralReflectionArray CK_STATECHUNK_CHUNKOPTIONS; extern const GeneralReflectionArray CK_STATECHUNK_DATAVERSION; extern const GeneralReflectionArray CK_STATECHUNK_CHUNKVERSION; extern const GeneralReflectionArray CK_OBJECT_FLAGS; extern const GeneralReflectionArray CK_3DENTITY_FLAGS; extern const GeneralReflectionArray CK_TEXTURE_SAVEOPTIONS; extern const GeneralReflectionArray CK_BITMAPDATA_FLAGS; extern const GeneralReflectionArray VX_PIXELFORMAT; extern const GeneralReflectionArray VXTEXTURE_BLENDMODE; extern const GeneralReflectionArray VXTEXTURE_FILTERMODE; extern const GeneralReflectionArray VXBLEND_MODE; extern const GeneralReflectionArray VXTEXTURE_ADDRESSMODE; extern const GeneralReflectionArray VXFILL_MODE; extern const GeneralReflectionArray VXSHADE_MODE; extern const GeneralReflectionArray VXCMPFUNC; extern const GeneralReflectionArray VX_EFFECT; extern const GeneralReflectionArray VX_MOVEABLE_FLAGS; extern const GeneralReflectionArray VXMESH_FLAGS; extern const GeneralReflectionArray VXMESH_LITMODE; extern const GeneralReflectionArray VXTEXTURE_WRAPMODE; } #pragma endregion } }