Skip to content

Commit a9e1078

Browse files
committed
Resolved conflicts cherry-picked from the unified_testing_interface branch
1 parent 45d6173 commit a9e1078

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed

include/nbl/system/to_string.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#ifndef _NBL_SYSTEM_TO_STRING_INCLUDED_
2+
#define _NBL_SYSTEM_TO_STRING_INCLUDED_
3+
4+
#include <nbl/builtin/hlsl/cpp_compat.hlsl>
5+
#include <nbl/builtin/hlsl/emulated/int64_t.hlsl>
6+
#include <nbl/builtin/hlsl/morton.hlsl>
7+
8+
namespace nbl
9+
{
10+
namespace system
11+
{
12+
namespace impl
13+
{
14+
15+
template<typename T>
16+
struct to_string_helper
17+
{
18+
static std::string __call(const T& value)
19+
{
20+
return std::to_string(value);
21+
}
22+
};
23+
24+
template<>
25+
struct to_string_helper<hlsl::emulated_uint64_t>
26+
{
27+
static std::string __call(const hlsl::emulated_uint64_t& value)
28+
{
29+
return std::to_string(static_cast<uint64_t>(value));
30+
}
31+
};
32+
33+
template<>
34+
struct to_string_helper<hlsl::emulated_int64_t>
35+
{
36+
static std::string __call(const hlsl::emulated_int64_t& value)
37+
{
38+
return std::to_string(static_cast<int64_t>(value));
39+
}
40+
};
41+
42+
template<typename T, int16_t N>
43+
struct to_string_helper<hlsl::vector<T, N>>
44+
{
45+
static std::string __call(const hlsl::vector<T, N>& value)
46+
{
47+
std::stringstream output;
48+
output << "{ ";
49+
for (int i = 0; i < N; ++i)
50+
{
51+
output << to_string_helper<T>::__call(value[i]);
52+
53+
if (i < N - 1)
54+
output << ", ";
55+
}
56+
output << " }";
57+
58+
return output.str();
59+
}
60+
};
61+
62+
template<bool Signed, uint16_t Bits, uint16_t D, typename _uint64_t>
63+
struct to_string_helper<hlsl::morton::code<Signed, Bits, D, _uint64_t>>
64+
{
65+
using value_t = hlsl::morton::code<Signed, Bits, D, _uint64_t>;
66+
static std::string __call(value_t value)
67+
{
68+
TestValueToTextConverter<value_t::storage_t> mortonCodeDataToTextConverter;
69+
return mortonCodeDataToTextConverter(value.value);
70+
}
71+
};
72+
73+
74+
}
75+
76+
template<typename T>
77+
std::string to_string(T value)
78+
{
79+
return impl::to_string_helper<T>::__call(value);
80+
}
81+
}
82+
}
83+
84+
#endif

0 commit comments

Comments
 (0)