高手出马啦,关于C++迭代器的问题,折腾我一上午,急啊,编译环境VS2005
高手出马啦,关于C++迭代器的问题:耐心看啊,代码有点长,编译环境VS2005
先给出错误,链接不到函数
1>NetworkOperationRunnable.obj : error LNK2019: 无法解析的外部符号 "public: bool __cdecl NetworkLinkCollection::downloadBook(class BookReference const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class ZLNetworkSSLCertificate const &,class shared_ptr<class ZLExecutionData::Listener>)" (?downloadBook@NetworkLinkCollection@@QAA_NABVBookReference@@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABVZLNetworkSSLCertificate@@V?$shared_ptr@VListener@ZLExecutionData@@@@@Z),该符号在函数 "public: virtual void __cdecl DownloadBookRunnable::run(void)" (?run@DownloadBookRunnable@@UAAXXZ) 中被引用
class NetworkLinkCollection {
private:
class Comparator;
public:
static NetworkLinkCollection &Instance();
private:
static NetworkLinkCollection *ourInstance;
public:
ZLStringOption DirectoryOption;
private:
NetworkLinkCollection();
~NetworkLinkCollection();
public:
std::string bookFileName(const BookReference &reference) const;
std::string makeBookFileName(const BookReference &reference);
bool downloadBook(const BookReference &reference, std::string &fileName, const ZLNetworkSSLCertificate &sslSertificate, shared_ptr<ZLExecutionData::Listener> listener);
shared_ptr<NetworkBookCollection> simpleSearch(const std::string &pattern);
shared_ptr<NetworkBookCollection> advancedSearch(const std::string &titleAndSeries, const std::string &author, const std::string &tag, const std::string &annotation);
size_t size() const;
size_t numberOfEnabledLinks() const;
NetworkLink &link(size_t index) const;
const std::string &errorMessage() const;
void rewriteUrl(std::string &url, bool externalUrl = false) const;
private:
std::string makeBookFileName(const std::string &url, BookReference::Format format, BookReference::Type type, bool createDirectories);
private:
typedef std::vector<shared_ptr<NetworkLink> > LinkVector;
LinkVector myLinks;
std::string myErrorMessage;
};
downloadBook函数原型(确认已经加入到工程)
bool NetworkLinkCollection::downloadBook(const BookReference &reference, std::string &fileName, const ZLNetworkSSLCertificate &sslCertificate, shared_ptr<ZLExecutionData::Listener> listener) {
std::string nURL = ::normalize(reference.URL);
rewriteUrl(nURL);
const std::string nNetworkBookId = ::normalize(reference.cleanURL());
const ZLResource &errorResource = ZLResource::resource("dialog")["networkError"];
myErrorMessage.clear();
if (nURL.empty() || nNetworkBookId.empty()) {
myErrorMessage = errorResource["unknownErrorMessage"].value();
return false;
}
std::string storedFileName = BooksDB::Instance().getNetFile(nNetworkBookId);
if (!storedFileName.empty() && ZLFile(storedFileName).exists()) {
fileName = storedFileName;
return true;
}
fileName = makeBookFileName(nNetworkBookId, reference.BookFormat, reference.ReferenceType, true);
if (fileName.empty()) {
if (myErrorMessage.empty()) {
myErrorMessage = errorResource["unknownErrorMessage"].value();
}
return false;
}
if (ZLFile(fileName).exists()) {
ZLFile(fileName).remove();
}
myErrorMessage = ZLNetworkManager::Instance().downloadFile(nURL, sslCertificate, fileName, listener);
if (!myErrorMessage.empty()) {
return false;
}
BooksDB::Instance().setNetFile(nNetworkBookId, fileName);
return true;
}
NetworkLinkCollection &NetworkLinkCollection::Instance() {
if (ourInstance == 0) {
ourInstance = new NetworkLinkCollection();
}
return *ourInstance;
}
class DownloadBookRunnable : public NetworkOperationRunnable {
public:
DownloadBookRunnable(shared_ptr<BookReference> reference, shared_ptr<NetworkAuthenticationManager> authManager);
DownloadBookRunnable(const std::string &url);
~DownloadBookRunnable();
void run();
const std::string &fileName() const;
private:
shared_ptr<BookReference> myReference;
shared_ptr<NetworkAuthenticationManager> myAuthManager;
std::string myFileName;
};
void DownloadBookRunnable::run() {
NetworkLinkCollection::Instance().downloadBook(
*myReference, myFileName,
myAuthManager.isNull() ? ZLNetworkSSLCertificate::NULL_CERTIFICATE : myAuthManager->certificate(),
myDialog->listener()
);//就这里链接不过啊,真气人
myErrorMessage = NetworkLinkCollection::Instance().errorMessage();
}