本文整理汇总了C++中Download::contents方法的典型用法代码示例。如果您正苦于以下问题:C++ Download::contents方法的具体用法?C++ Download::contents怎么用?C++ Download::contents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Download
的用法示例。
在下文中一共展示了Download::contents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fetch
void Import::fetch()
{
if(m_download)
return;
auto_string url(4096, 0);
GetWindowText(m_url, &url[0], (int)url.size());
// remove extra nulls from the string
url.resize(url.find(AUTO_STR('\0')));
if(url.empty()) {
close();
return;
}
setWaiting(true);
Download *dl = m_download = new Download({}, from_autostring(url));
dl->onFinish([=] {
const Download::State state = dl->state();
if(state == Download::Aborted) {
// at this point `this` is deleted, so there is nothing else
// we can do without crashing
return;
}
setWaiting(false);
if(state != Download::Success) {
const string msg = "Download failed: " + dl->contents();
MessageBox(handle(), make_autostring(msg).c_str(), TITLE, MB_OK);
SetFocus(m_url);
return;
}
if(!import())
SetFocus(m_url);
});
dl->setCleanupHandler([=] {
// if we are still alive
if(dl->state() != Download::Aborted)
m_download = nullptr;
delete dl;
});
dl->start();
}