1#ifndef MSTL_CORE_SYSTEM_CMDLINE_HPP__
2#define MSTL_CORE_SYSTEM_CMDLINE_HPP__
3#include "../container/unordered_map.hpp"
4#include "../container/vector.hpp"
5#include "../string/string.hpp"
11class MSTL_API cmdline {
17 bool requires_value =
false;
18 bool allow_multiple =
false;
21 _MSTL vector<string> values;
24 option(
string lname,
char sname,
string desc,
25 bool req_val,
bool allow_multi,
string def_val);
28 void add_option(
const string& long_name,
char short_name,
29 const string& description,
bool requires_value =
false,
30 bool allow_multiple =
false,
const string& default_value =
"");
33 void parse(
int argc,
char* argv[]);
34 void parse(
const _MSTL vector<string>& args);
36 string get(
const string& long_name,
size_t index = 0)
const;
37 bool has(
const string& long_name)
const;
38 size_t count(
const string& long_name)
const;
40 const _MSTL vector<string>& positional_args()
const {
return positional_; }
41 string program_name()
const {
return program_name_; }
43 void print_help()
const;
45 static _MSTL vector<string> get_os_argv();
49 _MSTL vector<option> options_;
50 _MSTL unordered_map<string, option*> options_long_;
51 _MSTL unordered_map<char, option*> options_short_;
52 _MSTL vector<string> positional_;
54 option* find_option_long(
const string& name);
55 option* find_option_short(
char name);
57 void parse_long_option(
const string& arg,
const _MSTL vector<string>& args,
size_t& i);
58 void parse_short_options(
const string& arg,
const _MSTL vector<string>& args,
size_t& i);
MSTL_ALWAYS_INLINE enable_if_t< is_void_v< T >, future_result_t< T > > get(future< T > &f)
通用future结果获取函数
constexpr iter_difference_t< Iterator > count(Iterator first, Iterator last, const T &value)
统计范围内等于指定值的元素数量
#define MSTL_ERROR_BUILD_FINAL_CLASS(THIS, BASE, INFO)
构建最终异常类宏
#define _MSTL
全局命名空间MSTL前缀
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL