本文整理汇总了C++中ObjectEntry::GetKey方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectEntry::GetKey方法的具体用法?C++ ObjectEntry::GetKey怎么用?C++ ObjectEntry::GetKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectEntry
的用法示例。
在下文中一共展示了ObjectEntry::GetKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddObjectEntry
static nsresult
SetOrRemoveObject(PLDHashTable& table, nsIContent* aKey, nsISupports* aValue)
{
if (aValue) {
// lazily create the table, but only when adding elements
if (!table.ops &&
!PL_DHashTableInit(&table, &ObjectTableOps, nullptr,
sizeof(ObjectEntry), 16)) {
table.ops = nullptr;
return NS_ERROR_OUT_OF_MEMORY;
}
aKey->SetFlags(NODE_MAY_BE_IN_BINDING_MNGR);
return AddObjectEntry(table, aKey, aValue);
}
// no value, so remove the key from the table
if (table.ops) {
ObjectEntry* entry =
static_cast<ObjectEntry*>
(PL_DHashTableOperate(&table, aKey, PL_DHASH_LOOKUP));
if (entry && PL_DHASH_ENTRY_IS_BUSY(entry)) {
// Keep key and value alive while removing the entry.
nsCOMPtr<nsISupports> key = entry->GetKey();
nsCOMPtr<nsISupports> value = entry->GetValue();
RemoveObjectEntry(table, aKey);
}
}
return NS_OK;
}
示例2:
// helper routine for adding a new entry
static nsresult
AddObjectEntry(PLDHashTable& table, nsISupports* aKey, nsISupports* aValue)
{
NS_ASSERTION(aKey, "key must be non-null");
if (!aKey) return NS_ERROR_INVALID_ARG;
ObjectEntry *entry =
static_cast<ObjectEntry*>
(PL_DHashTableOperate(&table, aKey, PL_DHASH_ADD));
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;
// only add the key if the entry is new
if (!entry->GetKey())
entry->SetKey(aKey);
// now attach the new entry - note that entry->mValue could possibly
// have a value already, this will release that.
entry->SetValue(aValue);
return NS_OK;
}