diff --git a/ArgsParser/.vscode/c_cpp_properties.json b/ArgsParser/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..84a652a --- /dev/null +++ b/ArgsParser/.vscode/c_cpp_properties.json @@ -0,0 +1,27 @@ +{ + "configurations": [ + { + "name": "Mac", + "defines": [], + "compilerPath": "/usr/bin/clang", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "macos-clang-x64", + "includePath": [ + "/" + ] + }, + { + "name": "mloc", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/bin/clang", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "macos-clang-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/ArgsParser/CMakeLists.txt b/ArgsParser/CMakeLists.txt new file mode 100644 index 0000000..a218c28 --- /dev/null +++ b/ArgsParser/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.10) + +project(ArgsParser CXX) + +set(CMAKE_PREFIX_PATH "~/Qt5.12.4/5.12.4/clang_64/lib/cmake") + +find_package(Qt5 COMPONENTS Core REQUIRED) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_library(ArgsParser argsparser.cpp) + +set(CMAKE_CXX_STANDARD 20) + +target_link_libraries(ArgsParser Qt5::Core) diff --git a/ArgsParser/argsparser.cpp b/ArgsParser/argsparser.cpp index 67f586f..6f594ea 100644 --- a/ArgsParser/argsparser.cpp +++ b/ArgsParser/argsparser.cpp @@ -107,10 +107,18 @@ bool FloatOption::parse(const QList args) { MatchMode::MatchMode(int mode_code, const QString& mode) :_means_explain(mode), code_store(mode_code) { } -/** -* @brief 获取模式代码 -* @return 模式代码 -*/ +#include +class inner_exception : public std::exception { +private: + QByteArray _message; + +public: + inner_exception(const QString &msg) + :_message(msg.toUtf8()){} + virtual const char* what() const noexcept{ + return _message.data(); + } +}; MatchMode& MatchMode::operator<<(std::shared_ptr unit) { if(unit->paramType() == ParamType::FloatParam){ @@ -119,7 +127,7 @@ MatchMode& MatchMode::operator<<(std::shared_ptr unit) { 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("重复设置选项"); + throw new inner_exception("重复设置选项"); } } }