00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SourceCodeLocation_h
00022 #define SourceCodeLocation_h
00023
00024 #include <iosfwd>
00025 #include <string>
00026
00028
00029
00035 class SourceCodeLocation
00036 {
00040 struct _Verbose;
00041
00046 friend SourceCodeLocation::_Verbose
00047 verbose( const SourceCodeLocation & obj_r );
00048
00052 friend std::ostream &
00053 operator<<( std::ostream & str, const SourceCodeLocation & obj_r );
00054
00059 friend std::ostream &
00060 operator<<( std::ostream & str, const SourceCodeLocation::_Verbose & obj_r );
00061
00062 public:
00063
00067 SourceCodeLocation()
00068 : _line( _unknown )
00069 {}
00070
00075 SourceCodeLocation( const std::string & file_r,
00076 const std::string & func_r,
00077 const std::string & pretty_func_r,
00078 unsigned line_r )
00079 : _file( file_r ), _func( func_r ), _pretty_func( pretty_func_r ), _line( line_r )
00080 {}
00081
00085 operator const void *const() const
00086 { return (const void *const)(_line != _unknown); }
00087
00091 const std::string &
00092 file() const
00093 { return _file; }
00094
00098 const std::string &
00099 func() const
00100 { return _func; }
00101
00105 const std::string &
00106 pretty_func() const
00107 { return _pretty_func; }
00108
00112 unsigned
00113 line() const
00114 { return _line; }
00115
00116 private:
00117
00118 static const unsigned _unknown;
00119
00120 std::string _file;
00121 std::string _func;
00122 std::string _pretty_func;
00123 unsigned _line;
00124 };
00126
00127 #define SOURCECODELOCATION SourceCodeLocation( __FILE__, __FUNCTION__, __PRETTY_FUNCTION__, __LINE__ )
00128
00130
00136 struct SourceCodeLocation::_Verbose
00137 { SourceCodeLocation _obj; };
00138
00143 inline SourceCodeLocation::_Verbose
00144 verbose( const SourceCodeLocation & obj_r )
00145 { SourceCodeLocation::_Verbose obj; obj._obj = obj_r; return obj; }
00146
00148 #endif // SourceCodeLocation_h