chxavcleanupstack.h
来自「symbian 下的helix player源代码」· C头文件 代码 · 共 146 行
H
146 行
/************************************************************************
* chxavcleanupstack.h
* -------------------
*
* Synopsis:
* Helpers for simplifying use of Symbian cleanup stack. Uses automatic objects
* to facilitate push/pop/destroy of cleanup stack objects. Use macros only.
*
* Target:
* Symbian OS
*
*
* (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
*
************************************************************************/
#ifndef _chxavcleanupstack_h_
#define _chxavcleanupstack_h_
// Symbian includes...
#include <e32std.h>
#include <eikenv.h>
// Forward declarations...
class CSPushPopDelL;
class CSPushPopL;
class CSPopDelL;
class CSPopL;
// make variable name something like "csvar1424"
#define makevar_(var, line) csvar ## line
#define makevar__(line) makevar_(var, line)
//
// AUTO_PUSH_POP_DEL
//
// Use when an object needs to be pushed, then later popped and deleted on exit from a given scope.
//
#define AUTO_PUSH_POP_DEL(p) CSPushPopDelL makevar__(__LINE__) (p);
//
// AUTO_PUSH_POP
//
// Use when an object needs to be pushed, then later popped on exit from a given scope. Typical
// use case is when you are you intend to transfer ownership of a pointer (e.g., return value
// from function), in which case you do not want to delete the pointer.
//
#define AUTO_PUSH_POP(p) CSPushPopL makevar__(__LINE__) (p);
//
// AUTO_POP_DEL
//
// Use when an object needs to be popped and deleted on exit from a given scope. Typical use case
// is when you get a pointer that has already been pushed on the cleanup stack for you (e.g., after
// receiving a pointer from a function ending in LC()).
//
#define AUTO_POP_DEL(p) CSPopDelL makevar__(__LINE__) (p);
//
// AUTO_POP
//
// Use when an object needs to be popped from the cleanup stack on exit from a given scope.
//
#define AUTO_POP(p) CSPopL makevar__(__LINE__) (p);
//
// AUTO_PUSH_POP_CLOSE_DEL
//
// Use when an object needs to be auto-closed on exit from a given scope (typically use with R objects).
//
#define AUTO_PUSH_POP_CLOSE(item) CSPushPopCloseL makevar__(__LINE__) (item);
#include <stdlib.h>
// CSPushPopDelL, Use the macro only.
class CSPushPopDelL
{
public:
explicit CSPushPopDelL(CBase* p) { CleanupStack::PushL(p); }
CSPushPopDelL(TAny* p){ CleanupStack::PushL(p); };
~CSPushPopDelL() { CleanupStack::PopAndDestroy(); }
private:
void * operator new(size_t size);
};
// CSPushPopL, Use the macro only.
class CSPushPopL
{
public:
explicit CSPushPopL(CBase* p) { CleanupStack::PushL(p); }
CSPushPopL(TAny* p){ CleanupStack::PushL(p); };
~CSPushPopL() { CleanupStack::Pop(); }
private:
void * operator new(size_t size);
};
// class CSPopDelL - use macro
class CSPopDelL
{
public:
CSPopDelL(CBase* /*p*/) {/*no push*/}
CSPopDelL(TAny* /*p*/) {/*no push*/}
~CSPopDelL() { CleanupStack::PopAndDestroy();}
private:
void * operator new(size_t size); // stack only
};
// class CSPopL - use macro
class CSPopL
{
public:
CSPopL(CBase* /*p*/) {/*no push*/}
CSPopL(TAny* /*p*/) {/*no push*/}
~CSPopL() { CleanupStack::Pop(); /*no destroy*/}
private:
void * operator new(size_t size); // stack only
};
// CSPushPopCloseL, Use the macro only.
class CSPushPopCloseL
{
public:
explicit CSPushPopCloseL(RHandleBase& handle) { CleanupClosePushL(handle); }
~CSPushPopCloseL() { CleanupStack::PopAndDestroy(); /*calls Close()*/}
private:
void * operator new(size_t size);
};
#endif // _chxavcleanupstack_h_
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?