xtd.tunit - Reference Guide  1.0.0
Modern c++17 unit testing framework on Windows, macOS, Linux, iOS and android.
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;
}
// The main entry point for the application.
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

Constructor & Destructor Documentation

§ line_info() [1/3]

xtd::tunit::line_info::line_info ( )
defaultnoexcept

Creates new instance of line info.

§ line_info() [2/3]

xtd::tunit::line_info::line_info ( const std::string &  file_path,
unsigned int  line_number 
)
inlinenoexcept

Creates new instance of line info with file path specified, and line number specified.

Parameters
file_pathContains the file path string.
line_numberContains the line number.

§ line_info() [3/3]

xtd::tunit::line_info::line_info ( const std::string &  member_name,
const std::string &  file_path,
unsigned int  line_number 
)
inlinenoexcept

Creates new instance of line info with member name specified, file path specified, and line number specified.

Parameters
member_nameContains the member name string.
file_pathContains the file path string.
line_numberContains the line number.

Member Function Documentation

§ empty()

static xtd::tunit::line_info xtd::tunit::line_info::empty ( )
inlinestatic

Return an empty line info.

Returns
Empty line info.

§ file_path()

const std::string& xtd::tunit::line_info::file_path ( ) const
inlinenoexcept

Gets the file path.

Returns
string file path

§ line_number()

unsigned int xtd::tunit::line_info::line_number ( ) const
inlinenoexcept

Gets the line number.

Returns
int32 line number

§ member_name()

const std::string& xtd::tunit::line_info::member_name ( ) const
inlinenoexcept

Gets the member name.

Returns
string member name

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