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

📄 cpgpcontext.h

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 H
字号:
/*____________________________________________________________________________
		Copyright (C) 2002 PGP Corporation
        All rights reserved.

        $Id: CPGPContext.h,v 1.2 2002/08/06 20:10:19 dallen Exp $
____________________________________________________________________________*/

#ifndef Included_CPGPContext_h	// [
#define Included_CPGPContext_h

#include "pgpUtilities.h"

_PGP_BEGIN

// Class CPGPContext

class CPGPContext
{
	NOT_COPYABLE(CPGPContext)

public:
	CPGPContext();
	CPGPContext(PGPContextRef pgpContext);

	~CPGPContext();

	operator PGPContextRef() const {return mPGPContext;}
	CPGPContext&	operator=(PGPContextRef pgpContext);

	PGPContextRef	Get() const {return mPGPContext;}

	PGPBoolean	IsAttached() const;
	PGPBoolean	WeCreated() const {return mWeCreated;}

	void	Attach(PGPContextRef pgpContext);
	void	Create();
	void	Clear();

private:
	PGPBoolean		mWeCreated;
	PGPContextRef	mPGPContext;
};


// Class CPGPContext member functions

inline 
CPGPContext::CPGPContext() :
	mWeCreated(FALSE), mPGPContext(kInvalidPGPContextRef)
{
}

inline 
CPGPContext::CPGPContext(PGPContextRef pgpContext) :
	mWeCreated(FALSE), mPGPContext(kInvalidPGPContextRef)
{
	Attach(pgpContext);
}

inline 
CPGPContext::~CPGPContext()
{
	Clear();
}

inline 
CPGPContext& 
CPGPContext::operator=(PGPContextRef pgpContext)
{
	Attach(pgpContext);
	return *this;
}

inline 
PGPBoolean 
CPGPContext::IsAttached() const
{
	return PGPContextRefIsValid(mPGPContext);
}

inline 
void 
CPGPContext::Attach(PGPContextRef pgpContext)
{
	if (mPGPContext == pgpContext)
		return;

	Clear();
	pgpAssert(PGPContextRefIsValid(pgpContext));

	mPGPContext = pgpContext;
	mWeCreated = FALSE;
}

inline 
void 
CPGPContext::Create()
{
	Clear();

	PGPError	pgpErr	= PGPNewContext(kPGPsdkAPIVersion, &mPGPContext);
	THROW_IF_PGPERROR(pgpErr);

	mWeCreated = TRUE;
}

inline 
void 
CPGPContext::Clear()
{
	if (WeCreated())
		PGPFreeContext(mPGPContext);

	mWeCreated = FALSE;
	mPGPContext = kInvalidPGPContextRef;
}

_PGP_END

#endif	// ] Included_CPGPContext_h

⌨️ 快捷键说明

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