xtd 0.2.0
Loading...
Searching...
No Matches
__xtd_source_location.hpp
Go to the documentation of this file.
1
3#pragma once
5#if !defined(__XTD_CORE_INTERNAL__)
6#error "Do not include this file: Internal use only"
7#endif
9
11#define __XTD_STD_INTERNAL__
12#include "__xtd_std_version.hpp"
13#undef __XTD_STD_INTERNAL__
14
15#if defined(__xtd__cpp_lib_source_location)
16#include <source_location>
17using __xtd_source_location__ = std::source_location;
18#else
19#include <cstdint>
20
21#define __XTD_FILE__ __builtin_FILE()
22#define __XTD_LINE__ __builtin_LINE()
23#define __XTD_FUNC__ __builtin_FUNCTION()
24#define __XTD_COLUMN__ __builtin_COLUMN()
25
26class __xtd_source_location__ {
27public:
28 const char* file_name() const noexcept {return data_.file;}
29 uint32_t line() const noexcept {return data_.line;}
30 const char* function_name() const noexcept {return data_.func;}
31 uint32_t column() const noexcept {return data_.column;}
32
33 static __xtd_source_location__ current(const char* file = __XTD_FILE__, uint32_t line = __XTD_LINE__, const char* func = __XTD_FUNC__, uint32_t column = __XTD_COLUMN__) noexcept {
34 auto csl = __xtd_source_location__ {};
35 csl.data_ = {file, line, func, column};
36 return csl;
37 }
38
39private:
40 struct data {
41 const char* file;
42 uint32_t line;
43 const char* func;
44 uint32_t column;
45 } data_;
46};
47
48#undef __XTD_FILE__
49#undef __XTD_LINE__
50#undef __XTD_FUNC__
51#undef __XTD_COLUMN__
52#endif
Contains __xtd_std_version definitions.
delegate< result_t(arguments_t...)> func
Represents a delegate that has variables parameters and returns a value of the type specified by the ...
Definition func.hpp:16