From 5612363097db9d8f56b612e2d0713bcae20a8fd0 Mon Sep 17 00:00:00 2001 From: Przemog1 Date: Mon, 1 Dec 2025 13:57:18 +0100 Subject: [PATCH 1/5] Created `nbl::system::to_string` utility function --- examples_tests | 2 +- include/nbl/system/to_string.h | 84 ++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 include/nbl/system/to_string.h diff --git a/examples_tests b/examples_tests index 2b4db21239..158e58891d 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 2b4db2123918f380cc0a35f6889315a02f84ea73 +Subproject commit 158e58891d6395df2566013b3590fdfe475aae8d diff --git a/include/nbl/system/to_string.h b/include/nbl/system/to_string.h new file mode 100644 index 0000000000..70ecfba211 --- /dev/null +++ b/include/nbl/system/to_string.h @@ -0,0 +1,84 @@ +#ifndef _NBL_SYSTEM_TO_STRING_INCLUDED_ +#define _NBL_SYSTEM_TO_STRING_INCLUDED_ + +#include +#include +#include + +namespace nbl +{ +namespace system +{ +namespace impl +{ + +template +struct to_string_helper +{ + static std::string __call(const T& value) + { + return std::to_string(value); + } +}; + +template<> +struct to_string_helper +{ + static std::string __call(const hlsl::emulated_uint64_t& value) + { + return std::to_string(static_cast(value)); + } +}; + +template<> +struct to_string_helper +{ + static std::string __call(const hlsl::emulated_int64_t& value) + { + return std::to_string(static_cast(value)); + } +}; + +template +struct to_string_helper> +{ + static std::string __call(const hlsl::vector& value) + { + std::stringstream output; + output << "{ "; + for (int i = 0; i < N; ++i) + { + output << to_string_helper::__call(value[i]); + + if (i < N - 1) + output << ", "; + } + output << " }"; + + return output.str(); + } +}; + +template +struct to_string_helper> +{ + using value_t = hlsl::morton::code; + static std::string __call(value_t value) + { + TestValueToTextConverter mortonCodeDataToTextConverter; + return mortonCodeDataToTextConverter(value.value); + } +}; + + +} + +template +std::string to_string(T value) +{ + return impl::to_string_helper::__call(value); +} +} +} + +#endif \ No newline at end of file From 2a43ae8981e0c984631176b0fb7caada4d39cd40 Mon Sep 17 00:00:00 2001 From: Przemog1 Date: Mon, 1 Dec 2025 15:37:21 +0100 Subject: [PATCH 2/5] Removed from the `to_string` function specialization of types not present yet in the master branch --- include/nbl/system/to_string.h | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/include/nbl/system/to_string.h b/include/nbl/system/to_string.h index 70ecfba211..92888704c0 100644 --- a/include/nbl/system/to_string.h +++ b/include/nbl/system/to_string.h @@ -2,8 +2,6 @@ #define _NBL_SYSTEM_TO_STRING_INCLUDED_ #include -#include -#include namespace nbl { @@ -21,24 +19,6 @@ struct to_string_helper } }; -template<> -struct to_string_helper -{ - static std::string __call(const hlsl::emulated_uint64_t& value) - { - return std::to_string(static_cast(value)); - } -}; - -template<> -struct to_string_helper -{ - static std::string __call(const hlsl::emulated_int64_t& value) - { - return std::to_string(static_cast(value)); - } -}; - template struct to_string_helper> { @@ -59,18 +39,6 @@ struct to_string_helper> } }; -template -struct to_string_helper> -{ - using value_t = hlsl::morton::code; - static std::string __call(value_t value) - { - TestValueToTextConverter mortonCodeDataToTextConverter; - return mortonCodeDataToTextConverter(value.value); - } -}; - - } template From b7f71690d99cd931d17e56b324e82547b8f1e3c2 Mon Sep 17 00:00:00 2001 From: Przemog1 Date: Mon, 1 Dec 2025 16:04:55 +0100 Subject: [PATCH 3/5] Restored the removed `system::to_string` specializations --- include/nbl/system/to_string.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/nbl/system/to_string.h b/include/nbl/system/to_string.h index 92888704c0..70ecfba211 100644 --- a/include/nbl/system/to_string.h +++ b/include/nbl/system/to_string.h @@ -2,6 +2,8 @@ #define _NBL_SYSTEM_TO_STRING_INCLUDED_ #include +#include +#include namespace nbl { @@ -19,6 +21,24 @@ struct to_string_helper } }; +template<> +struct to_string_helper +{ + static std::string __call(const hlsl::emulated_uint64_t& value) + { + return std::to_string(static_cast(value)); + } +}; + +template<> +struct to_string_helper +{ + static std::string __call(const hlsl::emulated_int64_t& value) + { + return std::to_string(static_cast(value)); + } +}; + template struct to_string_helper> { @@ -39,6 +59,18 @@ struct to_string_helper> } }; +template +struct to_string_helper> +{ + using value_t = hlsl::morton::code; + static std::string __call(value_t value) + { + TestValueToTextConverter mortonCodeDataToTextConverter; + return mortonCodeDataToTextConverter(value.value); + } +}; + + } template From 486af6d3698534557809065b3fbf491c5078a47c Mon Sep 17 00:00:00 2001 From: Przemog1 Date: Mon, 1 Dec 2025 16:14:26 +0100 Subject: [PATCH 4/5] Fixes --- examples_tests | 2 +- include/nbl/system/to_string.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples_tests b/examples_tests index 158e58891d..8842299b81 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 158e58891d6395df2566013b3590fdfe475aae8d +Subproject commit 8842299b81c2ab0a8951d042b1945372a930b863 diff --git a/include/nbl/system/to_string.h b/include/nbl/system/to_string.h index 70ecfba211..3169503a06 100644 --- a/include/nbl/system/to_string.h +++ b/include/nbl/system/to_string.h @@ -65,8 +65,7 @@ struct to_string_helper> using value_t = hlsl::morton::code; static std::string __call(value_t value) { - TestValueToTextConverter mortonCodeDataToTextConverter; - return mortonCodeDataToTextConverter(value.value); + return to_string_helper::__call(value.value); } }; From 256420229e8a3b65bb5f09fc0933e70e894338f0 Mon Sep 17 00:00:00 2001 From: Przemog1 Date: Mon, 1 Dec 2025 17:05:34 +0100 Subject: [PATCH 5/5] Updated examples --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 8842299b81..44fdbe8d35 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 8842299b81c2ab0a8951d042b1945372a930b863 +Subproject commit 44fdbe8d35a9505ac3474b708200cc7e039aae31