本文整理汇总了C++中lazy_entry::dict_find_list方法的典型用法代码示例。如果您正苦于以下问题:C++ lazy_entry::dict_find_list方法的具体用法?C++ lazy_entry::dict_find_list怎么用?C++ lazy_entry::dict_find_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lazy_entry
的用法示例。
在下文中一共展示了lazy_entry::dict_find_list方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_state
void feed::load_state(lazy_entry const& rd)
{
load_struct(rd, this, feed_map, sizeof(feed_map)/sizeof(feed_map[0]));
lazy_entry const* e = rd.dict_find_list("items");
if (e)
{
m_items.reserve(e->list_size());
for (int i = 0; i < e->list_size(); ++i)
{
if (e->list_at(i)->type() != lazy_entry::dict_t) continue;
m_items.push_back(feed_item());
load_struct(*e->list_at(i), &m_items.back(), feed_item_map
, sizeof(feed_item_map)/sizeof(feed_item_map[0]));
// don't load duplicates
if (m_urls.find(m_items.back().url) != m_urls.end())
{
m_items.pop_back();
continue;
}
m_urls.insert(m_items.back().url);
}
}
load_struct(rd, &m_settings, feed_settings_map
, sizeof(feed_settings_map)/sizeof(feed_settings_map[0]));
e = rd.dict_find_dict("add_params");
if (e)
{
load_struct(*e, &m_settings.add_args, add_torrent_map
, sizeof(add_torrent_map)/sizeof(add_torrent_map[0]));
}
e = rd.dict_find_list("history");
if (e)
{
for (int i = 0; i < e->list_size(); ++i)
{
if (e->list_at(i)->type() != lazy_entry::list_t) continue;
lazy_entry const* item = e->list_at(i);
if (item->list_size() != 2
|| item->list_at(0)->type() != lazy_entry::string_t
|| item->list_at(1)->type() != lazy_entry::int_t)
continue;
m_added.insert(std::pair<std::string, time_t>(
item->list_at(0)->string_value()
, item->list_at(1)->int_value()));
}
}
}
示例2: verify_resume_data
bool default_storage::verify_resume_data(lazy_entry const& rd, error_code& error)
{
lazy_entry const* file_priority = rd.dict_find_list("file_priority");
if (file_priority && file_priority->list_size()
== files().num_files())
{
m_file_priority.resize(file_priority->list_size());
for (int i = 0; i < file_priority->list_size(); ++i)
m_file_priority[i] = boost::uint8_t(file_priority->list_int_value_at(i, 1));
}
bool seed = false;
if (lazy_entry const* pieces = rd.dict_find_string("pieces"))
{
if (int(pieces->string_length()) == m_files.num_pieces())
{
seed = true;
char const* p = pieces->string_ptr();
for (int i = 0; i < pieces->string_length(); ++i)
{
if ((p[i] & 1) == 1) continue;
seed = false;
break;
}
}
}
else
{
error = errors::missing_pieces;
return false;
}
int flags = (settings().ignore_resume_timestamps ? ignore_timestamps : 0);
return true;
}