Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

SourceCodeLocation.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                         (C) SuSE Linux Products GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       SourceCodeLocation.h
00014 
00015   Author:     Michael Andres <ma@suse.de>
00016   Maintainer: Michael Andres <ma@suse.de>
00017 
00018   Purpose:
00019 
00020 /-*/
00021 #ifndef SourceCodeLocation_h
00022 #define SourceCodeLocation_h
00023 
00024 #include <iosfwd>
00025 #include <string>
00026 
00028 //
00029 //      CLASS NAME : SourceCodeLocation
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

Generated on Fri Feb 24 00:30:02 2006 for liby2util by  doxygen 1.4.4