refactor (5/?)

This commit is contained in:
yyc12345 2023-08-26 20:34:51 +08:00
parent 47bf6ab6c6
commit 8a1f71e855
16 changed files with 582 additions and 378 deletions

View File

@ -5,12 +5,8 @@ import java.util.stream.Collectors;
* The nameof values writer for CK_CLASSID. * The nameof values writer for CK_CLASSID.
*/ */
public class ClassidWriter { public class ClassidWriter {
public static void writeNameofClassid(OutputStreamWriter writer, EnumsHelper.Enum_t classids) throws Exception { public static void writeAccVals(OutputStreamWriter writer, EnumsHelper.Enum_t classids) throws Exception {
IndentHelper indent = new IndentHelper(writer); IndentHelper indent = new IndentHelper(writer);
indent.puts("struct CkClassidReflection { std::vector<const char*> mHierarchy; };");
indent.puts(
"using CkClassidReflectionArray = std::vector<std::pair<LibCmo::CK2::CK_CLASSID, CkClassidReflection>>;");
indent.puts("");
indent.puts("const CkClassidReflectionArray CK_CLASSID {"); indent.puts("const CkClassidReflectionArray CK_CLASSID {");
indent.inc(); indent.inc();

View File

@ -4,13 +4,9 @@ import java.io.OutputStreamWriter;
* The nameof values writer for CKERROR * The nameof values writer for CKERROR
*/ */
public class ErrorsWriter { public class ErrorsWriter {
public static void writeNameofError(OutputStreamWriter writer, EnumsHelper.Enum_t errors) throws Exception { public static void writeAccVals(OutputStreamWriter writer, EnumsHelper.Enum_t errors) throws Exception {
IndentHelper indent = new IndentHelper(writer); IndentHelper indent = new IndentHelper(writer);
indent.puts("struct CkErrorReflection { const char* mName; const char* mDescription; };");
indent.puts("using CkErrorReflectionArray = std::vector<std::pair<LibCmo::CK2::CKERROR, CkErrorReflection>>;");
indent.puts("");
indent.puts("const CkErrorReflectionArray CKERROR {"); indent.puts("const CkErrorReflectionArray CKERROR {");
indent.inc(); indent.inc();
for (EnumsHelper.EnumEntry_t entry : errors.mEntries) { for (EnumsHelper.EnumEntry_t entry : errors.mEntries) {

View File

@ -4,6 +4,7 @@ import java.io.OutputStreamWriter;
* Generic Enum Writer. Including Data Type Defination and Nameof Values. * Generic Enum Writer. Including Data Type Defination and Nameof Values.
*/ */
public class GeneralWriter { public class GeneralWriter {
public static void writeEnums(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog) throws Exception { public static void writeEnums(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog) throws Exception {
IndentHelper indent = new IndentHelper(writer); IndentHelper indent = new IndentHelper(writer);
for (EnumsHelper.Enum_t enum_t : prog.mEnums) { for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
@ -31,18 +32,29 @@ public class GeneralWriter {
// write enum tail // write enum tail
indent.dec(); indent.dec();
indent.puts("};"); indent.puts("};");
indent.printf("LIBCMO_BITFLAG_OPERATORS(%s);", enum_t.mEnumName);
} }
} }
public static void writeNameofValues(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog, public static void writeEnum(OutputStreamWriter writer, EnumsHelper.Enum_t _enum) throws Exception {
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
col.mEnums.add(_enum);
writeEnums(writer, col);
}
public static void writeAccVals(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog,
CommonHelper.CKParts parts) throws Exception { CommonHelper.CKParts parts) throws Exception {
IndentHelper indent = new IndentHelper(writer); IndentHelper indent = new IndentHelper(writer);
// write decls
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
indent.printf("extern const GeneralReflectionArray<LibCmo::%s::%s> %s;", CommonHelper.getCKPartsNamespace(parts),
enum_t.mEnumName, enum_t.mEnumName);
}
indent.puts("struct GeneralReflection { const char* mName; };"); indent.puts("");
indent.puts("template<typename _Ty>;"); indent.puts("");
indent.puts("using GeneralReflectionArray = std::vector<std::pair<TEnum, GeneralReflection>>;"); indent.puts("");
// write implements
for (EnumsHelper.Enum_t enum_t : prog.mEnums) { for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
// write enum desc header // write enum desc header
indent.printf("const GeneralReflectionArray<LibCmo::%s::%s> %s {", CommonHelper.getCKPartsNamespace(parts), indent.printf("const GeneralReflectionArray<LibCmo::%s::%s> %s {", CommonHelper.getCKPartsNamespace(parts),
@ -60,4 +72,12 @@ public class GeneralWriter {
indent.puts("};"); indent.puts("};");
} }
} }
public static void writeAccVal(OutputStreamWriter writer, EnumsHelper.Enum_t _enum, CommonHelper.CKParts parts)
throws Exception {
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
col.mEnums.add(_enum);
writeAccVals(writer, col, parts);
}
} }

View File

@ -38,7 +38,7 @@ public class MainRunner {
return result; return result;
} }
private static EnumsHelper.Enum_t organiseClassid(String infile, String assignedEnumName) throws Exception { private static EnumsHelper.Enum_t organiseClassid(String infile) throws Exception {
CommonHelper.InputFilePair pair = CommonHelper.openInputFile(infile); CommonHelper.InputFilePair pair = CommonHelper.openInputFile(infile);
CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream); CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream);
CommonTokenStream tokens = new CommonTokenStream(lexer); CommonTokenStream tokens = new CommonTokenStream(lexer);
@ -52,61 +52,71 @@ public class MainRunner {
pair.mUnderlyingStream.close(); pair.mUnderlyingStream.close();
EnumsHelper.Enum_t result = worker.getEnum(); EnumsHelper.Enum_t result = worker.getEnum();
result.mEnumName = assignedEnumName; result.mEnumName = "CK_CLASSID";
return result; return result;
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
OutputStreamWriter fs = null; OutputStreamWriter fs = null;
// =========== Read Data =========== // =========== CKERROR ===========
// read enum series first.
// these file are originally is enum in Virtools SDK
EnumsHelper.EnumCollection_t ck2Enums = getEnumsCollection("src/CKEnums.txt"),
vxEnums = getEnumsCollection("src/VxEnums.txt"),
def2 = getEnumsCollection("src/Defines2.txt");
// read and reorganize #define type enum
// read CKERROR standalone. because we need treat it specialized.
EnumsHelper.Enum_t ckerror = organiseDefines("src/CKError.txt", "CKERROR"); EnumsHelper.Enum_t ckerror = organiseDefines("src/CKError.txt", "CKERROR");
// read CK_CLASSID standalone in another way. fs = CommonHelper.openOutputFile("dest/CKError.hpp");
EnumsHelper.Enum_t classid = organiseClassid("src/Classid.txt", "CK_CLASSID"); GeneralWriter.writeEnum(fs, ckerror);
// these enum can be directly merge into previous read enum collection
// because we do not need process it independently.
ck2Enums.mEnums.add(organiseDefines("src/CK_STATECHUNK_CHUNKVERSION.txt", "CK_STATECHUNK_CHUNKVERSION"));
ck2Enums.mEnums.add(organiseDefines("src/CK_STATECHUNK_DATAVERSION.txt", "CK_STATECHUNK_DATAVERSION"));
// =========== Write Nameof Values ===========
// write general accessible values
fs = CommonHelper.openOutputFile("dest/CKEnums.NameofValue.hpp");
GeneralWriter.writeNameofValues(fs, ck2Enums, CommonHelper.CKParts.CK2);
fs.close(); fs.close();
fs = CommonHelper.openOutputFile("dest/VxEnums.NameofValue.hpp"); fs = CommonHelper.openOutputFile("dest/CKError.AccVal.hpp");
GeneralWriter.writeNameofValues(fs, vxEnums, CommonHelper.CKParts.VxMath); ErrorsWriter.writeAccVals(fs, ckerror);
fs.close();
// write CKERROR
fs = CommonHelper.openOutputFile("dest/CKError.NameofValue.hpp");
ErrorsWriter.writeNameofError(fs, ckerror);
fs.close();
// write CK_CLASSID
fs = CommonHelper.openOutputFile("dest/CKClassid.NameofValue.hpp");
ClassidWriter.writeNameofClassid(fs, classid);
fs.close(); fs.close();
// write data type defines // =========== CK_CLASSID ===========
// CKERROR and CK_CLASSID should be grouped into ck2Enums EnumsHelper.Enum_t classid = organiseClassid("src/CK_CLASSID.txt");
ck2Enums.mEnums.add(ckerror); fs = CommonHelper.openOutputFile("dest/CK_CLASSID.hpp");
ck2Enums.mEnums.add(classid); GeneralWriter.writeEnum(fs, classid);
fs.close();
fs = CommonHelper.openOutputFile("dest/CK_CLASSID.AccVal.hpp");
ClassidWriter.writeAccVals(fs, classid);
fs.close();
// =========== Define2 ===========
// Define2 do not need values.
EnumsHelper.EnumCollection_t def2 = getEnumsCollection("src/Defines2.txt");
fs = CommonHelper.openOutputFile("dest/CK_CLASSID.hpp");
GeneralWriter.writeEnums(fs, def2);
fs.close();
// =========== Combined enums ===========
EnumsHelper.EnumCollection_t ck2Enums = getEnumsCollection("src/CKEnums.txt"),
vxEnums = getEnumsCollection("src/VxEnums.txt");
fs = CommonHelper.openOutputFile("dest/CKEnums.hpp"); fs = CommonHelper.openOutputFile("dest/CKEnums.hpp");
GeneralWriter.writeEnums(fs, ck2Enums); GeneralWriter.writeEnums(fs, ck2Enums);
fs.close(); fs.close();
fs = CommonHelper.openOutputFile("dest/CKEnums.AccVal.hpp");
GeneralWriter.writeAccVals(fs, ck2Enums, CommonHelper.CKParts.CK2);
fs.close();
fs = CommonHelper.openOutputFile("dest/VxEnums.hpp"); fs = CommonHelper.openOutputFile("dest/VxEnums.hpp");
GeneralWriter.writeEnums(fs, vxEnums); GeneralWriter.writeEnums(fs, vxEnums);
fs.close(); fs.close();
// Defines2.h need independentlt write fs = CommonHelper.openOutputFile("dest/VxEnums.AccVal.hpp");
fs = CommonHelper.openOutputFile("dest/Def2.hpp"); GeneralWriter.writeAccVals(fs, vxEnums, CommonHelper.CKParts.VxMath);
GeneralWriter.writeEnums(fs, def2); fs.close();
// =========== Single enums ===========
EnumsHelper.Enum_t single;
single = organiseDefines("src/CK_STATECHUNK_CHUNKVERSION.txt", "CK_STATECHUNK_CHUNKVERSION");
fs = CommonHelper.openOutputFile("dest/CK_STATECHUNK_CHUNKVERSION.hpp");
GeneralWriter.writeEnum(fs, single);
fs.close();
fs = CommonHelper.openOutputFile("dest/CK_STATECHUNK_CHUNKVERSION.AccVal.hpp");
GeneralWriter.writeAccVal(fs, single, CommonHelper.CKParts.CK2);
fs.close();
single = organiseDefines("src/CK_STATECHUNK_DATAVERSION.txt", "CK_STATECHUNK_DATAVERSION");
fs = CommonHelper.openOutputFile("dest/CK_STATECHUNK_DATAVERSION.hpp");
GeneralWriter.writeEnum(fs, single);
fs.close();
fs = CommonHelper.openOutputFile("dest/CK_STATECHUNK_DATAVERSION.AccVal.hpp");
GeneralWriter.writeAccVal(fs, single, CommonHelper.CKParts.CK2);
fs.close(); fs.close();
// print message. // print message.

View File

@ -55,6 +55,45 @@ typedef enum CK_LOAD_FLAGS {
// and the user choose to keep the existing one. // and the user choose to keep the existing one.
}; };
/*************************************************
{filename:CK_LOADMODE}
Summary: Specify the way an object just loaded should be handled when it already exists in the level.
{secret}
See also:
*************************************************/
typedef enum CK_LOADMODE
{
CKLOAD_INVALID=-1,// Use the existing object instead of loading
CKLOAD_OK=0, // Ignore ( Name unicity is broken )
CKLOAD_REPLACE=1, // Replace the existing object (Not yet implemented)
CKLOAD_RENAME=2, // Rename the loaded object
CKLOAD_USECURRENT=3,// Use the existing object instead of loading
} CK_LOADMODE;
/*************************************************
{filename:CK_OBJECTCREATION_OPTIONS}
Summary: Specify the way an object is created through CKCreateObject.
Remarks:
+ These flag controls the way an object is created, the most important of these flags
being CK_OBJECTCREATION_DYNAMIC which, if set in CKCreateObject, make the newly created object
dynamic.
See also: CKContext::CreateObject,Dynamic Objects
*************************************************/
enum CK_OBJECTCREATION_OPTIONS
{
CK_OBJECTCREATION_NONAMECHECK = 0, // Do not test for name unicity (may be overriden in special case)
CK_OBJECTCREATION_REPLACE = 1, // Replace the current object by the object being loaded
CK_OBJECTCREATION_RENAME = 2, // Rename the created object to ensure its uniqueness
CK_OBJECTCREATION_USECURRENT = 3, // Do not create a new object, use the one with the same name instead
CK_OBJECTCREATION_ASK = 4, // If a duplicate name if found, opens a dialog box to ask the useror use automatic load mode if any.
CK_OBJECTCREATION_FLAGSMASK = 0x0000000F, // Mask for previous values
CK_OBJECTCREATION_DYNAMIC = 0x00000010, // The object must be created dynamic
CK_OBJECTCREATION_ACTIVATE = 0x00000020, // The object will be copied/created active
CK_OBJECTCREATION_NONAMECOPY = 0x00000040 // The object will take control of the string given to it directly, without copying it
};
/************************************************* /*************************************************
{filename:CK_PLUGIN_TYPE} {filename:CK_PLUGIN_TYPE}
Summary: Type identifier for a Virtools plugin. Summary: Type identifier for a Virtools plugin.

View File

@ -168,8 +168,12 @@ namespace LibCmo::CK2 {
CKERROR DeepLoad(CKSTRING u8_filename); CKERROR DeepLoad(CKSTRING u8_filename);
// ========== Loading Result ========== // ========== Loading Result ==========
CKINT GetSaveIdMax();
const XContainer::XArray<CKFileObject>& GetFileObjects(); const XContainer::XArray<CKFileObject>& GetFileObjects();
const XContainer::XArray<CKFileManagerData>& GetManagersData();
const XContainer::XArray<CKFilePluginDependencies>& GetPluginsDep();
const XContainer::XArray<XContainer::XString>& GetIncludedFiles(); const XContainer::XArray<XContainer::XString>& GetIncludedFiles();
const CKFileInfo GetFileInfo();
protected: protected:
CKBOOL m_Done; CKBOOL m_Done;

View File

@ -129,14 +129,30 @@ namespace LibCmo::CK2 {
CKFileReader::~CKFileReader() {} CKFileReader::~CKFileReader() {}
CKINT CKFileReader::GetSaveIdMax() {
return m_SaveIDMax;
}
const XContainer::XArray<CKFileObject>& CKFileReader::GetFileObjects() { const XContainer::XArray<CKFileObject>& CKFileReader::GetFileObjects() {
return m_FileObjects; return m_FileObjects;
} }
const XContainer::XArray<CKFileManagerData>& CKFileReader::GetManagersData() {
return m_ManagersData;
}
const XContainer::XArray<CKFilePluginDependencies>& CKFileReader::GetPluginsDep() {
return m_PluginsDep;
}
const XContainer::XArray<XContainer::XString>& CKFileReader::GetIncludedFiles() { const XContainer::XArray<XContainer::XString>& CKFileReader::GetIncludedFiles() {
return m_IncludedFiles; return m_IncludedFiles;
} }
const CKFileInfo CKFileReader::GetFileInfo() {
return m_FileInfo;
}
#pragma endregion #pragma endregion
#pragma region CKFileWriter #pragma region CKFileWriter

View File

@ -74,7 +74,7 @@ namespace LibCmo {
namespace TypeHelper { namespace TypeHelper {
/** /**
* @brief HybridString is a compatible type. * @brief MKString is a compatible type.
* In some original Virtools case, we need CKSTRING to hold string. * In some original Virtools case, we need CKSTRING to hold string.
* But CKSTRING is just a pointer and it is very cause memory leak. * But CKSTRING is just a pointer and it is very cause memory leak.
* So I invent this. It like CKSTRING but will free memory automatically. * So I invent this. It like CKSTRING but will free memory automatically.

View File

@ -3,63 +3,125 @@
#include <vector> #include <vector>
#include <array> #include <array>
namespace Unvirt { namespace Unvirt::AccessibleValue {
namespace AccessibleValue {
#pragma region universal enum name #pragma region File Formatter
std::string GetReadableFileSize(uint64_t size) {
std::string strl;
static double denominator = (double)0b1111111111;
uint64_t probe = size;
// check bytes
if ((probe >> 10) == UINT64_C(0)) {
StringHelper::StdstringPrintf(strl, "%" PRIu64 "Bytes", probe);
return strl;
}
probe >>= 10;
// check kb
if ((probe >> 10) == UINT64_C(0)) {
StringHelper::StdstringPrintf(strl, "%.2lfKiB", size / static_cast<double>(UINT64_C(1) << 10));
return strl;
}
probe >>= 10;
// check mb
if ((probe >> 10) == UINT64_C(0)) {
StringHelper::StdstringPrintf(strl, "%.2lfMiB", size / static_cast<double>(UINT64_C(1) << 20));
return strl;
}
probe >>= 10;
// otherwise gb
StringHelper::StdstringPrintf(strl, "%.2lfGiB", size / static_cast<double>(UINT64_C(1) << 30));
return strl;
namespace EnumDesc {
const EnumDescPairArray<LibCmo::CK2::CK_FILE_WRITEMODE> CK_FILE_WRITEMODE{
{ LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_UNCOMPRESSED, "CKFILE_UNCOMPRESSED" },
{ LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD, "CKFILE_CHUNKCOMPRESSED_OLD" },
{ LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_EXTERNALTEXTURES_OLD, "CKFILE_EXTERNALTEXTURES_OLD" },
{ LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_FORVIEWER, "CKFILE_FORVIEWER" },
{ LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED, "CKFILE_WHOLECOMPRESSED" }
};
const EnumDescPairArray<LibCmo::CK2::CK_LOAD_FLAGS> CK_LOAD_FLAGS{
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_ANIMATION, "CK_LOAD_ANIMATION" },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_GEOMETRY, "CK_LOAD_GEOMETRY" },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_DEFAULT, "CK_LOAD_DEFAULT" },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_ASCHARACTER, "CK_LOAD_ASCHARACTER" },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_DODIALOG, "CK_LOAD_DODIALOG" },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_AS_DYNAMIC_OBJECT, "CK_LOAD_AS_DYNAMIC_OBJECT" },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_AUTOMATICMODE, "CK_LOAD_AUTOMATICMODE" },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_CHECKDUPLICATES, "CK_LOAD_CHECKDUPLICATES" },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_CHECKDEPENDENCIES, "CK_LOAD_CHECKDEPENDENCIES" },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_ONLYBEHAVIORS, "CK_LOAD_ONLYBEHAVIORS" }
};
const EnumDescPairArray<LibCmo::CK2::CK_FO_OPTIONS> CK_FO_OPTIONS{
{ LibCmo::CK2::CK_FO_OPTIONS::CK_FO_DEFAULT, "CK_FO_DEFAULT" },
{ LibCmo::CK2::CK_FO_OPTIONS::CK_FO_RENAMEOBJECT, "CK_FO_RENAMEOBJECT" },
{ LibCmo::CK2::CK_FO_OPTIONS::CK_FO_REPLACEOBJECT, "CK_FO_REPLACEOBJECT" },
{ LibCmo::CK2::CK_FO_OPTIONS::CK_FO_DONTLOADOBJECT, "CK_FO_DONTLOADOBJECT" }
};
const EnumDescPairArray<LibCmo::CK2::CK_PLUGIN_TYPE> CK_PLUGIN_TYPE{
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_BITMAP_READER, "CKPLUGIN_BITMAP_READER" },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_SOUND_READER, "CKPLUGIN_SOUND_READER" },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_MODEL_READER, "CKPLUGIN_MODEL_READER" },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_MANAGER_DLL, "CKPLUGIN_MANAGER_DLL" },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_BEHAVIOR_DLL, "CKPLUGIN_BEHAVIOR_DLL" },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_RENDERENGINE_DLL, "CKPLUGIN_RENDERENGINE_DLL" },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_MOVIE_READER, "CKPLUGIN_MOVIE_READER" },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_EXTENSION_DLL, "CKPLUGIN_EXTENSION_DLL" }
};
} }
#pragma endregion #pragma endregion
#pragma region class id and ck error #pragma region CKERROR CK_CLASSID Data
template<typename TKey, typename TValue> struct CkClassidReflection { std::vector<const char*> mHierarchy; };
static inline const TValue* GetEnumData(const std::vector<std::pair<TKey, TValue>>& vec, const TKey key) { using CkClassidReflectionArray = std::vector<std::pair<LibCmo::CK2::CK_CLASSID, CkClassidReflection>>;
size_t len = vec.size();
for (size_t i = 0; i < len; ++i) {
if (key == vec[i].first) return &vec[i].second;
}
return nullptr;
}
static const std::vector<std::pair<LibCmo::CK2::CKERROR, std::array<const char*, 2>>> _CkErrorData{ struct CkErrorReflection { const char* mName; const char* mDescription; };
using CkErrorReflectionArray = std::vector<std::pair<LibCmo::CK2::CKERROR, CkErrorReflection>>;
namespace EnumDesc {
const CkClassidReflectionArray CK_CLASSID {
{ LibCmo::CK2::CK_CLASSID::CKCID_OBJECT, { { "CKCID_OBJECT" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETERIN, { { "CKCID_OBJECT", "CKCID_PARAMETERIN" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETEROPERATION, { { "CKCID_OBJECT", "CKCID_PARAMETEROPERATION" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_STATE, { { "CKCID_OBJECT", "CKCID_STATE" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIORLINK, { { "CKCID_OBJECT", "CKCID_BEHAVIORLINK" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIOR, { { "CKCID_OBJECT", "CKCID_BEHAVIOR" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIORIO, { { "CKCID_OBJECT", "CKCID_BEHAVIORIO" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_RENDERCONTEXT, { { "CKCID_OBJECT", "CKCID_RENDERCONTEXT" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_KINEMATICCHAIN, { { "CKCID_OBJECT", "CKCID_KINEMATICCHAIN" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_SCENEOBJECT, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_OBJECTANIMATION, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_OBJECTANIMATION" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_ANIMATION, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_ANIMATION" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_KEYEDANIMATION, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_ANIMATION", "CKCID_KEYEDANIMATION" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_BEOBJECT, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_DATAARRAY, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_DATAARRAY" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_SCENE, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SCENE" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_LEVEL, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_LEVEL" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_PLACE, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_PLACE" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_GROUP, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_GROUP" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_SOUND, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_WAVESOUND, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND", "CKCID_WAVESOUND" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_MIDISOUND, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND", "CKCID_MIDISOUND" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MATERIAL" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_TEXTURE" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_MESH, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MESH" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_PATCHMESH, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MESH", "CKCID_PATCHMESH" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_RENDEROBJECT, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_2DENTITY, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_SPRITE, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY", "CKCID_SPRITE" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_SPRITETEXT, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY", "CKCID_SPRITETEXT" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_3DENTITY, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_GRID, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_GRID" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_CURVEPOINT, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CURVEPOINT" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_SPRITE3D, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_SPRITE3D" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_CURVE, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CURVE" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_CAMERA, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CAMERA" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_TARGETCAMERA, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CAMERA", "CKCID_TARGETCAMERA" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_LIGHT, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_LIGHT" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_TARGETLIGHT, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_LIGHT", "CKCID_TARGETLIGHT" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_CHARACTER, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CHARACTER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_3DOBJECT" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_BODYPART, { { "CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_3DOBJECT", "CKCID_BODYPART" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETER, { { "CKCID_OBJECT", "CKCID_PARAMETER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETERLOCAL, { { "CKCID_OBJECT", "CKCID_PARAMETER", "CKCID_PARAMETERLOCAL" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETEROUT, { { "CKCID_OBJECT", "CKCID_PARAMETER", "CKCID_PARAMETEROUT" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_INTERFACEOBJECTMANAGER, { { "CKCID_OBJECT", "CKCID_INTERFACEOBJECTMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_CRITICALSECTION, { { "CKCID_OBJECT", "CKCID_CRITICALSECTION" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_LAYER, { { "CKCID_OBJECT", "CKCID_LAYER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_PROGRESSIVEMESH, { { "CKCID_OBJECT", "CKCID_PROGRESSIVEMESH" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_SYNCHRO, { { "CKCID_OBJECT", "CKCID_SYNCHRO" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_OBJECTARRAY, { { "CKCID_OBJECTARRAY" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_SCENEOBJECTDESC, { { "CKCID_SCENEOBJECTDESC" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_ATTRIBUTEMANAGER, { { "CKCID_ATTRIBUTEMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_MESSAGEMANAGER, { { "CKCID_MESSAGEMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_COLLISIONMANAGER, { { "CKCID_COLLISIONMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_OBJECTMANAGER, { { "CKCID_OBJECTMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_FLOORMANAGER, { { "CKCID_FLOORMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_RENDERMANAGER, { { "CKCID_RENDERMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIORMANAGER, { { "CKCID_BEHAVIORMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_INPUTMANAGER, { { "CKCID_INPUTMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETERMANAGER, { { "CKCID_PARAMETERMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_GRIDMANAGER, { { "CKCID_GRIDMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_SOUNDMANAGER, { { "CKCID_SOUNDMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_TIMEMANAGER, { { "CKCID_TIMEMANAGER" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_CUIKBEHDATA, { { "CKCID_CUIKBEHDATA" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_MAXCLASSID, { { "CKCID_MAXCLASSID" } } },
{ LibCmo::CK2::CK_CLASSID::CKCID_MAXMAXCLASSID, { { "CKCID_MAXMAXCLASSID" } } },
};
const CkErrorReflectionArray CKERROR {
{ LibCmo::CK2::CKERROR::CKERR_OK, { "CKERR_OK", "Operation successful " } }, { LibCmo::CK2::CKERROR::CKERR_OK, { "CKERR_OK", "Operation successful " } },
{ LibCmo::CK2::CKERROR::CKERR_INVALIDPARAMETER, { "CKERR_INVALIDPARAMETER", "One of the parameter passed to the function was invalid " } }, { LibCmo::CK2::CKERROR::CKERR_INVALIDPARAMETER, { "CKERR_INVALIDPARAMETER", "One of the parameter passed to the function was invalid " } },
{ LibCmo::CK2::CKERROR::CKERR_INVALIDPARAMETERTYPE, { "CKERR_INVALIDPARAMETERTYPE", "One of the parameter passed to the function was invalid " } }, { LibCmo::CK2::CKERROR::CKERR_INVALIDPARAMETERTYPE, { "CKERR_INVALIDPARAMETERTYPE", "One of the parameter passed to the function was invalid " } },
@ -110,173 +172,193 @@ namespace Unvirt {
{ LibCmo::CK2::CKERROR::CKERR_CANCELLED, { "CKERR_CANCELLED", "Operation was cancelled by user " } }, { LibCmo::CK2::CKERROR::CKERR_CANCELLED, { "CKERR_CANCELLED", "Operation was cancelled by user " } },
{ LibCmo::CK2::CKERROR::CKERR_NOANIMATIONKEY, { "CKERR_NOANIMATIONKEY", "there were no animation key at the given index " } }, { LibCmo::CK2::CKERROR::CKERR_NOANIMATIONKEY, { "CKERR_NOANIMATIONKEY", "there were no animation key at the given index " } },
{ LibCmo::CK2::CKERROR::CKERR_INVALIDINDEX, { "CKERR_INVALIDINDEX", "attemp to acces an animation key with an invalid index " } }, { LibCmo::CK2::CKERROR::CKERR_INVALIDINDEX, { "CKERR_INVALIDINDEX", "attemp to acces an animation key with an invalid index " } },
{ LibCmo::CK2::CKERROR::CKERR_INVALIDANIMATION, {"CKERR_INVALIDANIMATION", "the animation is invalid (no entity associated or zero length)"} } { LibCmo::CK2::CKERROR::CKERR_INVALIDANIMATION, { "CKERR_INVALIDANIMATION", "the animation is invalid (no entity associated or zero length) " } },
}; };
std::string GetCkErrorName(LibCmo::CK2::CKERROR err) {
std::string strl;
const std::array<const char*, 2>* pErrDesc = GetEnumData<LibCmo::CK2::CKERROR, std::array<const char*, 2>>(
_CkErrorData, err
);
if (pErrDesc != nullptr) {
strl = pErrDesc->front();
} else {
strl = c_InvalidEnumName;
} }
return strl;
#pragma endregion
#pragma region CKERROR CK_CLASSID Process
static const CkErrorReflection* GetCkError(LibCmo::CK2::CKERROR err) {
for (auto& item : EnumDesc::CKERROR) {
if (item.first == err) {
return &item.second;
}
}
return nullptr;
}
std::string GetCkErrorName(LibCmo::CK2::CKERROR err) {
const CkErrorReflection* node = GetCkError(err);
if (node != nullptr) return node->mName;
else return c_InvalidEnumName;
} }
std::string GetCkErrorDescription(LibCmo::CK2::CKERROR err) { std::string GetCkErrorDescription(LibCmo::CK2::CKERROR err) {
std::string strl; const CkErrorReflection* node = GetCkError(err);
const std::array<const char*, 2>* pErrDesc = GetEnumData<LibCmo::CK2::CKERROR, std::array<const char*, 2>>( if (node != nullptr) return node->mDescription;
_CkErrorData, err else return c_InvalidEnumName;
);
if (pErrDesc != nullptr) {
strl = pErrDesc->back();
} else {
strl = c_InvalidEnumName;
}
return strl;
} }
static const std::vector<std::pair<LibCmo::CK2::CK_CLASSID, std::vector<const char*>>> _CkClassHierarchy{ static const CkClassidReflection* GetCkClassid(LibCmo::CK2::CK_CLASSID cls) {
{ LibCmo::CK2::CK_CLASSID::CKCID_OBJECT, {"CKCID_OBJECT"} }, for (auto& item : EnumDesc::CK_CLASSID) {
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETERIN, {"CKCID_OBJECT", "CKCID_PARAMETERIN"} }, if (item.first == cls) {
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETEROPERATION, {"CKCID_OBJECT", "CKCID_PARAMETEROPERATION"} }, return &item.second;
{ LibCmo::CK2::CK_CLASSID::CKCID_STATE, {"CKCID_OBJECT", "CKCID_STATE"} }, }
{ LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIORLINK, {"CKCID_OBJECT", "CKCID_BEHAVIORLINK"} }, }
{ LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIOR, {"CKCID_OBJECT", "CKCID_BEHAVIOR"} }, return nullptr;
{ LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIORIO, {"CKCID_OBJECT", "CKCID_BEHAVIORIO"} }, }
{ LibCmo::CK2::CK_CLASSID::CKCID_RENDERCONTEXT, {"CKCID_OBJECT", "CKCID_RENDERCONTEXT"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_KINEMATICCHAIN, {"CKCID_OBJECT", "CKCID_KINEMATICCHAIN"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_SCENEOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_OBJECTANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_OBJECTANIMATION"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_ANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_ANIMATION"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_KEYEDANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_ANIMATION", "CKCID_KEYEDANIMATION"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_BEOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_DATAARRAY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_DATAARRAY"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_SCENE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SCENE"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_LEVEL, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_LEVEL"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_PLACE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_PLACE"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_GROUP, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_GROUP"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_SOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_WAVESOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND", "CKCID_WAVESOUND"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_MIDISOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND", "CKCID_MIDISOUND"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MATERIAL"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_TEXTURE"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_MESH, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MESH"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_PATCHMESH, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MESH", "CKCID_PATCHMESH"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_RENDEROBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_2DENTITY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_SPRITE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY", "CKCID_SPRITE"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_SPRITETEXT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY", "CKCID_SPRITETEXT"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_3DENTITY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_GRID, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_GRID"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_CURVEPOINT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CURVEPOINT"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_SPRITE3D, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_SPRITE3D"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_CURVE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CURVE"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_CAMERA, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CAMERA"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_TARGETCAMERA, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CAMERA", "CKCID_TARGETCAMERA"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_LIGHT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_LIGHT"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_TARGETLIGHT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_LIGHT", "CKCID_TARGETLIGHT"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_CHARACTER, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CHARACTER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_3DOBJECT"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_BODYPART, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_3DOBJECT", "CKCID_BODYPART"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETER, {"CKCID_OBJECT", "CKCID_PARAMETER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETERLOCAL, {"CKCID_OBJECT", "CKCID_PARAMETER", "CKCID_PARAMETERLOCAL"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETEROUT, {"CKCID_OBJECT", "CKCID_PARAMETER", "CKCID_PARAMETEROUT"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_INTERFACEOBJECTMANAGER, {"CKCID_OBJECT", "CKCID_INTERFACEOBJECTMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_CRITICALSECTION, {"CKCID_OBJECT", "CKCID_CRITICALSECTION"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_LAYER, {"CKCID_OBJECT", "CKCID_LAYER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_PROGRESSIVEMESH, {"CKCID_OBJECT", "CKCID_PROGRESSIVEMESH"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_SYNCHRO, {"CKCID_OBJECT", "CKCID_SYNCHRO"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_OBJECTARRAY, {"CKCID_OBJECTARRAY"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_SCENEOBJECTDESC, {"CKCID_SCENEOBJECTDESC"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_ATTRIBUTEMANAGER, {"CKCID_ATTRIBUTEMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_MESSAGEMANAGER, {"CKCID_MESSAGEMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_COLLISIONMANAGER, {"CKCID_COLLISIONMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_OBJECTMANAGER, {"CKCID_OBJECTMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_FLOORMANAGER, {"CKCID_FLOORMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_RENDERMANAGER, {"CKCID_RENDERMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIORMANAGER, {"CKCID_BEHAVIORMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_INPUTMANAGER, {"CKCID_INPUTMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_PARAMETERMANAGER, {"CKCID_PARAMETERMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_GRIDMANAGER, {"CKCID_GRIDMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_SOUNDMANAGER, {"CKCID_SOUNDMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_TIMEMANAGER, {"CKCID_TIMEMANAGER"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_CUIKBEHDATA, {"CKCID_CUIKBEHDATA"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_MAXCLASSID, {"CKCID_MAXCLASSID"} },
{ LibCmo::CK2::CK_CLASSID::CKCID_MAXMAXCLASSID, {"CKCID_MAXMAXCLASSID"} }
};
std::string GetClassIdName(LibCmo::CK2::CK_CLASSID cls) { std::string GetClassIdName(LibCmo::CK2::CK_CLASSID cls) {
std::string strl; const CkClassidReflection* node = GetCkClassid(cls);
const std::vector<const char*>* pHierarchy = GetEnumData<LibCmo::CK2::CK_CLASSID, std::vector<const char*>>( if (node == nullptr) return c_InvalidEnumName;
_CkClassHierarchy, cls else return node->mHierarchy.back();
);
if (pHierarchy != nullptr) {
strl = pHierarchy->back();
} else {
strl = c_InvalidEnumName;
}
return strl;
} }
std::string GetClassIdHierarchy(LibCmo::CK2::CK_CLASSID cls) { std::string GetClassIdHierarchy(LibCmo::CK2::CK_CLASSID cls) {
const CkClassidReflection* node = GetCkClassid(cls);
if (node == nullptr) return c_InvalidEnumName;
std::string strl; std::string strl;
const std::vector<const char*>* pHierarchy = GetEnumData<LibCmo::CK2::CK_CLASSID, std::vector<const char*>>( for (auto& hierarchy_node : node->mHierarchy) {
_CkClassHierarchy, cls if (!strl.empty()) strl += " -> ";
); strl += hierarchy_node;
if (pHierarchy != nullptr) {
strl.clear();
for (auto it = pHierarchy->begin(); it != pHierarchy->end(); ++it) {
if (it != pHierarchy->begin()) strl += " -> ";
strl += (*it);
} }
} else {
strl = c_InvalidEnumName;
}
return strl; return strl;
} }
#pragma endregion #pragma endregion
std::string GetAccessibleFileSize(uint64_t size) { #pragma region Other Enums
std::string strl;
static double denominator = (double)0b1111111111;
uint64_t probe = size;
// check bytes namespace EnumDesc {
if ((probe >> 10) == UINT64_C(0)) {
StringHelper::StdstringPrintf(strl, "%" PRIu64 "Bytes", probe);
return strl;
}
probe >>= 10;
// check kb const GeneralReflectionArray<LibCmo::CK2::CK_FILE_WRITEMODE> CK_FILE_WRITEMODE {
if ((probe >> 10) == UINT64_C(0)) { { LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_UNCOMPRESSED, {"CKFILE_UNCOMPRESSED"} },
StringHelper::StdstringPrintf(strl, "%.2lfKiB", size / static_cast<double>(UINT64_C(1) << 10)); { LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD, {"CKFILE_CHUNKCOMPRESSED_OLD"} },
return strl; { LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_EXTERNALTEXTURES_OLD, {"CKFILE_EXTERNALTEXTURES_OLD"} },
} { LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_FORVIEWER, {"CKFILE_FORVIEWER"} },
probe >>= 10; { LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED, {"CKFILE_WHOLECOMPRESSED"} },
};
const GeneralReflectionArray<LibCmo::CK2::CK_LOAD_FLAGS> CK_LOAD_FLAGS {
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_ANIMATION, {"CK_LOAD_ANIMATION"} },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_GEOMETRY, {"CK_LOAD_GEOMETRY"} },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_DEFAULT, {"CK_LOAD_DEFAULT"} },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_ASCHARACTER, {"CK_LOAD_ASCHARACTER"} },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_DODIALOG, {"CK_LOAD_DODIALOG"} },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_AS_DYNAMIC_OBJECT, {"CK_LOAD_AS_DYNAMIC_OBJECT"} },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_AUTOMATICMODE, {"CK_LOAD_AUTOMATICMODE"} },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_CHECKDUPLICATES, {"CK_LOAD_CHECKDUPLICATES"} },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_CHECKDEPENDENCIES, {"CK_LOAD_CHECKDEPENDENCIES"} },
{ LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_ONLYBEHAVIORS, {"CK_LOAD_ONLYBEHAVIORS"} },
};
const GeneralReflectionArray<LibCmo::CK2::CK_FO_OPTIONS> CK_FO_OPTIONS {
{ LibCmo::CK2::CK_FO_OPTIONS::CK_FO_DEFAULT, {"CK_FO_DEFAULT"} },
{ LibCmo::CK2::CK_FO_OPTIONS::CK_FO_RENAMEOBJECT, {"CK_FO_RENAMEOBJECT"} },
{ LibCmo::CK2::CK_FO_OPTIONS::CK_FO_REPLACEOBJECT, {"CK_FO_REPLACEOBJECT"} },
{ LibCmo::CK2::CK_FO_OPTIONS::CK_FO_DONTLOADOBJECT, {"CK_FO_DONTLOADOBJECT"} },
};
const GeneralReflectionArray<LibCmo::CK2::CK_LOADMODE> CK_LOADMODE {
{ LibCmo::CK2::CK_LOADMODE::CKLOAD_INVALID, {"CKLOAD_INVALID"} },
{ LibCmo::CK2::CK_LOADMODE::CKLOAD_OK, {"CKLOAD_OK"} },
{ LibCmo::CK2::CK_LOADMODE::CKLOAD_REPLACE, {"CKLOAD_REPLACE"} },
{ LibCmo::CK2::CK_LOADMODE::CKLOAD_RENAME, {"CKLOAD_RENAME"} },
{ LibCmo::CK2::CK_LOADMODE::CKLOAD_USECURRENT, {"CKLOAD_USECURRENT"} },
};
const GeneralReflectionArray<LibCmo::CK2::CK_OBJECTCREATION_OPTIONS> CK_OBJECTCREATION_OPTIONS {
{ LibCmo::CK2::CK_OBJECTCREATION_OPTIONS::CK_OBJECTCREATION_NONAMECHECK, {"CK_OBJECTCREATION_NONAMECHECK"} },
{ LibCmo::CK2::CK_OBJECTCREATION_OPTIONS::CK_OBJECTCREATION_REPLACE, {"CK_OBJECTCREATION_REPLACE"} },
{ LibCmo::CK2::CK_OBJECTCREATION_OPTIONS::CK_OBJECTCREATION_RENAME, {"CK_OBJECTCREATION_RENAME"} },
{ LibCmo::CK2::CK_OBJECTCREATION_OPTIONS::CK_OBJECTCREATION_USECURRENT, {"CK_OBJECTCREATION_USECURRENT"} },
{ LibCmo::CK2::CK_OBJECTCREATION_OPTIONS::CK_OBJECTCREATION_ASK, {"CK_OBJECTCREATION_ASK"} },
{ LibCmo::CK2::CK_OBJECTCREATION_OPTIONS::CK_OBJECTCREATION_FLAGSMASK, {"CK_OBJECTCREATION_FLAGSMASK"} },
{ LibCmo::CK2::CK_OBJECTCREATION_OPTIONS::CK_OBJECTCREATION_DYNAMIC, {"CK_OBJECTCREATION_DYNAMIC"} },
{ LibCmo::CK2::CK_OBJECTCREATION_OPTIONS::CK_OBJECTCREATION_ACTIVATE, {"CK_OBJECTCREATION_ACTIVATE"} },
{ LibCmo::CK2::CK_OBJECTCREATION_OPTIONS::CK_OBJECTCREATION_NONAMECOPY, {"CK_OBJECTCREATION_NONAMECOPY"} },
};
const GeneralReflectionArray<LibCmo::CK2::CK_PLUGIN_TYPE> CK_PLUGIN_TYPE {
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_BITMAP_READER, {"CKPLUGIN_BITMAP_READER"} },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_SOUND_READER, {"CKPLUGIN_SOUND_READER"} },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_MODEL_READER, {"CKPLUGIN_MODEL_READER"} },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_MANAGER_DLL, {"CKPLUGIN_MANAGER_DLL"} },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_BEHAVIOR_DLL, {"CKPLUGIN_BEHAVIOR_DLL"} },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_RENDERENGINE_DLL, {"CKPLUGIN_RENDERENGINE_DLL"} },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_MOVIE_READER, {"CKPLUGIN_MOVIE_READER"} },
{ LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_EXTENSION_DLL, {"CKPLUGIN_EXTENSION_DLL"} },
};
const GeneralReflectionArray<LibCmo::CK2::CK_STATECHUNK_CHUNKOPTIONS> CK_STATECHUNK_CHUNKOPTIONS {
{ LibCmo::CK2::CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS, {"CHNK_OPTION_IDS"} },
{ LibCmo::CK2::CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN, {"CHNK_OPTION_MAN"} },
{ LibCmo::CK2::CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN, {"CHNK_OPTION_CHN"} },
{ LibCmo::CK2::CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_FILE, {"CHNK_OPTION_FILE"} },
{ LibCmo::CK2::CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_ALLOWDYN, {"CHNK_OPTION_ALLOWDYN"} },
{ LibCmo::CK2::CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_LISTBIG, {"CHNK_OPTION_LISTBIG"} },
{ LibCmo::CK2::CK_STATECHUNK_CHUNKOPTIONS::CHNK_DONTDELETE_PTR, {"CHNK_DONTDELETE_PTR"} },
{ LibCmo::CK2::CK_STATECHUNK_CHUNKOPTIONS::CHNK_DONTDELETE_PARSER, {"CHNK_DONTDELETE_PARSER"} },
};
const GeneralReflectionArray<LibCmo::CK2::CK_OBJECT_FLAGS> CK_OBJECT_FLAGS {
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_INTERFACEOBJ, {"CK_OBJECT_INTERFACEOBJ"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_PRIVATE, {"CK_OBJECT_PRIVATE"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_INTERFACEMARK, {"CK_OBJECT_INTERFACEMARK"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_FREEID, {"CK_OBJECT_FREEID"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_TOBEDELETED, {"CK_OBJECT_TOBEDELETED"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_NOTTOBESAVED, {"CK_OBJECT_NOTTOBESAVED"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE, {"CK_OBJECT_VISIBLE"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_NAMESHARED, {"CK_OBJECT_NAMESHARED"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_DYNAMIC, {"CK_OBJECT_DYNAMIC"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE, {"CK_OBJECT_HIERACHICALHIDE"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_UPTODATE, {"CK_OBJECT_UPTODATE"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_TEMPMARKER, {"CK_OBJECT_TEMPMARKER"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_ONLYFORFILEREFERENCE, {"CK_OBJECT_ONLYFORFILEREFERENCE"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_NOTTOBEDELETED, {"CK_OBJECT_NOTTOBEDELETED"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_APPDATA, {"CK_OBJECT_APPDATA"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_SINGLEACTIVITY, {"CK_OBJECT_SINGLEACTIVITY"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_LOADSKIPBEOBJECT, {"CK_OBJECT_LOADSKIPBEOBJECT"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_NOTTOBELISTEDANDSAVED, {"CK_OBJECT_NOTTOBELISTEDANDSAVED"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETEROUT_SETTINGS, {"CK_PARAMETEROUT_SETTINGS"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETEROUT_PARAMOP, {"CK_PARAMETEROUT_PARAMOP"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETERIN_DISABLED, {"CK_PARAMETERIN_DISABLED"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETERIN_THIS, {"CK_PARAMETERIN_THIS"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETERIN_SHARED, {"CK_PARAMETERIN_SHARED"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETEROUT_DELETEAFTERUSE, {"CK_PARAMETEROUT_DELETEAFTERUSE"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_PARAMMASK, {"CK_OBJECT_PARAMMASK"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_BEHAVIORIO_IN, {"CK_BEHAVIORIO_IN"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_BEHAVIORIO_OUT, {"CK_BEHAVIORIO_OUT"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_BEHAVIORIO_ACTIVE, {"CK_BEHAVIORIO_ACTIVE"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_IOTYPEMASK, {"CK_OBJECT_IOTYPEMASK"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_IOMASK, {"CK_OBJECT_IOMASK"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CKBEHAVIORLINK_RESERVED, {"CKBEHAVIORLINK_RESERVED"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CKBEHAVIORLINK_ACTIVATEDLASTFRAME, {"CKBEHAVIORLINK_ACTIVATEDLASTFRAME"} },
{ LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_BEHAVIORLINKMASK, {"CK_OBJECT_BEHAVIORLINKMASK"} },
};
// check mb const GeneralReflectionArray<LibCmo::CK2::CK_STATECHUNK_DATAVERSION> CK_STATECHUNK_DATAVERSION {
if ((probe >> 10) == UINT64_C(0)) { { LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNKDATA_OLDVERSION, {"CHUNKDATA_OLDVERSION"} },
StringHelper::StdstringPrintf(strl, "%.2lfMiB", size / static_cast<double>(UINT64_C(1) << 20)); { LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNKDATA_BASEVERSION, {"CHUNKDATA_BASEVERSION"} },
return strl; { LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNK_WAVESOUND_VERSION2, {"CHUNK_WAVESOUND_VERSION2"} },
} { LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNK_WAVESOUND_VERSION3, {"CHUNK_WAVESOUND_VERSION3"} },
probe >>= 10; { LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNK_MATERIAL_VERSION_ZTEST, {"CHUNK_MATERIAL_VERSION_ZTEST"} },
{ LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNK_MAJORCHANGE_VERSION, {"CHUNK_MAJORCHANGE_VERSION"} },
{ LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNK_MACCHANGE_VERSION, {"CHUNK_MACCHANGE_VERSION"} },
{ LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNK_WAVESOUND_VERSION4, {"CHUNK_WAVESOUND_VERSION4"} },
{ LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNK_SCENECHANGE_VERSION, {"CHUNK_SCENECHANGE_VERSION"} },
{ LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNK_MESHCHANGE_VERSION, {"CHUNK_MESHCHANGE_VERSION"} },
{ LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNK_DEV_2_1, {"CHUNK_DEV_2_1"} },
{ LibCmo::CK2::CK_STATECHUNK_DATAVERSION::CHUNKDATA_CURRENTVERSION, {"CHUNKDATA_CURRENTVERSION"} },
};
// otherwise gb const GeneralReflectionArray<LibCmo::CK2::CK_STATECHUNK_CHUNKVERSION> CK_STATECHUNK_CHUNKVERSION {
StringHelper::StdstringPrintf(strl, "%.2lfGiB", size / static_cast<double>(UINT64_C(1) << 30)); { LibCmo::CK2::CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSIONBASE, {"CHUNK_VERSIONBASE"} },
return strl; { LibCmo::CK2::CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION1, {"CHUNK_VERSION1"} },
{ LibCmo::CK2::CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION2, {"CHUNK_VERSION2"} },
{ LibCmo::CK2::CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION3, {"CHUNK_VERSION3"} },
{ LibCmo::CK2::CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION4, {"CHUNK_VERSION4"} },
};
} }
} #pragma endregion
} }

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include <CKEnums.hpp> #include <VTAll.hpp>
#include <VTUtils.hpp>
#include <vector> #include <vector>
#include <string> #include <string>
@ -10,63 +9,68 @@ namespace Unvirt {
constexpr const char c_InvalidEnumName[] = "[undefined]"; constexpr const char c_InvalidEnumName[] = "[undefined]";
#pragma region universal enum name struct GeneralReflection { const char* mName; };
template<typename _Ty>
using GeneralReflectionArray = std::vector<std::pair<_Ty, GeneralReflection>>;
template<typename TEnum> template<typename _Ty>
using EnumDescPairArray = std::vector<std::pair<TEnum, const char*>>; std::string GetEnumName(_Ty val, const GeneralReflectionArray<_Ty>& desc) {
namespace EnumDesc {
extern const EnumDescPairArray<LibCmo::CK2::CK_FILE_WRITEMODE> CK_FILE_WRITEMODE;
extern const EnumDescPairArray<LibCmo::CK2::CK_LOAD_FLAGS> CK_LOAD_FLAGS;
extern const EnumDescPairArray<LibCmo::CK2::CK_FO_OPTIONS> CK_FO_OPTIONS;
extern const EnumDescPairArray<LibCmo::CK2::CK_PLUGIN_TYPE> CK_PLUGIN_TYPE;
}
template<typename TEnum>
std::string GetEnumName(const EnumDescPairArray<TEnum>& desc, TEnum val) {
std::string strl; std::string strl;
for (auto it = desc.begin(); it != desc.end(); ++it) { for (auto& item : desc) {
if ((*it).first == val) { if (item.first == val) {
strl = (*it).second; strl = item.second.mName;
return strl; return strl;
} }
} }
strl = c_InvalidEnumName; strl = c_InvalidEnumName;
return strl; return strl;
} }
template<typename TEnum> template<typename _Ty>
std::string GetFlagEnumName(const EnumDescPairArray<TEnum>& desc, TEnum val) { std::string GetFlagEnumName(_Ty val, const GeneralReflectionArray<_Ty>& desc) {
std::string strl; std::string strl;
for (auto it = desc.begin(); it != desc.end(); ++it) { for (auto& item : desc) {
// if it have exacelt same entry, return directly // if it have exacelt same entry, return directly
if ((*it).first == val) { if (item.first == val) {
strl = (*it).second; strl = item.second.mName;
return strl; return strl;
} }
// check flag match // check flag match
if (LibCmo::EnumsHelper::FlagEnumHas(val, (*it).first)) { if (LibCmo::EnumsHelper::Has(val, item.first)) {
// matched, add it
if (strl.size() != 0u) strl += ", "; if (strl.size() != 0u) strl += ", ";
strl += (*it).second; strl += item.second.mName;
} }
} }
// if nothing was gotten. set to undefined
if (strl.size() == 0u) { if (strl.size() == 0u) {
// nothing was gotten. set to undefined
strl = c_InvalidEnumName; strl = c_InvalidEnumName;
} // otherwise return directly }
return strl; return strl;
} }
#pragma endregion
std::string GetClassIdName(LibCmo::CK2::CK_CLASSID cls); std::string GetClassIdName(LibCmo::CK2::CK_CLASSID cls);
std::string GetCkErrorName(LibCmo::CK2::CKERROR err); std::string GetCkErrorName(LibCmo::CK2::CKERROR err);
std::string GetClassIdHierarchy(LibCmo::CK2::CK_CLASSID cls); std::string GetClassIdHierarchy(LibCmo::CK2::CK_CLASSID cls);
std::string GetCkErrorDescription(LibCmo::CK2::CKERROR err); std::string GetCkErrorDescription(LibCmo::CK2::CKERROR err);
std::string GetAccessibleFileSize(uint64_t size); std::string GetReadableFileSize(uint64_t size);
namespace EnumDesc {
extern const GeneralReflectionArray<LibCmo::CK2::CK_FILE_WRITEMODE> CK_FILE_WRITEMODE;
extern const GeneralReflectionArray<LibCmo::CK2::CK_LOAD_FLAGS> CK_LOAD_FLAGS;
extern const GeneralReflectionArray<LibCmo::CK2::CK_FO_OPTIONS> CK_FO_OPTIONS;
extern const GeneralReflectionArray<LibCmo::CK2::CK_LOADMODE> CK_LOADMODE;
extern const GeneralReflectionArray<LibCmo::CK2::CK_OBJECTCREATION_OPTIONS> CK_OBJECTCREATION_OPTIONS;
extern const GeneralReflectionArray<LibCmo::CK2::CK_PLUGIN_TYPE> CK_PLUGIN_TYPE;
extern const GeneralReflectionArray<LibCmo::CK2::CK_STATECHUNK_CHUNKOPTIONS> CK_STATECHUNK_CHUNKOPTIONS;
extern const GeneralReflectionArray<LibCmo::CK2::CK_OBJECT_FLAGS> CK_OBJECT_FLAGS;
extern const GeneralReflectionArray<LibCmo::CK2::CK_STATECHUNK_DATAVERSION> CK_STATECHUNK_DATAVERSION;
extern const GeneralReflectionArray<LibCmo::CK2::CK_STATECHUNK_CHUNKVERSION> CK_STATECHUNK_CHUNKVERSION;
}
} }
} }

View File

@ -1,3 +1,4 @@
#include <VTAll.hpp>
#include "StructFormatter.hpp" #include "StructFormatter.hpp"
#include "AccessibleValue.hpp" #include "AccessibleValue.hpp"
#include "TerminalHelper.hpp" #include "TerminalHelper.hpp"
@ -26,23 +27,23 @@ namespace Unvirt::StructFormatter {
fileinfo.ProductVersion, product_series[0], product_series[1], product_series[2], product_series[3] fileinfo.ProductVersion, product_series[0], product_series[1], product_series[2], product_series[3]
); );
fprintf(fout, "Save Flags: %s\n", Unvirt::AccessibleValue::GetFlagEnumName<LibCmo::CK2::CK_FILE_WRITEMODE>( fprintf(fout, "Save Flags: %s\n", Unvirt::AccessibleValue::GetFlagEnumName(
Unvirt::AccessibleValue::EnumDesc::CK_FILE_WRITEMODE, fileinfo.FileWriteMode fileinfo.FileWriteMode, Unvirt::AccessibleValue::EnumDesc::CK_FILE_WRITEMODE
).c_str()); ).c_str());
fprintf(fout, "File Size: %s\n", Unvirt::AccessibleValue::GetAccessibleFileSize(fileinfo.FileSize).c_str()); fprintf(fout, "File Size: %s\n", Unvirt::AccessibleValue::GetReadableFileSize(fileinfo.FileSize).c_str());
fprintf(fout, "Crc: 0x%" PRIX32 "\n", fileinfo.Crc); fprintf(fout, "Crc: 0x%" PRIX32 "\n", fileinfo.Crc);
fputc('\n', fout); fputc('\n', fout);
fputs("Hdr1 (Pack / UnPack): ", fout); fputs("Hdr1 (Pack / UnPack): ", fout);
fprintf(fout, "%s / ", Unvirt::AccessibleValue::GetAccessibleFileSize(fileinfo.Hdr1PackSize).c_str()); fprintf(fout, "%s / ", Unvirt::AccessibleValue::GetReadableFileSize(fileinfo.Hdr1PackSize).c_str());
fprintf(fout, "%s\n", Unvirt::AccessibleValue::GetAccessibleFileSize(fileinfo.Hdr1UnPackSize).c_str()); fprintf(fout, "%s\n", Unvirt::AccessibleValue::GetReadableFileSize(fileinfo.Hdr1UnPackSize).c_str());
fputs("Data (Pack / UnPack): ", fout); fputs("Data (Pack / UnPack): ", fout);
fprintf(fout, "%s / ", Unvirt::AccessibleValue::GetAccessibleFileSize(fileinfo.DataPackSize).c_str()); fprintf(fout, "%s / ", Unvirt::AccessibleValue::GetReadableFileSize(fileinfo.DataPackSize).c_str());
fprintf(fout, "%s\n", Unvirt::AccessibleValue::GetAccessibleFileSize(fileinfo.DataUnPackSize).c_str()); fprintf(fout, "%s\n", Unvirt::AccessibleValue::GetReadableFileSize(fileinfo.DataUnPackSize).c_str());
fputc('\n', fout); fputc('\n', fout);
@ -52,12 +53,18 @@ namespace Unvirt::StructFormatter {
} }
static void PrintCKSTRING(const std::string& name) { static void PrintCKSTRING(const LibCmo::TypeHelper::MKString& name) {
if (name.empty()) { LibCmo::CK2::CKSTRING ckname = name.c_str();
if (ckname == nullptr) {
fputs(UNVIRT_TERMCOL_LIGHT_MAGENTA(("<anonymous>")), fout); fputs(UNVIRT_TERMCOL_LIGHT_MAGENTA(("<anonymous>")), fout);
} else { } else {
fputs(name.c_str(), fout); fputs(ckname, fout);
} }
//if (name.empty()) {
// fputs(UNVIRT_TERMCOL_LIGHT_MAGENTA(("<anonymous>")), fout);
//} else {
// fputs(name.c_str(), fout);
//}
} }
static void PrintPointer(const void* ptr) { static void PrintPointer(const void* ptr) {
if (ptr == nullptr) { if (ptr == nullptr) {
@ -70,7 +77,7 @@ namespace Unvirt::StructFormatter {
fprintf(stdout, "<0x%08" PRIx32 ", 0x%08" PRIx32 ">", guid.d1, guid.d2); fprintf(stdout, "<0x%08" PRIx32 ", 0x%08" PRIx32 ">", guid.d1, guid.d2);
} }
void PrintObjectList(const LibCmo::CK2::XArray<LibCmo::CK2::CKFileObject>& ls, size_t page, size_t pageitems) { void PrintObjectList(const LibCmo::XContainer::XArray<LibCmo::CK2::CKFileObject>& ls, size_t page, size_t pageitems) {
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKFileObject\n")), fout); fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKFileObject\n")), fout);
size_t fulllen = ls.size(), size_t fulllen = ls.size(),
@ -97,7 +104,7 @@ namespace Unvirt::StructFormatter {
fprintf(fout, "Page %zu of %zu\n", page + 1, fullpage + 1); fprintf(fout, "Page %zu of %zu\n", page + 1, fullpage + 1);
} }
void PrintManagerList(const LibCmo::CK2::XArray<LibCmo::CK2::CKFileManagerData>& ls, size_t page, size_t pageitems) { void PrintManagerList(const LibCmo::XContainer::XArray<LibCmo::CK2::CKFileManagerData>& ls, size_t page, size_t pageitems) {
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKFileManager\n")), fout); fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKFileManager\n")), fout);
size_t fulllen = ls.size(), size_t fulllen = ls.size(),
@ -113,8 +120,6 @@ namespace Unvirt::StructFormatter {
PrintCKGUID(mgr.Manager); PrintCKGUID(mgr.Manager);
fputc('\t', fout); fputc('\t', fout);
PrintPointer(mgr.MgrPtr);
fputc('\t', fout);
PrintPointer(mgr.Data); PrintPointer(mgr.Data);
fputc('\n', fout); fputc('\n', fout);
} }

View File

@ -1,11 +1,12 @@
#pragma once #pragma once
#include <CKFile.hpp> #include <VTAll.hpp>
#include <CK2/CKFile.hpp>
namespace Unvirt::StructFormatter { namespace Unvirt::StructFormatter {
void PrintCKFileInfo(const LibCmo::CK2::CKFileInfo& fileinfo); void PrintCKFileInfo(const LibCmo::CK2::CKFileInfo& fileinfo);
void PrintObjectList(const LibCmo::CK2::XArray<LibCmo::CK2::CKFileObject>& ls, size_t page, size_t pageitems); void PrintObjectList(const LibCmo::XContainer::XArray<LibCmo::CK2::CKFileObject>& ls, size_t page, size_t pageitems);
void PrintManagerList(const LibCmo::CK2::XArray<LibCmo::CK2::CKFileManagerData>& ls, size_t page, size_t pageitems); void PrintManagerList(const LibCmo::XContainer::XArray<LibCmo::CK2::CKFileManagerData>& ls, size_t page, size_t pageitems);
} }

View File

@ -1,6 +1,9 @@
#include "TerminalHelper.hpp" #include "TerminalHelper.hpp"
#include <VTUtils.hpp> #include <VTUtils.hpp>
#include <VTEncoding.hpp>
#include <cstdarg> #include <cstdarg>
#include <iostream>
#include <cstdio>
#if defined(LIBCMO_OS_WIN32) #if defined(LIBCMO_OS_WIN32)
#include <Windows.h> #include <Windows.h>
@ -43,5 +46,16 @@ namespace Unvirt {
return true; return true;
} }
void GetCmdLine(std::string& u8cmd) {
fputs("Unvirt> ", stdout);
#if defined(LIBCMO_OS_WIN32)
std::wstring wcmd;
std::getline(std::wcin, wcmd);
LibCmo::EncodingHelper::WcharToChar(wcmd, u8cmd, CP_UTF8);
#else
std::getline(std::cin, u8cmd);
#endif
}
} }
} }

View File

@ -1,7 +1,8 @@
#pragma once #pragma once
namespace Unvirt{ #include <string>
namespace TerminalHelper {
namespace Unvirt::TerminalHelper {
#define UNVIRT_REMOVE_PARENS_IMPL(...) __VA_ARGS__ #define UNVIRT_REMOVE_PARENS_IMPL(...) __VA_ARGS__
#define UNVIRT_REMOVE_PARENS(T) UNVIRT_REMOVE_PARENS_IMPL T #define UNVIRT_REMOVE_PARENS(T) UNVIRT_REMOVE_PARENS_IMPL T
@ -48,6 +49,6 @@ namespace Unvirt{
bool EnsureTerminalColor(void); bool EnsureTerminalColor(void);
bool EnsureTerminalEncoding(void); bool EnsureTerminalEncoding(void);
void GetCmdLine(std::string&);
} }
}

View File

@ -3,16 +3,33 @@
#include "StructFormatter.hpp" #include "StructFormatter.hpp"
#include "CmdHelper.hpp" #include "CmdHelper.hpp"
#include "CKMinContext.hpp" #include <VTAll.hpp>
#include "CKFile.hpp" #include <CK2/CKContext.hpp>
#include <CK2/CKFile.hpp>
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
int main(int argc, char* argv[]) { namespace Unvirt {
class UnvirtContext {
public:
UnvirtContext() {}
~UnvirtContext() {}
void Run() {
Unvirt::TerminalHelper::EnsureTerminalColor(); Unvirt::TerminalHelper::EnsureTerminalColor();
Unvirt::TerminalHelper::EnsureTerminalEncoding(); Unvirt::TerminalHelper::EnsureTerminalEncoding();
}
private:
};
}
int main(int argc, char* argv[]) {
//LibCmo::CK2::CKMinContext vtctx; //LibCmo::CK2::CKMinContext vtctx;
//vtctx.SetTempPath("Temp"); //vtctx.SetTempPath("Temp");
//vtctx.SetEncoding("850"); //vtctx.SetEncoding("850");
@ -23,9 +40,8 @@ int main(int argc, char* argv[]) {
//if (doc) //if (doc)
// Unvirt::StructFormatter::PrintCKFileInfo(doc->m_FileInfo); // Unvirt::StructFormatter::PrintCKFileInfo(doc->m_FileInfo);
auto cmd = new Unvirt::CmdHelper::InteractiveCmd(); Unvirt::UnvirtContext ctx;
cmd->Run(); ctx.Run();
delete cmd;
return 0; return 0;
} }