⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpgpkeydb.h

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 H
📖 第 1 页 / 共 2 页
字号:
void 
CPGPKeySet::Attach(PGPKeySetRef keySet, PGPBoolean weOwn)
{
	if (mKeySet == keySet)
		return;

	pgpAssert(PGPKeySetRefIsValid(keySet));
	Clear();

	mWeCreated = weOwn;
	mKeySet = keySet;
}

inline 
void 
CPGPKeySet::Clear()
{
	if (WeCreated())
		PGPFreeKeySet(mKeySet);

	mWeCreated = FALSE;
	mKeySet = kInvalidPGPKeySetRef;
}


// Class CPGPKeyList member functions

inline 
CPGPKeyList::CPGPKeyList(PGPKeySetRef keySet, PGPKeyOrdering ordering) :
	mWeCreated(FALSE), mKeyList(kInvalidPGPKeyListRef)
{
	Assign(keySet, ordering);
}

inline 
CPGPKeyList::CPGPKeyList(PGPKeyListRef keyList) : 
	mWeCreated(FALSE), mKeyList(kInvalidPGPKeyListRef)
{
	Attach(keyList);
}

inline 
CPGPKeyList::~CPGPKeyList()
{
	try
	{
		Clear();
	}
	catch (CComboError&) { }
}

inline 
CPGPKeyList& 
CPGPKeyList::operator=(PGPKeyListRef keyList)
{
	Attach(keyList);
	return *this;
}

inline 
PGPBoolean 
CPGPKeyList::IsAttached() const
{
	return PGPKeyListRefIsValid(mKeyList);
}

inline 
void 
CPGPKeyList::Assign(PGPKeySetRef keySet, PGPKeyOrdering ordering)
{
	pgpAssert(PGPKeySetRefIsValid(keySet));
	Clear();

	PGPError	pgpErr	= PGPOrderKeySet(keySet, ordering, 
		FALSE, &mKeyList);
	THROW_IF_PGPERROR(pgpErr);

	mWeCreated = TRUE;
}

inline 
void 
CPGPKeyList::Attach(PGPKeyListRef keyList)
{
	if (mKeyList == keyList)
		return;

	pgpAssert(PGPKeyListRefIsValid(keyList));
	Clear();

	mWeCreated = FALSE;
	mKeyList = keyList;
}

inline 
void 
CPGPKeyList::Clear()
{
	if (WeCreated())
		PGPFreeKeyList(mKeyList);

	mWeCreated = FALSE;
	mKeyList = kInvalidPGPKeyListRef;
}


// Class CPGPKeyIter member functions

inline 
CPGPKeyIter::CPGPKeyIter(PGPKeyListRef keyList) : 
	mWeCreated(FALSE), mKeyIter(kInvalidPGPKeyIterRef)
{
	Assign(keyList);
}

inline 
CPGPKeyIter::CPGPKeyIter(PGPKeyIterRef keyIter) : 
	mWeCreated(FALSE), mKeyIter(kInvalidPGPKeyIterRef)
{
	Attach(keyIter);
}

inline 
CPGPKeyIter::~CPGPKeyIter()
{
	try
	{
		Clear();
	}
	catch (CComboError&) { }
}

inline 
CPGPKeyIter& 
CPGPKeyIter::operator=(PGPKeyIterRef keyIter)
{
	Attach(keyIter);
	return *this;
}

inline 
PGPBoolean 
CPGPKeyIter::IsAttached() const
{
	return PGPKeyIterRefIsValid(mKeyIter);
}

inline 
void 
CPGPKeyIter::Key(CPGPKey& key) const
{
	pgpAssert(IsAttached());

	PGPError	pgpErr	= PGPKeyIterGetKeyDBObj(mKeyIter, 
		kPGPKeyDBObjType_Key, &key.mKeyDBObj);
	THROW_IF_PGPERROR(pgpErr);
}

inline 
void 
CPGPKeyIter::SubKey(CPGPKey& subKey) const
{
	pgpAssert(IsAttached());

	PGPError	pgpErr	= PGPKeyIterGetKeyDBObj(mKeyIter, 
		kPGPKeyDBObjType_SubKey, &subKey.mKeyDBObj);
	THROW_IF_PGPERROR(pgpErr);
}

inline 
PGPUInt32 
CPGPKeyIter::Index() const
{
	return PGPKeyIterIndex(mKeyIter);
}

inline 
void 
CPGPKeyIter::Copy(CPGPKeyIter& keyIter) const
{
	pgpAssert(IsAttached());

	PGPError	pgpErr	= PGPCopyKeyIter(mKeyIter, &keyIter.mKeyIter);
	THROW_IF_PGPERROR(pgpErr);
}

