各种一些宏的注释

来源:互联网 发布:伊势神宫 知乎 编辑:程序博客网 时间:2024/05/22 04:39
2010-01-14 19:06
//这个是用来返回一个错误的消息,并终止程序;
#define RERR( )               \
{                             \
ASSERT( 0 );              \
return ERR_CLASS::m_nERR; \
}

//判断exp是否为0,若为0则终止程序
#define ROF( exp )            \
{                             \
if( !( exp ) )              \
{                           \
RERR();                   \
}                           \
}

//判断exp是否为0,若非0则终止程序
#define ROT( exp )            \
{                             \
if( ( exp ) )               \
{                           \
RERR();                    \
}                           \
}

//只是返回错误值,但并不终止
#define RERRS( )               \
{                             \
return ERR_CLASS::m_nERR;     \
}

//判断是否为0,若为0则返回错误的信息,但并不终止
#define ROFS( exp )           \
{                             \
if( !( exp ) )              \
{                           \
RERRS();                  \
}                           \
}

//判断是否为非0,若是非0则返回错误的信息,不终止
#define ROTS( exp )           \
{                             \
if( ( exp ) )               \
{                           \
RERRS();                  \
}                           \
}

//返回retVal值,并终止程序
#define RVAL( retVal )        \
{                             \
ASSERT( 0 );              \
return retVal;            \
}

//在exp为0时返回retVal值,并终止程序
#define ROFR( exp, retVal )   \
{                             \
if( !( exp ) )              \
{                           \
RVAL( retVal );           \
}                           \
}


//在exp为1时返回retVal值,并终止程序
#define ROTR( exp, retVal )   \
{                             \
if( ( exp ) )               \
{                           \
RVAL( retVal );             \
}                           \
}

//在exp为0时返回retVal,但并不终止程序
#define ROFRS( exp, retVal )  \
{                             \
if( !( exp ) )              \
{                           \
return retVal;            \
}                           \
}

//在exp为非0时返回retVal
#define ROTRS( exp, retVal )  \
{                             \
if( ( exp ) )               \
{                           \
return retVal;            \
}                           \
}

//在exp为0时终止程序,不返回任何值
#define ROFV( exp )           \
{                             \
if( !( exp ) )              \
{                           \
ASSERT( 0 );              \
return;                   \
}                           \
}

//在exp为非0时终止程序,不返回任何值
#define ROTV( exp )           \
{                             \
if( ( exp ) )               \
{                           \
ASSERT( 0 );              \
return;                   \
}                           \
}

//exp为0时返回,不返回任何值
#define ROFVS( exp )          \
{                             \
if( !( exp ) )              \
{                           \
return;                   \
}                           \
}

//exp为非0时返回,不返回任何值
#define ROTVS( exp )          \
{                             \
if( ( exp ) )               \
{                           \
return;                   \
}                           \
}

//判断nMSysRetVal=exp是否为m_nOK,若不相等则终止程序,返回nMSysRetVal
#define RNOK( exp )               \
{                                 \
const ERR_VAL nMSysRetVal = ( exp );   \
if( ERR_CLASS::m_nOK != nMSysRetVal )  \
{                               \
ASSERT( 0 );                  \
return nMSysRetVal;                  \
}                               \
}


//在exp和m_nOK不相等时,则终止程序,并返回retVal
#define RNOKR( exp, retVal )        \
{                                   \
if( ERR_CLASS::m_nOK != ( exp ) ) \
{                                 \
ASSERT( 0 );                    \
return retVal;                  \
}                                 \
}

//判断exp是否为m_nOK,若不是,则返回其值
#define RNOKS( exp )                \
{                                   \
const ERR_VAL nMSysRetVal = ( exp );     \
if( ERR_CLASS::m_nOK != nMSysRetVal )    \
{                                 \
return nMSysRetVal;             \
}                                 \
}

//在m_nOK != ( exp )时返回retVal
#define RNOKRS( exp, retVal )       \
{                                   \
if( ERR_CLASS::m_nOK != ( exp ) ) \
{                                 \
return retVal;                  \
}                                 \
}

//m_nOK != ( exp )时终止程序,没有返回值
#define RNOKV( exp )                \
{                                   \
if( ERR_CLASS::m_nOK != ( exp ) ) \
{                                 \
ASSERT( 0 );                    \
return;                         \
}                                 \
}

//m_nOK != ( exp )时返回
#define RNOKVS( exp )               \
{                                   \
if( ERR_CLASS::m_nOK != ( exp ) ) \
{                                 \
return;                         \
}                                 \
}

//终止程序
#define AF( )                 \
{                             \
ASSERT( 0 );              \
}

//m_nOK != ( exp )时终止程序
#define ANOK( exp )                 \
{                                   \
if( ERR_CLASS::m_nOK != ( exp ) ) \
{                                 \
ASSERT( 0 );                    \
}                                 \
}

//exp为0时终止程序
#define AOF( exp )                  \
{                                   \
if( !( exp ) )                    \
{                                 \
ASSERT( 0 );                    \
}                                 \
}

//exp非0时终止
#define AOT( exp )            \
{                             \
if( ( exp ) )               \
{                           \
ASSERT( 0 );              \
}                           \
}