From 42775fd31ccf06cd4281ce2bfc3020c6cfcae4bb Mon Sep 17 00:00:00 2001 From: Gammasoft Date: Fri, 18 Oct 2024 21:19:35 +0200 Subject: [PATCH] move xtd::source_location to xtd::diagnostics::source_location --- examples/README.md | 1 - examples/xtd.core.examples/CMakeLists.txt | 1 - examples/xtd.core.examples/README.md | 5 +---- .../xtd.core.examples/diagnostics/CMakeLists.txt | 1 + examples/xtd.core.examples/diagnostics/README.md | 1 + .../source_location_invoked_directly/CMakeLists.txt | 0 .../source_location_invoked_directly/README.md | 0 .../src/source_location_invoked_directly.cpp | 0 .../source_location/CMakeLists.txt | 9 --------- .../xtd.core.examples/source_location/README.md | 13 ------------- src/xtd.core/CMakeLists.txt | 6 +++--- .../include/xtd/{ => diagnostics}/source_location | 0 .../include/xtd/{ => diagnostics}/source_location.h | 8 ++++---- src/xtd.core/include/xtd/diagnostics/stack_frame.h | 2 +- .../src/xtd/{ => diagnostics}/source_location.cpp | 4 ++-- .../src/assert_unit_tests/assert_value.h | 2 +- 16 files changed, 14 insertions(+), 39 deletions(-) rename examples/xtd.core.examples/{source_location => diagnostics}/source_location_invoked_directly/CMakeLists.txt (100%) rename examples/xtd.core.examples/{source_location => diagnostics}/source_location_invoked_directly/README.md (100%) rename examples/xtd.core.examples/{source_location => diagnostics}/source_location_invoked_directly/src/source_location_invoked_directly.cpp (100%) delete mode 100644 examples/xtd.core.examples/source_location/CMakeLists.txt delete mode 100644 examples/xtd.core.examples/source_location/README.md rename src/xtd.core/include/xtd/{ => diagnostics}/source_location (100%) rename src/xtd.core/include/xtd/{ => diagnostics}/source_location.h (97%) rename src/xtd.core/src/xtd/{ => diagnostics}/source_location.cpp (94%) diff --git a/examples/README.md b/examples/README.md index e512437487a6..6224d7570f2a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -38,7 +38,6 @@ * [Parse](xtd.core.examples/parse/README.md) contains parse examples. * [Processes](xtd.core.examples/processes/README.md) contains process examples. * [Random](xtd.core.examples/random/README.md) contains random examples. -* [Source location](xtd.core.examples/source_location/README.md) contains source location examples. * [Strings](xtd.core.examples/strings/README.md) contains strings examples. * [Text](xtd.core.examples/text/README.md) contains text examples. * [Threading](xtd.core.examples/threading/README.md) contains threading examples. diff --git a/examples/xtd.core.examples/CMakeLists.txt b/examples/xtd.core.examples/CMakeLists.txt index 1d9c4f131dcd..8399c78de53a 100644 --- a/examples/xtd.core.examples/CMakeLists.txt +++ b/examples/xtd.core.examples/CMakeLists.txt @@ -35,7 +35,6 @@ add_projects( parse processes random - source_location sprintf startups strings diff --git a/examples/xtd.core.examples/README.md b/examples/xtd.core.examples/README.md index f1a8ca108e4d..c1d1993a2e7a 100644 --- a/examples/xtd.core.examples/README.md +++ b/examples/xtd.core.examples/README.md @@ -123,6 +123,7 @@ * [console_trace_listener](diagnostics/console_trace_listener/README.md) shows how to use [xtd::diagnostics::console_trace_listener](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1console__trace__listener.html) class. * [debug](diagnostics/debug/README.md) shows how to use [xtd::diagnostics::debug](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1debug.html) class. * [debug_cassert](diagnostics/debug_cassert/README.md) shows how to use [xtd::diagnostics::debug::cassert](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1debug.html#acdb0d00e4b12fccc037cf3f965110d72) method. +* [source_location_invoked_directly](diagnostics/source_location_invoked_directly/README.md) shows how to use [xtd::source_location](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1source__location.html) class. * [stack_frame](diagnostics/stack_frame/README.md) shows how to use [xtd::diagnostics::stack_frame](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1stack__frame.html) class. * [stack_trace](diagnostics/stack_trace/README.md) shows how to use [xtd::diagnostics::stack_trace](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1stack__trace.html) class. * [stack_trace_simple](diagnostics/stack_trace_simple/README.md) demonstrates how to create a simple [xtd::diagnostics::stack_trace](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1stack__trace.html) class and iterate through its frames to obtain debugging and diagnostic information. @@ -328,10 +329,6 @@ * [random2](random/random2/README.md) shows how to use [xtd::random](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1random.html) class. * [random3](random/random3/README.md) shows how to use [xtd::random::next](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1random.html#aea69230c5fe2a5ecc5026aa568dc349c) method. -## [source_location](source_location/README.md) - -* [source_location_invoked_directly](source_location/source_location_invoked_directly/README.md) shows how to use [xtd::source_location](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1source__location.html) class. - ## [sprintf](sprintf/README.md) * [sprintf](sprintf/sprintf/README.md) shows how to use [xtd::ustring::sprintf](https://gammasoft71.github.io/xtd/reference_guides/latest/group__sprintf__parse.html#ga0c65606fb81f84e4d9ea43002114d8de) method. diff --git a/examples/xtd.core.examples/diagnostics/CMakeLists.txt b/examples/xtd.core.examples/diagnostics/CMakeLists.txt index 8a067332c1a9..47c6fe2b934d 100644 --- a/examples/xtd.core.examples/diagnostics/CMakeLists.txt +++ b/examples/xtd.core.examples/diagnostics/CMakeLists.txt @@ -10,6 +10,7 @@ add_projects( debug debug_cassert default_trace_listener + source_location_invoked_directly stack_frame stack_trace stack_trace_simple diff --git a/examples/xtd.core.examples/diagnostics/README.md b/examples/xtd.core.examples/diagnostics/README.md index ebd4fce4ec3e..4dab05497852 100644 --- a/examples/xtd.core.examples/diagnostics/README.md +++ b/examples/xtd.core.examples/diagnostics/README.md @@ -7,6 +7,7 @@ * [console_trace_listener](console_trace_listener/README.md) shows how to use [xtd::diagnostics::console_trace_listener](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1console__trace__listener.html) class. * [debug](debug/README.md) shows how to use [xtd::diagnostics::debug](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1debug.html) class. * [debug_cassert](debug_cassert/README.md) shows how to use [xtd::diagnostics::debug::cassert](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1debug.html#acdb0d00e4b12fccc037cf3f965110d72) method. +* [source_location_invoked_directly](source_location_invoked_directly/README.md) shows how to use [xtd::source_location](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1source__location.html) class. * [stack_frame](stack_frame/README.md) shows how to use [xtd::diagnostics::stack_frame](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1stack__frame.html) class. * [stack_trace](stack_trace/README.md) shows how to use [xtd::diagnostics::stack_trace](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1stack__trace.html) class. * [stack_trace_simple](stack_trace_simple/README.md) demonstrates how to create a simple [xtd::diagnostics::stack_trace](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1diagnostics_1_1stack__trace.html) class and iterate through its frames to obtain debugging and diagnostic information. diff --git a/examples/xtd.core.examples/source_location/source_location_invoked_directly/CMakeLists.txt b/examples/xtd.core.examples/diagnostics/source_location_invoked_directly/CMakeLists.txt similarity index 100% rename from examples/xtd.core.examples/source_location/source_location_invoked_directly/CMakeLists.txt rename to examples/xtd.core.examples/diagnostics/source_location_invoked_directly/CMakeLists.txt diff --git a/examples/xtd.core.examples/source_location/source_location_invoked_directly/README.md b/examples/xtd.core.examples/diagnostics/source_location_invoked_directly/README.md similarity index 100% rename from examples/xtd.core.examples/source_location/source_location_invoked_directly/README.md rename to examples/xtd.core.examples/diagnostics/source_location_invoked_directly/README.md diff --git a/examples/xtd.core.examples/source_location/source_location_invoked_directly/src/source_location_invoked_directly.cpp b/examples/xtd.core.examples/diagnostics/source_location_invoked_directly/src/source_location_invoked_directly.cpp similarity index 100% rename from examples/xtd.core.examples/source_location/source_location_invoked_directly/src/source_location_invoked_directly.cpp rename to examples/xtd.core.examples/diagnostics/source_location_invoked_directly/src/source_location_invoked_directly.cpp diff --git a/examples/xtd.core.examples/source_location/CMakeLists.txt b/examples/xtd.core.examples/source_location/CMakeLists.txt deleted file mode 100644 index c14b822646e4..000000000000 --- a/examples/xtd.core.examples/source_location/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.20) - -project(source_location) -find_package(xtd REQUIRED) - -add_projects( - source_location_invoked_directly -) - diff --git a/examples/xtd.core.examples/source_location/README.md b/examples/xtd.core.examples/source_location/README.md deleted file mode 100644 index b2797556bbfe..000000000000 --- a/examples/xtd.core.examples/source_location/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# source_location examples - -[This folder](.) contains random examples used by [Reference Guide](https://gammasoft71.github.io/xtd/reference_guides/latest/) and more. - -* [source_location_invoked_directly](source_location_invoked_directly/README.md) shows how to use [xtd::source_location](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1source__location.html) class. - -## Build and run any project - -Open "Command Prompt" or "Terminal". Navigate to the folder that contains the project and type the following: - -```shell -xtdc run -t any_project_name -``` diff --git a/src/xtd.core/CMakeLists.txt b/src/xtd.core/CMakeLists.txt index 96c71b2a7acf..1b0b95ad9321 100644 --- a/src/xtd.core/CMakeLists.txt +++ b/src/xtd.core/CMakeLists.txt @@ -395,8 +395,6 @@ add_sources( include/xtd/slong_object include/xtd/software_termination_exception.h include/xtd/software_termination_exception - include/xtd/source_location - include/xtd/source_location.h include/xtd/sptr.h include/xtd/sptr include/xtd/startup.h @@ -634,6 +632,8 @@ add_sources( include/xtd/diagnostics/source_filter include/xtd/diagnostics/source_levels.h include/xtd/diagnostics/source_levels + include/xtd/diagnostics/source_location.h + include/xtd/diagnostics/source_location include/xtd/diagnostics/source_switch.h include/xtd/diagnostics/source_switch include/xtd/diagnostics/stack_frame.h @@ -1063,7 +1063,6 @@ add_sources( src/xtd/processor.cpp src/xtd/random.cpp src/xtd/signal_cancel_event_args.cpp - src/xtd/source_location.cpp src/xtd/startup.cpp src/xtd/system_exception.cpp src/xtd/target_type.cpp @@ -1090,6 +1089,7 @@ add_sources( src/xtd/diagnostics/process.cpp src/xtd/diagnostics/process_start_info.cpp src/xtd/diagnostics/source_filter.cpp + src/xtd/diagnostics/source_location.cpp src/xtd/diagnostics/source_switch.cpp src/xtd/diagnostics/stack_frame.cpp src/xtd/diagnostics/stack_trace.cpp diff --git a/src/xtd.core/include/xtd/source_location b/src/xtd.core/include/xtd/diagnostics/source_location similarity index 100% rename from src/xtd.core/include/xtd/source_location rename to src/xtd.core/include/xtd/diagnostics/source_location diff --git a/src/xtd.core/include/xtd/source_location.h b/src/xtd.core/include/xtd/diagnostics/source_location.h similarity index 97% rename from src/xtd.core/include/xtd/source_location.h rename to src/xtd.core/include/xtd/diagnostics/source_location.h index 1c2f58c1f6e9..75eb00db68f7 100644 --- a/src/xtd.core/include/xtd/source_location.h +++ b/src/xtd.core/include/xtd/diagnostics/source_location.h @@ -3,11 +3,11 @@ /// @copyright Copyright (c) 2024 Gammasoft. All rights reserved. #pragma once #define __XTD_CORE_INTERNAL__ -#include "internal/__xtd_source_location.h" +#include "../internal/__xtd_source_location.h" #undef __XTD_CORE_INTERNAL__ -#include "object.h" -#include "ptr.h" -#include "size.h" +#include "../object.h" +#include "../ptr.h" +#include "../size.h" /// @brief The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more. namespace xtd { /// @brief The xtd::source_location class represents certain information about the source code, such as file names, line numbers, and function names. Previously, functions that desire to obtain this information about the call site (for logging, testing, or debugging purposes) must use macros so that [predefined macros](https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros) like `__LINE__` and `__FILE__` are expanded in the context of the caller. The xtd::source_location class provides a better alternative. diff --git a/src/xtd.core/include/xtd/diagnostics/stack_frame.h b/src/xtd.core/include/xtd/diagnostics/stack_frame.h index 5a5d3020d330..de09a504535a 100644 --- a/src/xtd.core/include/xtd/diagnostics/stack_frame.h +++ b/src/xtd.core/include/xtd/diagnostics/stack_frame.h @@ -5,11 +5,11 @@ #include #include +#include "source_location.h" #include "../core_export.h" #include "../iequatable.h" #include "../object.h" #include "../ptr.h" -#include "../source_location.h" #include "../size.h" #define __XTD_CORE_INTERNAL__ #include "../internal/__string_definitions.h" diff --git a/src/xtd.core/src/xtd/source_location.cpp b/src/xtd.core/src/xtd/diagnostics/source_location.cpp similarity index 94% rename from src/xtd.core/src/xtd/source_location.cpp rename to src/xtd.core/src/xtd/diagnostics/source_location.cpp index 09e752096388..d0bc73017507 100644 --- a/src/xtd.core/src/xtd/source_location.cpp +++ b/src/xtd.core/src/xtd/diagnostics/source_location.cpp @@ -1,5 +1,5 @@ -#include "../../include/xtd/source_location.h" -#include "../../include/xtd/string.h" +#include "../../../include/xtd/diagnostics/source_location.h" +#include "../../../include/xtd/string.h" using namespace xtd; diff --git a/tests/xtd.tunit.unit_tests/src/assert_unit_tests/assert_value.h b/tests/xtd.tunit.unit_tests/src/assert_unit_tests/assert_value.h index 57e510b41684..4636131e4cd1 100644 --- a/tests/xtd.tunit.unit_tests/src/assert_unit_tests/assert_value.h +++ b/tests/xtd.tunit.unit_tests/src/assert_unit_tests/assert_value.h @@ -1,8 +1,8 @@ #pragma once #include "unit_test_error.h" +#include #include #include -#include #include #include #include