本文整理汇总了C++中QCache::setAutoDelete方法的典型用法代码示例。如果您正苦于以下问题:C++ QCache::setAutoDelete方法的具体用法?C++ QCache::setAutoDelete怎么用?C++ QCache::setAutoDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCache
的用法示例。
在下文中一共展示了QCache::setAutoDelete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fni
FileDef *findFileDef(const FileNameDict *fnDict,const char *n,bool &ambig)
{
ambig=FALSE;
if (n==0) return 0;
const int maxAddrSize = 20;
char addr[maxAddrSize];
qsnprintf(addr,maxAddrSize,"%p:",fnDict);
QCString key = addr;
key+=n;
g_findFileDefCache.setAutoDelete(TRUE);
FindFileCacheElem *cachedResult = g_findFileDefCache.find(key);
//printf("key=%s cachedResult=%p\n",key.data(),cachedResult);
if (cachedResult)
{
ambig = cachedResult->isAmbig;
//printf("cached: fileDef=%p\n",cachedResult->fileDef);
return cachedResult->fileDef;
}
else
{
cachedResult = new FindFileCacheElem(0,FALSE);
}
QCString name=QDir::cleanDirPath(n).utf8();
QCString path;
int slashPos;
FileName *fn;
if (name.isEmpty()) goto exit;
slashPos=QMAX(name.findRev('/'),name.findRev('\\'));
if (slashPos!=-1)
{
path=name.left(slashPos+1);
name=name.right(name.length()-slashPos-1);
//printf("path=%s name=%s\n",path.data(),name.data());
}
if (name.isEmpty()) goto exit;
if ((fn=(*fnDict)[name]))
{
//printf("fn->count()=%d\n",fn->count());
if (fn->count()==1)
{
FileDef *fd = fn->getFirst();
#if defined(_WIN32) || defined(__MACOSX__) // Windows or MacOSX
bool isSamePath = fd->getPath().right(path.length()).lower()==path.lower();
#else // Unix
bool isSamePath = fd->getPath().right(path.length())==path;
#endif
if (path.isEmpty() || isSamePath)
{
cachedResult->fileDef = fd;
g_findFileDefCache.insert(key,cachedResult);
//printf("=1 ===> add to cache %p\n",fd);
return fd;
}
}
else // file name alone is ambiguous
{
int count=0;
FileNameIterator fni(*fn);
FileDef *fd;
FileDef *lastMatch=0;
QCString pathStripped = path;
for (fni.toFirst();(fd=fni.current());++fni)
{
QCString fdStripPath = fd->getPath();
if (path.isEmpty() || fdStripPath.right(pathStripped.length())==pathStripped)
{
count++;
lastMatch=fd;
}
}
//printf(">1 ===> add to cache %p\n",fd);
ambig=(count>1);
cachedResult->isAmbig = ambig;
cachedResult->fileDef = lastMatch;
g_findFileDefCache.insert(key,cachedResult);
return lastMatch;
}
}
else
{
//printf("not found!\n");
}
exit:
//printf("0 ===> add to cache %p: %s\n",cachedResult,n);
g_findFileDefCache.insert(key,cachedResult);
//delete cachedResult;
return 0;
}