XNSim/XNEngine/main.cpp

77 lines
1.8 KiB
C++
Raw Normal View History

2025-04-28 12:25:20 +08:00
/**
* @file main.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-02-14
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include <QCoreApplication>
#include "XNEngine.h"
/**
* @brief
* @param argc
* @param argv
* @return
*/
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
//检测输入参数个数
if (argc <= 1) {
qFatal("0x1000 The input parameters do not contain the path to the runtime environment "
"configuration file, the engine will exit!");
}
//第一个参数必须为运行环境配置文件路径
QString SecPath = argv[1];
//检测第一个参数是否是运行环境配置文件
//限制以下临时变量的生存
{
int index = SecPath.lastIndexOf('.');
if (index != -1) {
QString suffix = SecPath.mid(index);
if (suffix != QString(".xml") && suffix != QString(".sce")) {
qFatal("0x1001 The runtime environment configuration file is not a .xml or .sce "
"file, the engine will exit!");
}
} else {
qFatal("0x1002 The runtime environment configuration file is not a .xml or .sce "
"file, the engine will exit!");
}
}
XNEngine engine;
quint32 frameworkType = 0;
//依次读取其它附加参数
for (int i = 2; i < argc;) {
QString arg = argv[i];
//TODO Error1003 ~ 101f
if ("-fw" == arg) {
if ((i + 1) < argc) {
frameworkType = atoi(argv[i + 1]);
i += 2;
} else {
qFatal("0x1003 After the -fw parameter, the framework type is not specified, the "
"engine will exit!");
}
} else if ("-test" == arg) {
engine.SetTestMode(true);
i++;
} else {
i++;
}
//TODO 其它参数解析
}
// 引擎运行
bool isReady = engine.Run(SecPath);
if (!isReady)
return -1;
return a.exec();
}