📄 wyret.h
字号:
/* Copyright is licensed under GNU LGPL. by I.J.Wang 2003 Note: If symbol WYLIB_CONFIG_NORSLI is defined, no SLI in WyRet wyr_reply.h defines WyReply wyr_ret.h defines WyRet,Wy_SrcLoc*/#ifndef WYRET_H__#define WYRET_H__#include "wyreqs.h"#include "wydefs.h"// Note: Order of these included files is significant. They are as parts of// this file.//#include "wyr_reply.h"#include "wyr_srcloc.h"#include "wyr_ret.h"/* This macro is used to declare class Reply in the namespace it is expanded. Note: Class contains no vtbl.*/#ifndef WYLIB_CONFIG_NORSLI #define WY_THROW_REPLY \ class Reply : public WyRet {\ public:\ inline Reply() WY__NOTHROW__\ : WyRet() {};\ inline Reply(const Reply& e) WY__NOTHROW__\ : WyRet(e) {};\ inline Reply(const WyRet& e) WY__NOTHROW__\ : WyRet(e) {};\ inline Reply(const WyReply& e) WY__NOTHROW__\ : WyRet(e) {};\ inline explicit Reply(int en) WY__NOTHROW__\ : WyRet(en) {};\ inline const Reply& set_sli(const Wy_SrcLoc* s) WY__NOTHROW__\ { WyRet::set_sli(s); return(*this); };\ inline const Wy_SrcLoc* sli_ptr(void) const WY__NOTHROW__\ { return WyRet::sli_ptr(); };\ }#else #define WY_THROW_REPLY \ class Reply : public WyRet {\ public:\ inline Reply() WY__NOTHROW__\ : WyRet() {};\ inline Reply(const Reply& e) WY__NOTHROW__\ : WyRet(e) {};\ inline Reply(const WyRet& e) WY__NOTHROW__\ : WyRet(e) {};\ inline Reply(const WyReply& e) WY__NOTHROW__\ : WyRet(e) {};\ inline explicit Reply(int en) WY__NOTHROW__\ : WyRet(en) {};\ }#endif/* The following macros are defined to hide Wy_SrcLoc and to save typings. Note: gcc 3.2.2 found to optimize the static declared Wy_SrcLoc*/// [Macro] Set the source location information in r to where this macro is.// r should be an object that has set_sli(..) defined as// const T& set_sli(const Wy_SrcLoc*)//#ifndef WYLIB_CONFIG_NORSLI #define WY_HERE(r) { static const Wy_SrcLoc wy__sl(__FILE__,__LINE__);\ (r).set_sli(&wy__sl); }#else #define WY_HERE(r)#endif// [Macro] Return WyRet from rm// rm is intended the argument that WyRet ctor accepts//#ifndef WYLIB_CONFIG_NORSLI #define WY_RETURN(rm) { static const Wy_SrcLoc wy__sl(__FILE__,__LINE__);\ return WyRet(rm).set_sli(&wy__sl); }#else #define WY_RETURN(rm) return WyRet(rm)#endif// [Macro] Throw object obj// obj is intended in the ctor form T(...) or an object that has// set_sli(..) defined by the rule.//// Note: obj is not enclosed (won't compile if obj is like "T()"// Note: obj can't be const//#ifndef WYLIB_CONFIG_NORSLI #define WY_THROW(obj) { static const Wy_SrcLoc wy__sl(__FILE__,__LINE__);\ throw obj.set_sli(&wy__sl); } // 1. This expression throws a reference. A testing program // showed that a copy constructor will be used to construct // the real thrown object. // [15.1.3] looked to me, the thrown object copy is always // created, in unspecified way. // 2. No real problem experienced yet //#else #define WY_THROW(obj) throw obj#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -