【问题标题】:Looking for a visual studio visualizer (natvis) for JsonCpp为 JsonCpp 寻找 Visual Studio 可视化工具(natvis)
【发布时间】:2015-02-11 14:38:50
【问题描述】:

我正在寻找JsonCppnatvis 文件,但我找不到任何文件。

有人知道这样的文件吗?

【问题讨论】:

    标签: jsoncpp natvis


    【解决方案1】:

    编辑:我已将此文件添加到visualstudio-debugger repository on GitHub

    Edit2: 此问题的另外两个答案已链接到其他 github 存储库(我尚未签出)。出于某种原因,它们被管理员删除了(我不知道为什么),所以它们在这里:


    由于没有人给出答案(有些人认为由于某种原因这在 stackoverflow 上是题外话)我自己写了,就在这里。使用风险自负。

    <?xml version="1.0" encoding="utf-8"?>
    <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
      <!-- Json::Value - basic support -->
      <Type Name="Json::Value">
        <DisplayString Condition="type_ == 0">null</DisplayString>
        <DisplayString Condition="type_ == 1">{value_.int_}</DisplayString>
        <DisplayString Condition="type_ == 2">{value_.uint_}</DisplayString>
        <DisplayString Condition="type_ == 3">{value_.real_}</DisplayString>
        <DisplayString Condition="type_ == 4">{value_.string_,s8}</DisplayString>
        <DisplayString Condition="type_ == 5">{value_.bool_}</DisplayString>
        <DisplayString Condition="type_ == 6">array ({value_.map_-&gt;_Mysize})</DisplayString>
        <DisplayString Condition="type_ == 7">object ({value_.map_-&gt;_Mysize})</DisplayString>
        <DisplayString >Unknown Value type!</DisplayString>
        <StringView Condition="type_ == 4">value_.string_,s8</StringView>
        <Expand>
          <ExpandedItem Condition="type_ == 6">*(value_.map_)</ExpandedItem>
          <ExpandedItem Condition="type_ == 7">*(value_.map_)</ExpandedItem>
        </Expand>
      </Type>
    
      <!-- Key/value pairs - used as values for objects and arrays (in arrays the key is null so don't display it) -->
      <Type Name="std::pair&lt;Json::Value::CZString const ,Json::Value&gt;">
        <DisplayString Condition="first.cstr_ != nullptr">{first.cstr_,s8}: {second}</DisplayString>
        <DisplayString>{second}</DisplayString>
        <Expand>
          <Item Name="key" Condition="first.cstr_ != nullptr">first.cstr_</Item>
          <Item Name="value" Condition="first.cstr_ != nullptr">second</Item>
          <ExpandedItem>second</ExpandedItem>
        </Expand>
      </Type>
    </AutoVisualizer>
    

    【讨论】:

      【解决方案2】:

      根据 Dmitry Yastrebkov 的(已删除)答案,我做了以下似乎对我很有效的答案:

      <?xml version="1.0" encoding="utf-8"?>
      <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
        <Type Name="std::map&lt;*&gt;" IncludeView="jsoncpp">
          <Expand>
            <TreeItems>
              <Size>_Mypair._Myval2._Myval2._Mysize</Size>
              <HeadPointer>_Mypair._Myval2._Myval2._Myhead-&gt;_Parent</HeadPointer>
              <LeftPointer>_Left</LeftPointer>
              <RightPointer>_Right</RightPointer>
              <ValueNode Condition="_Isnil == 0 &amp;&amp; true" Name="{_Myval,view(jsonname)}">_Myval,view(jsoncpp)</ValueNode>
            </TreeItems>
          </Expand>
        </Type>
      
        <Type Name="std::pair&lt;*&gt;" IncludeView="jsonname">
          <DisplayString Condition="first.cstr_ == nullptr">[{first.index_}]</DisplayString>
          <DisplayString Condition="first.cstr_ != nullptr">{first.cstr_,s8}</DisplayString>
        </Type>
      
        <Type Name="std::pair&lt;*&gt;" IncludeView="jsoncpp">
          <DisplayString Condition="second.type_ == 0 &amp;&amp; true">null</DisplayString>
          <DisplayString Condition="second.type_ == 1 &amp;&amp; true">{second.value_.int_}</DisplayString>
          <DisplayString Condition="second.type_ == 2 &amp;&amp; true">{second.value_.uint_}</DisplayString>
          <DisplayString Condition="second.type_ == 3 &amp;&amp; true">{second.value_.real_}</DisplayString>
          <DisplayString Condition="second.type_ == 4 &amp;&amp; true">{second.value_.string_,s8}</DisplayString>
          <DisplayString Condition="second.type_ == 5 &amp;&amp; true">{second.value_.bool_}</DisplayString>
          <DisplayString Condition="second.type_ == 6 &amp;&amp; true">array({second.value_.map_-&gt;_Mypair._Myval2._Myval2._Mysize})</DisplayString>
          <DisplayString Condition="second.type_ == 7 &amp;&amp; true">object({second.value_.map_-&gt;_Mypair._Myval2._Myval2._Mysize})</DisplayString>
          <StringView Condition="second.type_ == 1 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
          <StringView Condition="second.type_ == 2 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
          <StringView Condition="second.type_ == 3 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
          <StringView Condition="second.type_ == 4 &amp;&amp; true">second.value_.string_,s8</StringView>
          <StringView Condition="second.type_ == 5 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
          <StringView Condition="second.type_ == 6 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
          <StringView Condition="second.type_ == 7 &amp;&amp; first.cstr_ != nullptr">first.cstr_,s8</StringView>
          <Expand>
            <ExpandedItem Condition="second.type_ == 6">*(second.value_.map_),view(jsoncpp)</ExpandedItem>
            <ExpandedItem Condition="second.type_ == 7">*(second.value_.map_),view(jsoncpp)</ExpandedItem>
          </Expand>
        </Type>
      
        <Type Name="Json::Value">
          <Expand>
            <ExpandedItem Condition="type_ == 6">*(value_.map_),view(jsoncpp)</ExpandedItem>
            <ExpandedItem Condition="type_ == 7">*(value_.map_),view(jsoncpp)</ExpandedItem>
          </Expand>
        </Type>
      </AutoVisualizer>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-07-09
        • 1970-01-01
        • 2016-05-25
        • 2011-11-29
        • 1970-01-01
        • 2010-09-10
        • 2010-10-29
        • 1970-01-01
        相关资源
        最近更新 更多