hxsym_leaveutil.h

来自「symbian 下的helix player源代码」· C头文件 代码 · 共 150 行

H
150
字号
/************************************************************************
 * hxsym_leaveutil.h.
 * -------------
 *
 * Synopsis:
 *
 *
 * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
 *
 ************************************************************************/


#ifndef hxsym_leaveutil_h
#define hxsym_leaveutil_h

// sdk includes
#include <e32std.h>

// helix includes
#include "hxassert.h"

//
// XXXLCM
//
// In some instances gcc appends an underscore to symbol names that
// externally reference the first member of a namespace if that member
// is a function. That is, in object files that reference the function 
// the symbol name has a trailing underscore appended to it; in the object
// file that defines the function, the symbol name does not have the trailing
// underscore in its name.
//
// This works around that by declaring a bogus, unlikely name as the
// first member.
//
#define NAMESPACE_FIRST_MEMBER_FIX void englebert_humperdinck();

namespace hxsym
{
NAMESPACE_FIRST_MEMBER_FIX

void DoLeaveErrorMsgL(const char* pszFile, int line, TInt err);

inline
void Leave(TInt err, const char* pszFile, int line)
{
    DoLeaveErrorMsgL(pszFile, line, err);
    User::Leave(err);
}

inline
void LeaveIfError(TInt err, const char* pszFile, int line)
{
    if( KErrNone != err )
    {
        Leave(err, pszFile, line);
    }
}

inline 
void LeaveIfFalse(bool cond, const char* pszFile, int line)
{
    HX_ASSERT(cond);
    if(!cond)
    {
	Leave(KErrGeneral, pszFile, line);
    }
}

inline
void LeaveIfTrue(bool cond, const char* pszFile, int line)
{
    LeaveIfFalse(!cond, pszFile, line);
}


} // ns hxsym

#define HXSYM_LEAVE(err)            hxsym::Leave(err, __FILE__, __LINE__)
#define HXSYM_LEAVE_IF_ERR(err)     hxsym::LeaveIfError(err, __FILE__, __LINE__)
#define HXSYM_LEAVE_IF_TRUE(cond)   hxsym::LeaveIfTrue(cond, __FILE__, __LINE__)
#define HXSYM_LEAVE_IF_FALSE(cond)  hxsym::LeaveIfFalse(cond, __FILE__, __LINE__)


#if defined(NO_LEAVE_MESSAGE) //XXXLCM support these (no message) versions as well

inline
void Leave(TInt err)
{
    User::Leave(err);
}

inline
void LeaveIfError(TInt err)
{
    HX_ASSERT(err != KErrNone);
    User::LeaveIfError(err);
}

inline
void LeaveIfTrue(bool cond)
{
    LeaveIfFalse(!cond);
}

inline
void LeaveIfFalse(bool cond)
{
    HX_ASSERT(cond);
    if(!cond)
    {
	User::Leave(KErrGeneral);
    }
}


///////////////////////////////////


/*
template<class T>
inline
T* LeaveIfNull(T *p)
{
    HX_ASSERT(p != 0);
    User::LeaveIfNull(p);
    return p;
}

template<class T>
inline
const T* LeaveIfNull(const T *p)
{
    HX_ASSERT(p != 0);
    User::LeaveIfNull(p);
    return p;
}


*/


#define HXSYM_LEAVE(err)            hxsym::Leave(err)
#define HXSYM_LEAVE_IF_ERR(err)     hxsym::LeaveIfError(err)
#define HXSYM_LEAVE_IF_TRUE(cond)   hxsym::LeaveIfTrue(cond)
#define HXSYM_LEAVE_IF_FALSE(cond)  hxsym::LeaveIfFalse(cond)

#endif // NO_LEAVE_MESSAGE

#endif //hxsym_leaveutil_h

⌨️ 快捷键说明

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