Skip to content

Commit

Permalink
feat: add .natvis
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Dec 12, 2024
1 parent 676cb37 commit 2e5e8be
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,7 @@ std::cout << value["名字"] << std::endl;
// str = "value"
std::string str = (std::string)value["key"][0];
```

## 调试

如果您正在使用 Visual Studio,并希望 `json::value` 在调试器中显示的更为直观,请为您的解决方案/项目添加 `tools/meojson.natvis`,详见 [将 .natvis 文件添加到 C++ 项目](https://learn.microsoft.com/zh-cn/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2022#add-a-natvis-file-to-a-c-project)
4 changes: 4 additions & 0 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,7 @@ std::cout << value["名字"] << std::endl;
// str = "value"
std::string str = (std::string)value["key"][0];
```

## Debug

If you are using Visual Studio and want `json::value` to be more visible in the debugger, please add `tools/meojson.natvis` to your solution/project, ref to [Add a .natvis file to a C++ project](https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2022#add-a-natvis-file-to-a-c-project).
26 changes: 26 additions & 0 deletions tools/meojson.natvis
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>

<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="json::basic_value&lt;*&gt;">
<DisplayString>{{ type={_type} str={to_string()} }}</DisplayString>
<Expand>
<Item Name="[type]">_type</Item>
<Item Name="[str]">format(4)</Item>
<Item Name="[value]" Condition="_type&lt;5">_raw_data._Head</Item>
<Item Name="[array]" Condition="_type==5">*_raw_data._Tail._Head</Item>
<Item Name="[object]" Condition="_type==6">*_raw_data._Tail._Tail._Head</Item>
</Expand>
</Type>
<Type Name="json::basic_array&lt;*&gt;">
<DisplayString>{{ size={_array_data.size()} str={to_string()} }}</DisplayString>
<Expand>
<ExpandedItem>_array_data</ExpandedItem>
</Expand>
</Type>
<Type Name="json::basic_object&lt;*&gt;">
<DisplayString>{{ size={_object_data._Mypair._Myval2._Myval2._Mysize} str={to_string()} }}</DisplayString>
<Expand>
<ExpandedItem>_object_data</ExpandedItem>
</Expand>
</Type>
</AutoVisualizer>

0 comments on commit 2e5e8be

Please sign in to comment.