From 37e3119934517dc612cbead4aff08bfd700d275b Mon Sep 17 00:00:00 2001 From: codeboss <2422523675@qq.com> Date: Fri, 4 Oct 2024 13:12:16 +0800 Subject: [PATCH] 1 --- ArgsParser/argsparser.cpp | 13 +++++++++- ArgsParser/argsparser.h | 2 +- StoryPresent/StoryPresent.vcxproj | 10 ++++++++ StoryPresent/StoryPresent.vcxproj.user | 2 +- StoryPresent/dag_layout.cpp | 4 +--- StoryPresent/main.cpp | 33 +++++++++++++++++++++++++- WsNovelManager/main.cpp | 6 ++--- WsNovelParser/main.cpp | 4 ++-- 8 files changed, 62 insertions(+), 12 deletions(-) diff --git a/ArgsParser/argsparser.cpp b/ArgsParser/argsparser.cpp index f7f5b77..905a4ad 100644 --- a/ArgsParser/argsparser.cpp +++ b/ArgsParser/argsparser.cpp @@ -113,6 +113,17 @@ MatchMode::MatchMode(int mode_code, const QString& mode) */ MatchMode& MatchMode::operator<<(std::shared_ptr unit) { + if(unit->paramType() == ParamType::FloatParam){ + auto unit_in = std::dynamic_pointer_cast<__FloatArgvImpls>(unit); + for (auto& u_exist : args_mode) { + if (u_exist->paramType() == ParamType::FloatParam) { + auto u_cast = std::dynamic_pointer_cast<__FloatArgvImpls>(u_exist); + if (u_cast->bindKey() == unit_in->bindKey()) + throw new std::exception("ÖØ¸´ÉèÖÃÑ¡Ïî"); + } + } + } + args_mode << unit; return *this; } @@ -221,7 +232,7 @@ std::shared_ptr MatchMode::getUnitViaInitIndex(int pos) { return args_mode[pos]; } -QString ArgsParser::helpDoc() const { +QString ArgsParser::helperDoc() const { QString help_string; for (auto& mode : this->match_modes) { help_string += "Usage:" + mode->usageString() + "\n"; diff --git a/ArgsParser/argsparser.h b/ArgsParser/argsparser.h index 37da01e..ecfa440 100644 --- a/ArgsParser/argsparser.h +++ b/ArgsParser/argsparser.h @@ -199,7 +199,7 @@ namespace args_parse { QList> match_modes; public: - QString helpDoc() const; + QString helperDoc() const; ArgsParser& operator<<(std::shared_ptr mode); diff --git a/StoryPresent/StoryPresent.vcxproj b/StoryPresent/StoryPresent.vcxproj index 33cdec2..24e63fe 100644 --- a/StoryPresent/StoryPresent.vcxproj +++ b/StoryPresent/StoryPresent.vcxproj @@ -61,15 +61,25 @@ StoryPresent + $(SolutionDir)ArgsParser;$(IncludePath) + $(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath) $(ProjectName) + $(SolutionDir)ArgsParser;$(IncludePath) + $(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath) + + ArgsParser.lib;%(AdditionalDependencies) + + + ArgsParser.lib;%(AdditionalDependencies) + diff --git a/StoryPresent/StoryPresent.vcxproj.user b/StoryPresent/StoryPresent.vcxproj.user index 8d0546a..2349169 100644 --- a/StoryPresent/StoryPresent.vcxproj.user +++ b/StoryPresent/StoryPresent.vcxproj.user @@ -1,7 +1,7 @@  - --graph --path D:\CustomNovel + --help WindowsLocalDebugger diff --git a/StoryPresent/dag_layout.cpp b/StoryPresent/dag_layout.cpp index c9b36c2..71181a3 100644 --- a/StoryPresent/dag_layout.cpp +++ b/StoryPresent/dag_layout.cpp @@ -205,9 +205,7 @@ QList> DAGGraph::tidy_graph_nodes() { nodes_temp[node->bindPoint().name()] = std::make_shared(node); } - QList> temp_array; - temp_array.append(nodes_temp.values()); - + QList> temp_array(nodes_temp.values()); for (auto node : this->graph_inst.values()) { for (auto next : node->nextNodes()) { auto node_links = QList>{ diff --git a/StoryPresent/main.cpp b/StoryPresent/main.cpp index 9f97a82..9a4a3bb 100644 --- a/StoryPresent/main.cpp +++ b/StoryPresent/main.cpp @@ -3,13 +3,44 @@ #include "xast_parse.h" #include "dag_present.h" #include "view_present.h" +#include #include -#include +#include +#include #include +using namespace args_parse; +using namespace std; + + int main(int argc, char* argv[]) { QApplication a(argc, argv); + ArgsParser cmdrec; + auto help_mode = std::make_shared(0x000au, u8"´òÓ¡°ïÖúÎĵµ"); + cmdrec << help_mode; + (*help_mode) << std::make_shared(u8"StoryPresent", u8"³ÌÐòÃû") << make_shared(u8"help", u8"´òÓ¡°ïÖúÎĵµ"); + + auto rst = cmdrec.parse(argc, argv); + QTextEdit msg; + msg.setReadOnly(true); + if (!rst) { + msg.setWindowTitle(u8"²ÎÊýÊäÈë´íÎó"); + msg.setPlainText(cmdrec.helperDoc()); + msg.show(); + } + else { + switch (rst->modeCode()) { + case 0x000au: + msg.setWindowTitle(u8"°ïÖúÐÅÏ¢"); + msg.setPlainText(cmdrec.helperDoc()); + msg.show(); + break; + default: + break; + } + } + return a.exec(); } diff --git a/WsNovelManager/main.cpp b/WsNovelManager/main.cpp index 329350d..ef14f0e 100644 --- a/WsNovelManager/main.cpp +++ b/WsNovelManager/main.cpp @@ -40,12 +40,12 @@ int main(int argc, char *argv[]) auto rst = entry_parser.parse(argc, argv); if (!rst) { - qDebug().noquote() << u8"ÃüÁîÐвÎÊý´íÎó"; - qDebug().noquote() << entry_parser.helpDoc(); + qDebug().noquote() << u8"ÃüÁîÐвÎÊý´íÎó¡£"; + qDebug().noquote() << entry_parser.helperDoc(); return 0; } if (rst->modeCode() == 0x000au) { - qDebug().noquote() << entry_parser.helpDoc(); + qDebug().noquote() << entry_parser.helperDoc(); } diff --git a/WsNovelParser/main.cpp b/WsNovelParser/main.cpp index 6f13083..63d1586 100644 --- a/WsNovelParser/main.cpp +++ b/WsNovelParser/main.cpp @@ -41,7 +41,7 @@ int main(int argc, char* argv[]) { auto p_result = args_parser.parse(argc, argv); if (!p_result) { qDebug().noquote() << u8"ÃüÁîÐвÎÊý´íÎó£¡"; - qDebug().noquote() << args_parser.helpDoc(); + qDebug().noquote() << args_parser.helperDoc(); } else { switch (p_result->modeCode()) { @@ -117,7 +117,7 @@ int main(int argc, char* argv[]) { }break; case 0xAu: default: - qDebug().noquote() << args_parser.helpDoc(); + qDebug().noquote() << args_parser.helperDoc(); break; } }