xtd - Reference Guide  0.1.0
Modern c++17 framework to create console, gui and unit test applications on Windows, macOS and Linux.
xtd::tunit::line_info Class Referencefinal

line_info information class is used to store current file, current line and current function information. More...

#include <line_info.h>

Public Member Functions

 line_info () noexcept=default
 Creates new instance of line info. More...
 
 line_info (const std::string &file_path, unsigned int line_number) noexcept
 Creates new instance of line info with file path specified, and line number specified. More...
 
 line_info (const std::string &member_name, const std::string &file_path, unsigned int line_number) noexcept
 Creates new instance of line info with member name specified, file path specified, and line number specified. More...
 
const std::string & file_path () const noexcept
 Gets the file path. More...
 
unsigned int line_number () const noexcept
 Gets the line number. More...
 
const std::string & member_name () const noexcept
 Gets the member name. More...
 

Static Public Member Functions

static xtd::tunit::line_info empty ()
 Return an empty line info. More...
 

Detailed Description

line_info information class is used to store current file, current line and current function information.

Examples
The following example shows how to use the line_info
#include <xtd/xtd.tunit>
#include <iostream>
using namespace std;
using namespace xtd::tunit;
void trace_message(const string& message, const line_info& info) {
cout << "message: " << message << endl;
cout << "member name: " << info.member_name() << endl;
cout << "source file path: " << info.file_path() << endl;
cout << "source line number: " << info.line_number() << endl;
}
int main() {
trace_message("Something happened.", line_info_);
}
// This code can produce the following output:
//
// message: Something happened.
// member name: main
// source file path: /Users/UserName/Projects/xtd/xtd.tunit/examples/line_info/src/line_info.cpp
// source line number: 16

The documentation for this class was generated from the following file: