Skip to content

Commit 0369d36

Browse files
author
Julian LALU
committed
Update natvis for string
1 parent 9ce63df commit 0369d36

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

core.natvis

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
</ArrayItems>
1212
</Expand>
1313
</Type>
14-
14+
1515
<!-- hud::optional<T> -->
1616
<Type Name="hud::optional&lt;*&gt;">
17-
<DisplayString Condition="some == true">Value: {some_value}</DisplayString>
17+
<DisplayString Condition="some == true">{some_value}</DisplayString>
1818
<DisplayString Condition="some == false">None</DisplayString>
1919
</Type>
2020

@@ -47,17 +47,49 @@
4747
<Item Name="second">($T2*)this</Item>
4848
</Expand>
4949
</Type>
50-
50+
5151
<!-- hud::vector<T> -->
5252
<Type Name="hud::vector&lt;*&gt;">
53-
<DisplayString Condition ="compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_ == 0"> Size = {compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_}</DisplayString>
54-
<DisplayString Condition ="compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_ > 0"> Size = {compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_}, Ptr = {compressed_allocator_.type_2_.begin_ptr_} </DisplayString>
53+
<DisplayString
54+
Condition="compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_ == 0">
55+
Size = {compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_}</DisplayString>
56+
<DisplayString
57+
Condition="compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_ > 0">
58+
Size = {compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_},
59+
Ptr = {compressed_allocator_.type_2_.begin_ptr_} </DisplayString>
5560
<Expand>
56-
<Item Condition="compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_ > 0" Name="Size">compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_</Item>
61+
<Item
62+
Condition="compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_ > 0"
63+
Name="Size">compressed_allocator_.type_2_.end_ptr_ -
64+
compressed_allocator_.type_2_.begin_ptr_</Item>
5765
<ArrayItems>
5866
<Size>compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_</Size>
5967
<ValuePointer>compressed_allocator_.type_2_.begin_ptr_</ValuePointer>
6068
</ArrayItems>
6169
</Expand>
6270
</Type>
71+
72+
<!-- hud::string -->
73+
<Type Name="hud::string">
74+
<DisplayString
75+
Condition="bytes_.compressed_allocator_.type_2_.end_ptr_ - bytes_.compressed_allocator_.type_2_.begin_ptr_ == 0">
76+
Empty
77+
</DisplayString>
78+
<DisplayString
79+
Condition="bytes_.compressed_allocator_.type_2_.end_ptr_ - bytes_.compressed_allocator_.type_2_.begin_ptr_ > 0">
80+
{bytes_.compressed_allocator_.type_2_.begin_ptr_,s8}
81+
</DisplayString>
82+
<Expand>
83+
<Item
84+
Condition="bytes_.compressed_allocator_.type_2_.end_ptr_ - bytes_.compressed_allocator_.type_2_.begin_ptr_ > 0"
85+
Name="Size">
86+
bytes_.compressed_allocator_.type_2_.end_ptr_ -
87+
bytes_.compressed_allocator_.type_2_.begin_ptr_
88+
</Item>
89+
<ArrayItems>
90+
<Size>bytes_.compressed_allocator_.type_2_.end_ptr_ - bytes_.compressed_allocator_.type_2_.begin_ptr_</Size>
91+
<ValuePointer>bytes_.compressed_allocator_.type_2_.begin_ptr_</ValuePointer>
92+
</ArrayItems>
93+
</Expand>
94+
</Type>
6395
</AutoVisualizer>

interface/core/string/string.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ namespace hud
2222

2323
[[nodiscard]] constexpr usize byte_count() const noexcept
2424
{
25-
return data_.byte_count();
25+
return bytes_.byte_count();
2626
}
2727
[[nodiscard]] constexpr usize max_byte_count() const noexcept
2828
{
29-
return data_.max_count();
29+
return bytes_.max_count();
3030
}
3131
[[nodiscard]] constexpr const char8 *bytes() const noexcept
3232
{
33-
return data_.data();
33+
return bytes_.data();
3434
}
3535

3636
private:
3737
template<typename char_t>
3838
requires(hud::is_same_v<hud::remove_cv_t<char_t>, char8>)
3939
constexpr string(const hud::slice<char_t> slice) noexcept
40-
: data_ {slice.data(), slice.count()}
40+
: bytes_ {slice.data(), slice.count()}
4141
{
4242
}
4343

@@ -46,7 +46,7 @@ namespace hud
4646
friend constexpr hud::optional<hud::string> make_string(const hud::slice<char_t> slice) noexcept;
4747

4848
private:
49-
hud::vector<char8> data_;
49+
hud::vector<char8> bytes_;
5050
};
5151

5252
template<typename char_t>

test/string/string_constructors.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ GTEST_TEST(string, constructor_from_char8)
3636
auto test = []() {
3737
const char8 txt[] = "é&='\0/1234564789";
3838
hud::optional<hud::string> str_opt = hud::make_string(hud::slice {txt, sizeof(txt)});
39-
auto str = *str_opt;
4039
return std::tuple {
4140
str_opt.has_value(),
4241
str_opt->byte_count() == sizeof(txt),

0 commit comments

Comments
 (0)