本文整理汇总了C++中nsTHashtable::GetEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ nsTHashtable::GetEntry方法的具体用法?C++ nsTHashtable::GetEntry怎么用?C++ nsTHashtable::GetEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsTHashtable
的用法示例。
在下文中一共展示了nsTHashtable::GetEntry方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nsTIterPrint
void
testTHashtable(nsTHashtable<EntityToUnicodeEntry>& hash, uint32_t numEntries) {
uint32_t i;
for (i = 0; i < numEntries; ++i) {
EntityToUnicodeEntry* entry =
hash.PutEntry(gEntities[i].mStr);
EXPECT_TRUE(entry);
EXPECT_FALSE(entry->mNode);
entry->mNode = &gEntities[i];
}
for (i = 0; i < numEntries; ++i) {
EntityToUnicodeEntry* entry =
hash.GetEntry(gEntities[i].mStr);
EXPECT_TRUE(entry);
}
EntityToUnicodeEntry* entry =
hash.GetEntry("xxxy");
EXPECT_FALSE(entry);
uint32_t count = nsTIterPrint(hash);
EXPECT_EQ(count, numEntries);
}
示例2: printf
void
testTHashtable(nsTHashtable<EntityToUnicodeEntry>& hash, uint32_t numEntries) {
printf("Filling hash with %d entries.\n", numEntries);
uint32_t i;
for (i = 0; i < numEntries; ++i) {
printf(" Putting entry \"%s\"...", gEntities[i].mStr);
EntityToUnicodeEntry* entry =
hash.PutEntry(gEntities[i].mStr);
if (!entry) {
printf("FAILED\n");
exit (2);
}
printf("OK...");
if (entry->mNode) {
printf("entry already exists!\n");
exit (3);
}
printf("\n");
entry->mNode = &gEntities[i];
}
printf("Testing Get:\n");
for (i = 0; i < numEntries; ++i) {
printf(" Getting entry \"%s\"...", gEntities[i].mStr);
EntityToUnicodeEntry* entry =
hash.GetEntry(gEntities[i].mStr);
if (!entry) {
printf("FAILED\n");
exit (4);
}
printf("Found %u\n", entry->mNode->mUnicode);
}
printf("Testing nonexistent entries...");
EntityToUnicodeEntry* entry =
hash.GetEntry("xxxy");
if (entry) {
printf("FOUND! BAD!\n");
exit (5);
}
printf("not found; good.\n");
printf("Enumerating:\n");
uint32_t count = hash.EnumerateEntries(nsTEnumGo, nullptr);
if (count != numEntries) {
printf(" Bad count!\n");
exit (6);
}
}
示例3: Free
void Free(PRUint32 aCode, void* aPtr)
{
// Try to recycle this entry.
FreeList* list = mFreeLists.GetEntry(aCode);
NS_ABORT_IF_FALSE(list, "no free list for pres arena object");
NS_ABORT_IF_FALSE(list->mEntrySize > 0, "PresArena cannot free zero bytes");
char* p = reinterpret_cast<char*>(aPtr);
char* limit = p + list->mEntrySize;
for (; p < limit; p += sizeof(PRUword)) {
*reinterpret_cast<PRUword*>(p) = ARENA_POISON;
}
list->mEntries.AppendElement(aPtr);
}
示例4: curName
// recursively check a directory tree for files not in the list of
// verified files we found in the manifest. For each file we find
// Check it against the files found in the manifest. If the file wasn't
// in the manifest then it's unsigned and we can stop looking. Otherwise
// remove it from the collection so we can check leftovers later.
//
// @param aDir Directory to check
// @param aPath Relative path to that directory (to check against aItems)
// @param aItems All the files found
// @param *Filename signature files that won't be in the manifest
nsresult
CheckDirForUnsignedFiles(nsIFile* aDir,
const nsString& aPath,
/* in/out */ nsTHashtable<nsStringHashKey>& aItems,
const nsAString& sigFilename,
const nsAString& sfFilename,
const nsAString& mfFilename)
{
nsCOMPtr<nsISimpleEnumerator> entries;
nsresult rv = aDir->GetDirectoryEntries(getter_AddRefs(entries));
nsCOMPtr<nsIDirectoryEnumerator> files = do_QueryInterface(entries);
if (NS_FAILED(rv) || !files) {
return NS_ERROR_SIGNED_JAR_ENTRY_MISSING;
}
bool inMeta = StringBeginsWith(aPath, NS_LITERAL_STRING(JAR_META_DIR));
while (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIFile> file;
rv = files->GetNextFile(getter_AddRefs(file));
if (NS_FAILED(rv) || !file) {
break;
}
nsAutoString leafname;
rv = file->GetLeafName(leafname);
if (NS_FAILED(rv)) {
return rv;
}
nsAutoString curName(aPath + leafname);
bool isDir;
rv = file->IsDirectory(&isDir);
if (NS_FAILED(rv)) {
return rv;
}
// if it's a directory we need to recurse
if (isDir) {
curName.Append(NS_LITERAL_STRING("/"));
rv = CheckDirForUnsignedFiles(file, curName, aItems,
sigFilename, sfFilename, mfFilename);
} else {
// The files that comprise the signature mechanism are not covered by the
// signature.
//
// XXX: This is OK for a single signature, but doesn't work for
// multiple signatures because the metadata for the other signatures
// is not signed either.
if (inMeta && ( leafname == sigFilename ||
leafname == sfFilename ||
leafname == mfFilename )) {
continue;
}
// make sure the current file was found in the manifest
nsStringHashKey* item = aItems.GetEntry(curName);
if (!item) {
return NS_ERROR_SIGNED_JAR_UNSIGNED_ENTRY;
}
// Remove the item so we can check for leftover items later
aItems.RemoveEntry(item);
}
}
files->Close();
return rv;
}