Compare commits
3 Commits
d0fa2671fa
...
48af8723ef
Author | SHA1 | Date |
---|---|---|
|
48af8723ef | |
|
90b2323eb0 | |
|
aa9cdff7a4 |
|
@ -34,8 +34,8 @@ bool __FloatArgvImpls::optional() const {
|
|||
return optional_value;
|
||||
}
|
||||
|
||||
QString args_parse::FloatKeyValue::placeHolder() const {
|
||||
if (optional())
|
||||
QString FloatKeyValue::placeHolder(bool v) const {
|
||||
if (optional() && v)
|
||||
return QString("[--%1 <%2>]").arg(bindKey(), bindKey());
|
||||
return QString("--%1 <%2>").arg(bindKey(), bindKey());
|
||||
}
|
||||
|
@ -44,10 +44,13 @@ int FloatKeyValue::matchLenth() const {
|
|||
return 2;
|
||||
}
|
||||
|
||||
bool FloatKeyValue::parse(const QList<QString> args, int start) {
|
||||
auto args_t = args[start];
|
||||
auto args_v = args[start + 1];
|
||||
bool FloatKeyValue::parse(const QList<QString> args) {
|
||||
if (args.size() < 2)
|
||||
return false;
|
||||
|
||||
auto args_t = args[0];
|
||||
if (args_t == u8"--" + bindKey()) {
|
||||
auto args_v = args[1];
|
||||
setValue(args_v);
|
||||
return true;
|
||||
}
|
||||
|
@ -57,7 +60,7 @@ bool FloatKeyValue::parse(const QList<QString> args, int start) {
|
|||
IndexParam::IndexParam(const QString& place_v, const QString& means)
|
||||
: __ArgvPackImpls(means, ParamType::IndexParam), _place_holder(place_v) { }
|
||||
|
||||
QString args_parse::IndexParam::placeHolder() const {
|
||||
QString IndexParam::placeHolder(bool v) const {
|
||||
return QString("<%1>").arg(_place_holder);
|
||||
}
|
||||
|
||||
|
@ -65,8 +68,11 @@ int IndexParam::matchLenth() const {
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool IndexParam::parse(const QList<QString> args, int start) {
|
||||
setValue(args[start]);
|
||||
bool IndexParam::parse(const QList<QString> args) {
|
||||
if (args.size() < 1)
|
||||
return false;
|
||||
|
||||
setValue(args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -74,11 +80,10 @@ __FloatArgvImpls::__FloatArgvImpls(const QString& key, const QString& means, boo
|
|||
: __ArgvPackImpls(means, ParamType::FloatParam), key_name(key), optional_value(optional) { }
|
||||
|
||||
FloatOption::FloatOption(const QString& key, const QString& means, bool opt)
|
||||
: __FloatArgvImpls(key, means, opt) {
|
||||
}
|
||||
: __FloatArgvImpls(key, means, opt) { }
|
||||
|
||||
QString args_parse::FloatOption::placeHolder() const {
|
||||
if (optional())
|
||||
QString FloatOption::placeHolder(bool d) const {
|
||||
if (optional() && d)
|
||||
return QString("[--%1]").arg(bindKey());
|
||||
return QString("--%1").arg(bindKey());
|
||||
}
|
||||
|
@ -87,10 +92,16 @@ int FloatOption::matchLenth() const {
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool FloatOption::parse(const QList<QString> args, int start) {
|
||||
auto args_t = args[start];
|
||||
setValue(args_t == bindKey());
|
||||
return args_t == u8"--" + bindKey();
|
||||
bool FloatOption::parse(const QList<QString> args) {
|
||||
if (args.size() < 1)
|
||||
return false;
|
||||
|
||||
auto args_t = args[0];
|
||||
if (args_t == u8"--" + bindKey()) {
|
||||
setValue(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
MatchMode::MatchMode(int mode_code, const QString& mode)
|
||||
|
@ -101,7 +112,7 @@ MatchMode::MatchMode(int mode_code, const QString& mode)
|
|||
* @return 模式代码
|
||||
*/
|
||||
|
||||
MatchMode& args_parse::MatchMode::operator<<(std::shared_ptr<IArgvPack> unit) {
|
||||
MatchMode& MatchMode::operator<<(std::shared_ptr<IArgvPack> unit) {
|
||||
args_mode << unit;
|
||||
return *this;
|
||||
}
|
||||
|
@ -110,7 +121,7 @@ int MatchMode::modeCode() const {
|
|||
return code_store;
|
||||
}
|
||||
|
||||
QString args_parse::MatchMode::usageString() const {
|
||||
QString MatchMode::usageString() const {
|
||||
QString usage_string;
|
||||
for (auto& item : args_mode)
|
||||
usage_string += item->placeHolder() + u8" ";
|
||||
|
@ -118,15 +129,24 @@ QString args_parse::MatchMode::usageString() const {
|
|||
return usage_string;
|
||||
}
|
||||
|
||||
QString args_parse::MatchMode::explanString() const {
|
||||
QString MatchMode::explanString() const {
|
||||
QStringList sections;
|
||||
sections << u8" " + _means_explain;
|
||||
sections << QString(" Switch:");
|
||||
|
||||
for (auto& item : args_mode) {
|
||||
sections << " " + item->placeHolder();
|
||||
if (item->paramType() == ParamType::IndexParam) {
|
||||
sections << " " + item->placeHolder(false);
|
||||
sections << " " + item->means();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& item : args_mode) {
|
||||
if (item->paramType() == ParamType::FloatParam) {
|
||||
sections << " " + item->placeHolder(false);
|
||||
sections << " " + item->means();
|
||||
}
|
||||
}
|
||||
|
||||
return sections.join("\n");
|
||||
}
|
||||
|
@ -135,47 +155,57 @@ QString args_parse::MatchMode::explanString() const {
|
|||
* @brief 解析匹配参数
|
||||
*/
|
||||
|
||||
bool MatchMode::parse(const QList<QString>& args, int argv_index, int parse_index) {
|
||||
if (argv_index >= args.size())
|
||||
return true;
|
||||
bool MatchMode::parse(const QList<QString>& args) {
|
||||
decltype(this->args_mode) float_units;
|
||||
std::copy_if(this->args_mode.begin(), this->args_mode.end(), std::back_inserter(float_units),
|
||||
[](std::shared_ptr<IArgvPack> inst) {
|
||||
return inst->paramType() == ParamType::FloatParam;
|
||||
});
|
||||
|
||||
// 获取模式匹配单元
|
||||
auto parse_unit = args_mode[parse_index];
|
||||
switch (parse_unit->paramType()) {
|
||||
case ParamType::IndexParam:// 固定位置索引匹配
|
||||
{
|
||||
parse_unit->parse(args, argv_index);
|
||||
// 继续匹配下一个为止
|
||||
return parse(args, argv_index + parse_unit->matchLenth(), parse_index + 1);
|
||||
}break;
|
||||
case ParamType::FloatParam:// 浮动参数匹配
|
||||
{
|
||||
QList<shared_ptr<__FloatArgvImpls>> float_parsers;
|
||||
|
||||
for (auto& unit : args_mode) {
|
||||
if (unit->paramType() == ParamType::FloatParam)
|
||||
float_parsers << dynamic_pointer_cast<__FloatArgvImpls>(unit);
|
||||
auto remains = args;
|
||||
for (auto idx = 0; idx < remains.size(); ++idx) {
|
||||
auto vargs = remains.mid(idx);
|
||||
for (auto& unit : float_units) {
|
||||
if (unit->parse(vargs)) {
|
||||
auto it_start = remains.begin() + idx;
|
||||
auto it_until = it_start + unit->matchLenth();
|
||||
remains.erase(it_start, it_until);
|
||||
idx--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& unit : float_parsers) {
|
||||
if (unit->matchLenth() + argv_index > args.size())
|
||||
continue;
|
||||
|
||||
auto result = unit->parse(args, argv_index);
|
||||
if (result)
|
||||
if (parse(args, argv_index + unit->matchLenth(), parse_index + 1))
|
||||
return true;
|
||||
else if (!result && unit->optional())
|
||||
if (parse(args, argv_index, parse_index + 1))
|
||||
return true;
|
||||
}
|
||||
}break;
|
||||
decltype(this->args_mode) indexed_units;
|
||||
std::copy_if(this->args_mode.begin(), this->args_mode.end(), std::back_inserter(indexed_units),
|
||||
[](std::shared_ptr<IArgvPack> inst) {
|
||||
return inst->paramType() == ParamType::IndexParam;
|
||||
});
|
||||
for (auto idx = 0; idx < std::min(remains.size(), indexed_units.size()); ++idx) {
|
||||
auto vargs = remains.mid(idx);
|
||||
auto unit = indexed_units[idx];
|
||||
unit->parse(vargs);
|
||||
}
|
||||
|
||||
for (auto& u : args_mode) {
|
||||
switch (u->paramType()) {
|
||||
case ParamType::IndexParam:
|
||||
if (u->value().isNull())
|
||||
return false;
|
||||
break;
|
||||
case ParamType::FloatParam:
|
||||
if (!std::dynamic_pointer_cast<__FloatArgvImpls>(u)->optional() && u->value().isNull())
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<IArgvPack> args_parse::MatchMode::getUnitViaKey(const QString& key) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<IArgvPack> MatchMode::getUnitViaKey(const QString& key) {
|
||||
for (auto& u : args_mode) {
|
||||
if (u->paramType() == ParamType::FloatParam) {
|
||||
auto conv = std::dynamic_pointer_cast<__FloatArgvImpls>(u);
|
||||
|
@ -187,11 +217,11 @@ std::shared_ptr<IArgvPack> args_parse::MatchMode::getUnitViaKey(const QString& k
|
|||
return std::shared_ptr<IArgvPack>();
|
||||
}
|
||||
|
||||
std::shared_ptr<IArgvPack> args_parse::MatchMode::getUnitViaPos(int pos) {
|
||||
std::shared_ptr<IArgvPack> MatchMode::getUnitViaInitIndex(int pos) {
|
||||
return args_mode[pos];
|
||||
}
|
||||
|
||||
QString args_parse::ArgsParser::helpDoc() const {
|
||||
QString ArgsParser::helpDoc() const {
|
||||
QString help_string;
|
||||
for (auto& mode : this->match_modes) {
|
||||
help_string += "Usage:" + mode->usageString() + "\n";
|
||||
|
@ -200,7 +230,7 @@ QString args_parse::ArgsParser::helpDoc() const {
|
|||
return help_string;
|
||||
}
|
||||
|
||||
ArgsParser& args_parse::ArgsParser::operator<<(std::shared_ptr<MatchMode> mode) {
|
||||
ArgsParser& ArgsParser::operator<<(std::shared_ptr<MatchMode> mode) {
|
||||
this->match_modes.append(mode);
|
||||
return *this;
|
||||
}
|
||||
|
@ -215,7 +245,7 @@ std::shared_ptr<MatchMode> ArgsParser::parse(int argc, char* argv[]) {
|
|||
|
||||
// 枚举模式匹配
|
||||
for (auto& minst : this->match_modes) {
|
||||
if (minst->parse(args_list, 0, 0))
|
||||
if (minst->parse(args_list))
|
||||
return minst;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace args_parse {
|
|||
* \return 解释
|
||||
*/
|
||||
virtual QString means() const = 0;
|
||||
virtual QString placeHolder() const = 0;
|
||||
virtual QString placeHolder(bool decorate = true) const = 0;
|
||||
virtual QVariant value() const = 0;
|
||||
/**
|
||||
* @brief 匹配长度.
|
||||
|
@ -50,7 +50,7 @@ namespace args_parse {
|
|||
* \param start 起始解析
|
||||
* \return 匹配成功
|
||||
*/
|
||||
virtual bool parse(const QList<QString> args, int start) = 0;
|
||||
virtual bool parse(const QList<QString> args) = 0;
|
||||
};
|
||||
|
||||
class ARGSPARSER_EXPORT __ArgvPackImpls : public IArgvPack {
|
||||
|
@ -98,9 +98,9 @@ namespace args_parse {
|
|||
explicit FloatKeyValue(const QString& key, const QString &means, bool optional = false);
|
||||
virtual ~FloatKeyValue() = default;
|
||||
|
||||
virtual QString placeHolder() const override;
|
||||
virtual QString placeHolder(bool decorate = true) const override;
|
||||
virtual int matchLenth() const override;
|
||||
bool parse(const QList<QString> args, int start) override;
|
||||
bool parse(const QList<QString> args) override;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -119,9 +119,9 @@ namespace args_parse {
|
|||
explicit FloatOption(const QString& key, const QString& means, bool optional = false);
|
||||
virtual ~FloatOption() = default;
|
||||
|
||||
virtual QString placeHolder() const override;
|
||||
virtual QString placeHolder(bool decorate = true) const override;
|
||||
virtual int matchLenth() const override;
|
||||
bool parse(const QList<QString> args, int start) override;
|
||||
bool parse(const QList<QString> args) override;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -136,9 +136,9 @@ namespace args_parse {
|
|||
virtual ~IndexParam() = default;
|
||||
|
||||
// 通过 __ArgvPackImpls 继承
|
||||
virtual QString placeHolder() const override;
|
||||
virtual QString placeHolder(bool decorate = true) const override;
|
||||
int matchLenth() const override;
|
||||
bool parse(const QList<QString> args, int start) override;
|
||||
bool parse(const QList<QString> args) override;
|
||||
};
|
||||
|
||||
class ARGSPARSER_EXPORT MatchMode {
|
||||
|
@ -182,7 +182,7 @@ namespace args_parse {
|
|||
/**
|
||||
* @brief 解析匹配参数
|
||||
*/
|
||||
bool parse(const QList<QString>& args, int argv_index, int parse_index);
|
||||
bool parse(const QList<QString>& args);
|
||||
|
||||
/**
|
||||
* 获取解析单元.
|
||||
|
@ -191,7 +191,7 @@ namespace args_parse {
|
|||
* \return
|
||||
*/
|
||||
std::shared_ptr<IArgvPack> getUnitViaKey(const QString& key);
|
||||
std::shared_ptr<IArgvPack> getUnitViaPos(int pos);
|
||||
std::shared_ptr<IArgvPack> getUnitViaInitIndex(int idx);
|
||||
};
|
||||
|
||||
class ARGSPARSER_EXPORT ArgsParser {
|
||||
|
|
|
@ -60,17 +60,16 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<TargetName>storym</TargetName>
|
||||
<TargetName>StoryPresent</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<TargetName>StoryManage</TargetName>
|
||||
<IncludePath>$(SolutionDir)ArgsParser;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>ArgsParser.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<Link />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
<ClCompile>
|
||||
|
|
|
@ -3,42 +3,13 @@
|
|||
#include "xast_parse.h"
|
||||
#include "dag_present.h"
|
||||
#include "view_present.h"
|
||||
#include <argsparser.h>
|
||||
#include <QDebug>
|
||||
#include <qloggingcategory.h>
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
|
||||
args_parse::ArgsParser entry_parser;
|
||||
QList<std::shared_ptr<args_parse::IArgvPack>> args_mode;
|
||||
args_mode << std::make_shared<args_parse::IndexParam>(u8"程序名称");
|
||||
args_mode << std::make_shared<args_parse::FloatKeyValue>(u8"--help", "帮助选项");
|
||||
entry_parser.loadMode(0x000au, args_mode);
|
||||
args_mode.clear();
|
||||
|
||||
args_mode << std::make_shared<args_parse::IndexParam>(u8"程序名称");
|
||||
args_mode << std::make_shared<args_parse::FloatOption>(u8"--nsc", u8"调用编译功能");
|
||||
args_mode << std::make_shared<args_parse::FloatKeyValue>(u8"--path", u8"源码目录路径", true);
|
||||
args_mode << std::make_shared<args_parse::FloatKeyValue>(u8"--dest", u8"生成目标目录");
|
||||
entry_parser.loadMode(0x000bu, args_mode);
|
||||
args_mode.clear();
|
||||
|
||||
args_mode << std::make_shared<args_parse::IndexParam>(u8"程序名称");
|
||||
args_mode << std::make_shared<args_parse::FloatOption>(u8"--make_anchor");
|
||||
entry_parser.loadMode(0x000cu, args_mode);
|
||||
args_mode.clear();
|
||||
|
||||
args_mode << std::make_shared<args_parse::IndexParam>(u8"程序名称");
|
||||
args_mode << std::make_shared<args_parse::FloatOption>(u8"--cmp");
|
||||
entry_parser.loadMode(0x000du, args_mode);
|
||||
args_mode.clear();
|
||||
|
||||
args_mode << std::make_shared<args_parse::IndexParam>(u8"程序名称");
|
||||
args_mode << std::make_shared<args_parse::FloatOption>(u8"--graph");
|
||||
entry_parser.loadMode(0x000eu, args_mode);
|
||||
|
||||
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{DD802A96-BBB6-47CD-9B64-3582FD1805F3}</ProjectGuid>
|
||||
<Keyword>QtVS_v304</Keyword>
|
||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0</WindowsTargetPlatformVersion>
|
||||
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
|
||||
<Import Project="$(QtMsBuild)\qt_defaults.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
|
||||
<QtInstall>5.12.11_msvc2017_64</QtInstall>
|
||||
<QtModules>core</QtModules>
|
||||
<QtBuildConfig>debug</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
||||
<QtInstall>5.12.11_msvc2017_64</QtInstall>
|
||||
<QtModules>core</QtModules>
|
||||
<QtBuildConfig>release</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
|
||||
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
|
||||
</Target>
|
||||
<ImportGroup Label="ExtensionSettings" />
|
||||
<ImportGroup Label="Shared" />
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<IncludePath>$(SolutionDir)ArgsParser;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||
<TargetName>nsmt</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<TargetName>nsmt</TargetName>
|
||||
<IncludePath>$(SolutionDir)ArgsParser;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>ArgsParser.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>ArgsParser.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
<ClCompile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||
<ClCompile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
||||
<Import Project="$(QtMsBuild)\qt.targets" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Form Files">
|
||||
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
|
||||
<Extensions>ui</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Translation Files">
|
||||
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
|
||||
<Extensions>ts</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerCommandArguments>--help</LocalDebuggerCommandArguments>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<QtTouchProperty>
|
||||
</QtTouchProperty>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<QtTouchProperty>
|
||||
</QtTouchProperty>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -0,0 +1,53 @@
|
|||
#include <QtCore/QCoreApplication>
|
||||
#include <argsparser.h>
|
||||
#include <iostream>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace args_parse;
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
ArgsParser entry_parser;
|
||||
auto help_mode = make_shared<MatchMode>(0x000au, u8"打印帮助信息!");
|
||||
entry_parser << help_mode;
|
||||
(*help_mode) << make_shared<IndexParam>(u8"nsmt", u8"程序名称")
|
||||
<< make_shared<FloatOption>(u8"help", u8"帮助选项");
|
||||
|
||||
auto build_mode = make_shared<MatchMode>(0x000bu, u8"调用构建程序,编译故事线!");
|
||||
entry_parser << build_mode;
|
||||
(*build_mode) << make_shared<IndexParam>(u8"nsmt", u8"程序名称")
|
||||
<< make_shared<FloatOption>(u8"nsc", u8"调用编译功能")
|
||||
<< make_shared<FloatKeyValue>(u8"path", u8"源码目录路径", true)
|
||||
<< make_shared<FloatKeyValue>(u8"dest", u8"生成目标目录");
|
||||
|
||||
auto anchor_mode = make_shared<MatchMode>(0x000cu, u8"设置里程碑");
|
||||
entry_parser << anchor_mode;
|
||||
(*anchor_mode) << make_shared<IndexParam>(u8"nsmt", u8"程序名称")
|
||||
<< make_shared<FloatOption>(u8"mk_anchor", u8"设置里程碑");
|
||||
|
||||
auto cmp_mode = make_shared<MatchMode>(0x000du, u8"比较当前故事线和里程碑故事线");
|
||||
entry_parser << cmp_mode;
|
||||
(*cmp_mode) << make_shared<IndexParam>(u8"nsmt", u8"程序名称")
|
||||
<< make_shared<FloatOption>(u8"cmp", u8"比较当前故事线内容");
|
||||
|
||||
auto graph_mode = make_shared<MatchMode>(0x000eu, u8"图形化显示当前内容");
|
||||
entry_parser << graph_mode;
|
||||
(*graph_mode) << make_shared<IndexParam>(u8"nsmt", u8"程序名称")
|
||||
<< make_shared<FloatKeyValue>(u8"gmode", u8"设置图形化显示的模式");
|
||||
|
||||
auto rst = entry_parser.parse(argc, argv);
|
||||
if (!rst) {
|
||||
qDebug().noquote() << u8"命令行参数错误";
|
||||
qDebug().noquote() << entry_parser.helpDoc();
|
||||
return 0;
|
||||
}
|
||||
if (rst->modeCode() == 0x000au) {
|
||||
qDebug().noquote() << entry_parser.helpDoc();
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -33,6 +33,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ArgsParser", "ArgsParser\Ar
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StoryPresent", "StoryPresent\StoryPresent.vcxproj", "{48DA8516-26EA-4D59-8913-7EF28E3F87C3}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WsNovelManager", "WsNovelManager\WsNovelManager.vcxproj", "{DD802A96-BBB6-47CD-9B64-3582FD1805F3}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{1FF80476-26C9-42FB-BFF6-D587C4941964} = {1FF80476-26C9-42FB-BFF6-D587C4941964}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
|
@ -63,6 +68,10 @@ Global
|
|||
{48DA8516-26EA-4D59-8913-7EF28E3F87C3}.Debug|x64.Build.0 = Debug|x64
|
||||
{48DA8516-26EA-4D59-8913-7EF28E3F87C3}.Release|x64.ActiveCfg = Release|x64
|
||||
{48DA8516-26EA-4D59-8913-7EF28E3F87C3}.Release|x64.Build.0 = Release|x64
|
||||
{DD802A96-BBB6-47CD-9B64-3582FD1805F3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DD802A96-BBB6-47CD-9B64-3582FD1805F3}.Debug|x64.Build.0 = Debug|x64
|
||||
{DD802A96-BBB6-47CD-9B64-3582FD1805F3}.Release|x64.ActiveCfg = Release|x64
|
||||
{DD802A96-BBB6-47CD-9B64-3582FD1805F3}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -20,13 +20,7 @@ using namespace example_novel;
|
|||
using namespace std;
|
||||
using namespace args_parse;
|
||||
|
||||
/*
|
||||
* nsc --help
|
||||
* nsc -[pw] --path path-to-dir [--out path-to-dir]
|
||||
* opts:
|
||||
* p print-struct 输出整体结构
|
||||
* w print-web 基础的web页面输出格式
|
||||
*/
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
|
@ -46,14 +40,11 @@ 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();
|
||||
}
|
||||
else {
|
||||
switch (p_result->modeCode()) {
|
||||
case 0xAu:
|
||||
default:
|
||||
qDebug().noquote() << args_parser.helpDoc();
|
||||
break;
|
||||
case 0xBu:
|
||||
{
|
||||
auto src_dir = dynamic_pointer_cast<FloatKeyValue>(p_result->getUnitViaKey(u8"path"));
|
||||
|
@ -124,6 +115,10 @@ int main(int argc, char* argv[]) {
|
|||
qDebug().noquote() << QString(u8"%±àÒë³É¹¦£º%1¡£").arg(QFileInfo(file).absoluteFilePath());
|
||||
}
|
||||
}break;
|
||||
case 0xAu:
|
||||
default:
|
||||
qDebug().noquote() << args_parser.helpDoc();
|
||||
break;
|
||||
}
|
||||
}
|
||||
//return a.exec();
|
||||
|
|
Loading…
Reference in New Issue