inline 
PGPInt32 
CPGPKeyIter::Seek(PGPKeyDBObjRef key) const
{
	pgpAssert(IsAttached());
	return PGPKeyIterSeek(mKeyIter, key);
}

inline 
PGPBoolean 
CPGPKeyIter::Move(PGPInt32 relOffset, CPGPKey& key) const
{
	pgpAssert(IsAttached());

	PGPKeyDBObjRef	keyRef;
	PGPError		pgpErr	= PGPKeyIterMove(mKeyIter, relOffset, &keyRef);

	if (pgpErr == kPGPError_EndOfIteration)
		return FALSE;

	THROW_IF_PGPERROR(pgpErr);

	key.mKeyDBObj = keyRef;
	return TRUE;
}

inline 
PGPBoolean 
CPGPKeyIter::Next(CPGPKey& key) const
{
	pgpAssert(IsAttached());

	PGPKeyDBObjRef	keyRef;
	PGPError		pgpErr	= PGPKeyIterNextKeyDBObj(mKeyIter, 
		kPGPKeyDBObjType_Key, &keyRef);

	if (pgpErr == kPGPError_EndOfIteration)
		return FALSE;

	THROW_IF_PGPERROR(pgpErr);

	key.mKeyDBObj = keyRef;
	return TRUE;
}

inline 
PGPBoolean 
CPGPKeyIter::NextSubKey(CPGPKey& subKey) const
{
	pgpAssert(IsAttached());

	PGPKeyDBObjRef	subKeyRef;
	PGPError		pgpErr	= PGPKeyIterNextKeyDBObj(mKeyIter, 
		kPGPKeyDBObjType_SubKey, &subKeyRef);

	if (pgpErr == kPGPError_EndOfIteration)
		return FALSE;

	THROW_IF_PGPERROR(pgpErr);

	subKey.mKeyDBObj = subKeyRef;
	return TRUE;
}

inline 
PGPBoolean 
CPGPKeyIter::Prev(CPGPKey& key) const
{
	pgpAssert(IsAttached());

	PGPKeyDBObjRef	keyRef;
	PGPError		pgpErr	= PGPKeyIterPrevKeyDBObj(mKeyIter, 
		kPGPKeyDBObjType_Key, &keyRef);

	if (pgpErr == kPGPError_EndOfIteration)
		return FALSE;

	THROW_IF_PGPERROR(pgpErr);

	key.mKeyDBObj = keyRef;
	return TRUE;
}

inline 
PGPBoolean 
CPGPKeyIter::PrevSubKey(CPGPKey& subKey) const
{
	pgpAssert(IsAttached());

	PGPKeyDBObjRef	subKeyRef;
	PGPError		pgpErr	= PGPKeyIterPrevKeyDBObj(mKeyIter, 
		kPGPKeyDBObjType_SubKey, &subKeyRef);

	if (pgpErr == kPGPError_EndOfIteration)
		return FALSE;

	THROW_IF_PGPERROR(pgpErr);

	subKey.mKeyDBObj = subKeyRef;
	return TRUE;
}

inline 
void 
CPGPKeyIter::Rewind() const
{
	pgpAssert(IsAttached());

	PGPError	pgpErr	= PGPKeyIterRewind(mKeyIter, kPGPKeyDBObjType_Key);
	THROW_IF_PGPERROR(pgpErr);
}

inline 
void 
CPGPKeyIter::RewindSubKey() const
{
	pgpAssert(IsAttached());

	PGPError	pgpErr	= PGPKeyIterRewind(mKeyIter, kPGPKeyDBObjType_SubKey);
	THROW_IF_PGPERROR(pgpErr);
}

inline 
void 
CPGPKeyIter::Assign(PGPKeyListRef keyList)
{
	pgpAssert(PGPKeyListRefIsValid(keyList));
	Clear();

	PGPError	pgpErr	= PGPNewKeyIter(keyList, &mKeyIter);
	THROW_IF_PGPERROR(pgpErr);

	mWeCreated = TRUE;
}

inline 
void 
CPGPKeyIter::Attach(PGPKeyIterRef keyIter)
{
	if (mKeyIter == keyIter)
		return;

	pgpAssert(PGPKeyIterRefIsValid(keyIter));
	Clear();

	mWeCreated = FALSE;
	mKeyIter = keyIter;
}

