📄 wyr_srcloc.h
字号:
/* Copyright is licensed under GNU LGPL. (I.J. Wang, 2003-2004) This file is part of wyret.h and is included there. Definition code is in wyret.cpp */#ifndef WYR_SRCLOC_H__#define WYR_SRCLOC_H__#define WYR_SRCLOC_VERSION 31//// [Thread-Safe]//// [Internal] Class holding source location information//// Instances of this class should mostly be static const declared to live// throughout program life time.//// Note: All member functions do not throw// class Wy_SrcLoc { public: // // [Syn] Construct default object // // Wy_SrcLoc().src_file() = 0 // Wy_SrcLoc().src_line() = 0 // inline Wy_SrcLoc() WY__NOTHROW__ : _fn(0),_ln(0) {}; // // [Syn] Construct by copy // inline Wy_SrcLoc(const Wy_SrcLoc& c) WY__NOTHROW__ : _fn(c._fn), _ln(c._ln) {}; // self-copy ok // // [Syn] Construct the object to hold the source location information. // // Note: The c-string pointed to by file_name is supposed to exist constantly // throughout the program life time. // inline Wy_SrcLoc(const char* file_name, int line) WY__NOTHROW__ : _fn(file_name),_ln(line) {}; // // [Syn] Is object default // // [Ret] true= object is equivalent to Wy_SrcLoc() // false= otherwise // inline bool is_default(void) const WY__NOTHROW__ { return (_fn==0)&&(_ln==0); }; // // [Syn] Reset object to the constructed state as the parameters indicates // // Note: The c-string pointed to by file_name is supposed to exist constantly // throughout the program life time. // inline void reset(void) WY__NOTHROW__ { _fn=0; _ln=0; }; inline void reset(const char* file_name, int line) WY__NOTHROW__ { _fn=file_name; _ln=line; }; inline void reset(const Wy_SrcLoc& c) WY__NOTHROW__ { _fn=c._fn; _ln=c._ln; }; // // [Syn] Get the file name pointer this object holds // // [Ret] pointer of the file name this object holds // or zero (NULL) if object is default // inline const char *src_file(void) const WY__NOTHROW__ { return _fn; }; // // [Syn] Get the line number // // [Ret] The line number this object holds // or zero (NULL) if object is default // inline int src_line(void) const WY__NOTHROW__ { return _ln; }; // // [Syn] Test object equivalence // // [Ret] true= object contents is equivalent // false= otherwise // bool operator==(const Wy_SrcLoc& rhs) const WY__NOTHROW__ { return (_fn==rhs._fn)&&(_ln==rhs._ln); }; bool operator!=(const Wy_SrcLoc& rhs) const WY__NOTHROW__ { return (_fn!=rhs._fn)||(_ln!=rhs._ln); }; private: const char* _fn; int _ln; // Hidden const Wy_SrcLoc& operator=(const Wy_SrcLoc& rhs);};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -