本文整理汇总了C++中structureddata::Dictionary::GetValueForKeyAsArray方法的典型用法代码示例。如果您正苦于以下问题:C++ Dictionary::GetValueForKeyAsArray方法的具体用法?C++ Dictionary::GetValueForKeyAsArray怎么用?C++ Dictionary::GetValueForKeyAsArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类structureddata::Dictionary
的用法示例。
在下文中一共展示了Dictionary::GetValueForKeyAsArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateFromStructuredData
SearchFilterSP SearchFilterByModule::CreateFromStructuredData(
Target &target, const StructuredData::Dictionary &data_dict,
Status &error) {
StructuredData::Array *modules_array;
bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
modules_array);
if (!success) {
error.SetErrorString("SFBM::CFSD: Could not find the module list key.");
return nullptr;
}
size_t num_modules = modules_array->GetSize();
if (num_modules > 1) {
error.SetErrorString(
"SFBM::CFSD: Only one modules allowed for SearchFilterByModule.");
return nullptr;
}
llvm::StringRef module;
success = modules_array->GetItemAtIndexAsString(0, module);
if (!success) {
error.SetErrorString("SFBM::CFSD: filter module item not a string.");
return nullptr;
}
FileSpec module_spec(module);
return std::make_shared<SearchFilterByModule>(target.shared_from_this(),
module_spec);
}
示例2: g_bitfield_regex
size_t
DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict, ByteOrder byte_order)
{
assert(!m_finalized);
StructuredData::Array *sets = nullptr;
if (dict.GetValueForKeyAsArray("sets", sets))
{
const uint32_t num_sets = sets->GetSize();
for (uint32_t i=0; i<num_sets; ++i)
{
std::string set_name_str;
ConstString set_name;
if (sets->GetItemAtIndexAsString(i, set_name_str))
set_name.SetCString(set_name_str.c_str());
if (set_name)
{
RegisterSet new_set = { set_name.AsCString(), NULL, 0, NULL };
m_sets.push_back (new_set);
}
else
{
Clear();
printf("error: register sets must have valid names\n");
return 0;
}
}
m_set_reg_nums.resize(m_sets.size());
}
StructuredData::Array *regs = nullptr;
if (!dict.GetValueForKeyAsArray("registers", regs))
return 0;
const uint32_t num_regs = regs->GetSize();
// typedef std::map<std::string, std::vector<std::string> > InvalidateNameMap;
// InvalidateNameMap invalidate_map;
for (uint32_t i = 0; i < num_regs; ++i)
{
StructuredData::Dictionary *reg_info_dict = nullptr;
if (!regs->GetItemAtIndexAsDictionary(i, reg_info_dict))
{
Clear();
printf("error: items in the 'registers' array must be dictionaries\n");
regs->DumpToStdout();
return 0;
}
// { 'name':'rcx' , 'bitsize' : 64, 'offset' : 16, 'encoding':'uint' , 'format':'hex' , 'set': 0, 'gcc' : 2,
// 'dwarf' : 2, 'generic':'arg4', 'alt-name':'arg4', },
RegisterInfo reg_info;
std::vector<uint32_t> value_regs;
std::vector<uint32_t> invalidate_regs;
memset(®_info, 0, sizeof(reg_info));
ConstString name_val;
ConstString alt_name_val;
if (!reg_info_dict->GetValueForKeyAsString("name", name_val, nullptr))
{
Clear();
printf("error: registers must have valid names and offsets\n");
reg_info_dict->DumpToStdout();
return 0;
}
reg_info.name = name_val.GetCString();
reg_info_dict->GetValueForKeyAsString("alt-name", alt_name_val, nullptr);
reg_info.alt_name = alt_name_val.GetCString();
reg_info_dict->GetValueForKeyAsInteger("offset", reg_info.byte_offset, UINT32_MAX);
if (reg_info.byte_offset == UINT32_MAX)
{
// No offset for this register, see if the register has a value expression
// which indicates this register is part of another register. Value expressions
// are things like "rax[31:0]" which state that the current register's value
// is in a concrete register "rax" in bits 31:0. If there is a value expression
// we can calculate the offset
bool success = false;
std::string slice_str;
if (reg_info_dict->GetValueForKeyAsString("slice", slice_str, nullptr))
{
// Slices use the following format:
// REGNAME[MSBIT:LSBIT]
// REGNAME - name of the register to grab a slice of
// MSBIT - the most significant bit at which the current register value starts at
// LSBIT - the least significant bit at which the current register value ends at
static RegularExpression g_bitfield_regex("([A-Za-z_][A-Za-z0-9_]*)\\[([0-9]+):([0-9]+)\\]");
RegularExpression::Match regex_match(3);
if (g_bitfield_regex.Execute(slice_str.c_str(), ®ex_match))
{
llvm::StringRef reg_name_str;
std::string msbit_str;
std::string lsbit_str;
if (regex_match.GetMatchAtIndex(slice_str.c_str(), 1, reg_name_str) &&
regex_match.GetMatchAtIndex(slice_str.c_str(), 2, msbit_str) &&
regex_match.GetMatchAtIndex(slice_str.c_str(), 3, lsbit_str))
{
const uint32_t msbit = StringConvert::ToUInt32(msbit_str.c_str(), UINT32_MAX);
const uint32_t lsbit = StringConvert::ToUInt32(lsbit_str.c_str(), UINT32_MAX);
if (msbit != UINT32_MAX && lsbit != UINT32_MAX)
{
if (msbit > lsbit)
//.........这里部分代码省略.........