inline 
void 
CPGPKeyIter::Clear()
{
	if (WeCreated())
		PGPFreeKeyIter(mKeyIter);

	mWeCreated = FALSE;
	mKeyIter = kInvalidPGPKeyIterRef;
}


// Class CPGPFilter member functions

inline 
CPGPFilter::CPGPFilter() :
	mWeCreated(FALSE), mFilter(kInvalidPGPFilterRef)
{
}

inline 
CPGPFilter::CPGPFilter(PGPFilterRef filter) :
	mWeCreated(FALSE), mFilter(kInvalidPGPFilterRef)
{
	Attach(filter);
}

inline 
CPGPFilter::~CPGPFilter()
{
	try
	{
		Clear();
	}
	catch (CComboError&) { }
}

inline 
CPGPFilter& 
CPGPFilter::operator=(PGPFilterRef filter)
{
	Attach(filter);
	return *this;
}

inline 
PGPBoolean 
CPGPFilter::IsAttached() const
{
	return PGPFilterRefIsValid(mFilter);
}

inline 
void 
CPGPFilter::Intersect(CPGPFilter& filter)
{
	pgpAssert(IsAttached());

	PGPError	pgpErr	= PGPIntersectFilters(mFilter, filter, 
		&mFilter);
	THROW_IF_PGPERROR(pgpErr);

	filter.mWeCreated = FALSE;
	filter.mFilter = kInvalidPGPFilterRef;
}

inline 
void 
CPGPFilter::Union(CPGPFilter& filter)
{
	pgpAssert(IsAttached());

	PGPError	pgpErr	= PGPUnionFilters(mFilter, filter, 
		&mFilter);
	THROW_IF_PGPERROR(pgpErr);

	mWeCreated = TRUE;

	filter.mWeCreated = FALSE;
	filter.mFilter = kInvalidPGPFilterRef;
}

inline 
void 
CPGPFilter::Attach(PGPFilterRef filter)
{
	if (mFilter == filter)
		return;

	Clear();
	pgpAssert(PGPFilterRefIsValid(filter));

	mWeCreated = FALSE;
	mFilter = kInvalidPGPFilterRef;
}

inline 
void 
CPGPFilter::NewBooleanFilter(
	PGPContextRef		context, 
	PGPKeyDBObjProperty	whichProperty, 
	PGPBoolean			match)
{
	pgpAssert(PGPContextRefIsValid(context));

	Clear();

	PGPError	pgpErr	= PGPNewKeyDBObjBooleanFilter(context, 
		whichProperty, match, &mFilter);
	THROW_IF_PGPERROR(pgpErr);

	mWeCreated = TRUE;
}

inline 
void 
CPGPFilter::NewNumericFilter(
	PGPContextRef		context, 
	PGPKeyDBObjProperty	whichProperty, 
	PGPUInt32			matchValue, 
	PGPMatchCriterion	matchCriteria)
{
	pgpAssert(PGPContextRefIsValid(context));

	Clear();

	PGPError	pgpErr	= PGPNewKeyDBObjNumericFilter(context, 
		whichProperty, matchValue, matchCriteria, &mFilter);
	THROW_IF_PGPERROR(pgpErr);

	mWeCreated = TRUE;
}

inline 
void 
CPGPFilter::NewTimeFilter(
	PGPContextRef		context, 
	PGPKeyDBObjProperty	whichProperty, 
	PGPTime				matchValue, 
	PGPMatchCriterion	matchCriteria)
{
	pgpAssert(PGPContextRefIsValid(context));

	Clear();

	PGPError	pgpErr	= PGPNewKeyDBObjTimeFilter(context, whichProperty, 
		matchValue, matchCriteria, &mFilter);
	THROW_IF_PGPERROR(pgpErr);

	mWeCreated = TRUE;
}

inline 
void 
CPGPFilter::NewDataFilter(
	PGPContextRef		context, 
	PGPKeyDBObjProperty	whichProperty, 
	const void			*matchData, 
	PGPSize				matchDataSize, 
	PGPMatchCriterion	matchCriteria)
{
	pgpAssert(PGPContextRefIsValid(context));

	Clear();

	PGPError	pgpErr	= PGPNewKeyDBObjDataFilter(context, whichProperty, 
		matchData, matchDataSize, matchCriteria, &mFilter);
	THROW_IF_PGPERROR(pgpErr);

	mWeCreated = TRUE;
}

inline 
void 
CPGPFilter::Clear()
{
	if (WeCreated())
		PGPFreeFilter(mFilter);

	mFilter = kInvalidPGPFilterRef;
}

_PGP_END

#endif	// ] Included_CPGPKeyDB_h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -