SourceInfo Class Reference

#include <Pt/SourceInfo.h>

Source code info class. More...

Public Member Functions

 SourceInfo (const char *f, const char *ln, const char *fn)
 Constructor. More...
 
const char * file () const
 Returns the filename.
 
const char * func () const
 Returns the function signature.
 
const char * line () const
 Returns the line number.
 

Related Functions

std::string operator+ (const std::string &what, const SourceInfo &info)
 Concatenates a string with a SourceInfo.
 
std::string operator+ (const char *what, const SourceInfo &info)
 Concatenates a string with a SourceInfo.
 
std::string operator+ (const SourceInfo &info, const std::string &what)
 Concatenates a string with a SourceInfo.
 
std::string operator+ (const SourceInfo &info, const char *what)
 Concatenates a string with a SourceInfo.
 

Detailed Description

The SourceInfo class is used to store information about a location in the source code. This includes the file name, the line number and the name of the function. The PT_SOURCEINFO macro can be used to construct a SourceInfo object conveniently, based on compiler macros such as __FILE__ or __LINE__.

Pt::SourceInfo si(PT_SOURCEINFO);
// print file, line and function
std::cout << si.file() << std::endl;
std::cout << si.line() << std::endl;
std::cout << si.func() << std::endl;

Note, that the SourceInfo will contain the file and line information of the location where the PT_SOURCEINFO macro is used.

Constructor & Destructor Documentation

SourceInfo ( const char *  f,
const char *  ln,
const char *  fn 
)

Do not use the constructor directly, but the PT_SOURCEINFO macro to take advantage of compiler specific macros to indicate the source file name, position and function name.