本文整理汇总了C++中llvm::StringRef::getAsInteger方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRef::getAsInteger方法的具体用法?C++ StringRef::getAsInteger怎么用?C++ StringRef::getAsInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::StringRef
的用法示例。
在下文中一共展示了StringRef::getAsInteger方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetOptionValue
Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override {
Error error;
const int short_option = m_getopt_table[option_idx].val;
switch (short_option) {
case 'r':
reg = ConstString(option_arg);
break;
case 'a': {
address.emplace();
if (option_arg.getAsInteger(0, *address)) {
address.reset();
error.SetErrorStringWithFormat("invalid address argument '%s'",
option_arg.str().c_str());
}
} break;
case 'o': {
offset.emplace();
if (option_arg.getAsInteger(0, *offset)) {
offset.reset();
error.SetErrorStringWithFormat("invalid offset argument '%s'",
option_arg.str().c_str());
}
} break;
default:
error.SetErrorStringWithFormat("invalid short option character '%c'",
short_option);
break;
}
return error;
}
示例2: parse
bool parse(cl::Option &O, llvm::StringRef /*ArgName*/, llvm::StringRef Arg,
unsigned char &Val) {
if (Arg == "") {
Val = 0;
return false;
}
if (Arg.getAsInteger(0, Val)) {
return O.error("'" + Arg +
"' value invalid for required coverage percentage");
}
if (Val > 100) {
return O.error("Required coverage percentage must be <= 100");
}
return false;
}
示例3: SetOptionValue
Status OptionGroupValueObjectDisplay::SetOptionValue(
uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Status error;
const int short_option = g_option_table[option_idx].short_option;
bool success = false;
switch (short_option) {
case 'd': {
int32_t result;
result =
Args::StringToOptionEnum(option_arg, g_dynamic_value_types, 2, error);
if (error.Success())
use_dynamic = (lldb::DynamicValueType)result;
} break;
case 'T':
show_types = true;
break;
case 'L':
show_location = true;
break;
case 'F':
flat_output = true;
break;
case 'O':
use_objc = true;
break;
case 'R':
be_raw = true;
break;
case 'A':
ignore_cap = true;
break;
case 'D':
if (option_arg.getAsInteger(0, max_depth)) {
max_depth = UINT32_MAX;
error.SetErrorStringWithFormat("invalid max depth '%s'",
option_arg.str().c_str());
}
break;
case 'Z':
if (option_arg.getAsInteger(0, elem_count)) {
elem_count = UINT32_MAX;
error.SetErrorStringWithFormat("invalid element count '%s'",
option_arg.str().c_str());
}
break;
case 'P':
if (option_arg.getAsInteger(0, ptr_depth)) {
ptr_depth = 0;
error.SetErrorStringWithFormat("invalid pointer depth '%s'",
option_arg.str().c_str());
}
break;
case 'Y':
if (option_arg.empty())
no_summary_depth = 1;
else if (option_arg.getAsInteger(0, no_summary_depth)) {
no_summary_depth = 0;
error.SetErrorStringWithFormat("invalid pointer depth '%s'",
option_arg.str().c_str());
}
break;
case 'S':
use_synth = Args::StringToBoolean(option_arg, true, &success);
if (!success)
error.SetErrorStringWithFormat("invalid synthetic-type '%s'",
option_arg.str().c_str());
break;
case 'V':
run_validator = Args::StringToBoolean(option_arg, true, &success);
if (!success)
error.SetErrorStringWithFormat("invalid validate '%s'",
option_arg.str().c_str());
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
break;
}
return error;
}