增加16进制支持
This commit is contained in:
@@ -91,6 +91,15 @@ namespace ling {
|
||||
return anonymity;
|
||||
}
|
||||
|
||||
/// 自动处理16进制
|
||||
static inline int64_t toInt64(const std::string &str) {
|
||||
if (str.find("0x") == std::string::npos)
|
||||
return std::stoll(str);
|
||||
int64_t value;
|
||||
::sscanf(str.c_str(), "0x%lxx", &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
void Order::analysis() {
|
||||
for (auto it = cmd.begin(); it != cmd.end(); ++it) {
|
||||
auto rules = data.find(*it);
|
||||
@@ -127,7 +136,7 @@ namespace ling {
|
||||
if (std::next(it)->at(0) == '-')
|
||||
throw OptionsException("参数不足!" + *it + " 需要提供参数");
|
||||
++it;
|
||||
opt_int[rules->second.id] = std::stoll(*it);
|
||||
opt_int[rules->second.id] = toInt64(*it);
|
||||
break;
|
||||
case DOUBLE:
|
||||
if (opt_double.find(rules->second.id) != opt_double.end())
|
||||
|
||||
Reference in New Issue
Block a user