Skip to content

Converts classes/structs to a natvis format. This is to aid in quickly trying to convert classes/structures into a format which is fairly readable.

License

Notifications You must be signed in to change notification settings

Ma-XX-oN/class2natvis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

class2natvis

Brief Description

Converts classes/structs to a natvis format.

Detail

Having to convert a class or a struct to a natvis type representation is a bit of a PITA if you want to include all of the elements, want to be reminded as to what the types are being represented, get rid of all the function declarations/definitions and convert any comments or anything not recognised to comments.

This uses AutoHotKey to aid in quickly trying to convert classes/structures into a format which is still fairly readable.

I got tired of doing this manually so I used my knowledge of AHK and its regex engine to convert a class/struct to a natvis tag format.

Usage

Highlight a complete copy of the class/struct where you want it to be converted, and then press Ctrl-Shift-2. This will then replace the highlighted copy with the natvis block.

The indent character(s) is/are the leading whitespace(s) located directly to the left of the class/struct definition.

I normally do this directly in my .natvis file, but this will work in any editor, in any file.

Quick Start

  1. Clone this repository in your Documents folder.

  2. Download and install AutoHotKey if you haven't already.

  3. In your %USERPROFILE%\Documents\AutoHotKey.ahk file, add to the end of the file:

    #include %A_LineFile%\..\class2natvis\natvis.ahk
    

    and save it.

  4. Reload the AHK script

  5. Go to your system tray and find the green H icon.

  6. Right click on it and select Reload This Script.

  7. Now try it out! :)

Test Case

class testClass : public baseClass
{
  int function(LPCTSTR param1);
  int function(LPCTSTR param2, int value)
  {
    /* some code here */
  }
  LPCSTR const strings[3];  // some LPCSTR strings
}
<Type Name='testClass'>
  <DisplayString ExcludeView='preview'>{*this, view(preview)}</DisplayString>
  <Expand>
    <Item Name='baseClass [base]' ExcludeView='preview'>(baseClass*)this, nd</Item>
    <!-- LPCSTR const [3] -->
    <Item Name='strings'>strings</Item>  <!-- some LPCSTR strings -->
  </Expand>
</Type>

Caveats

At the moment, this doesn't recognise function pointers or nested classes/struct, anonymous classes/structs and will convert only one class/struct at a time. There may be some ways that I've not thought of which may not recognising certain constructs. Feel free to leave a bug report or add a fix. I'm not very sure how the push/pull thing works on git so please be patient.

About

Converts classes/structs to a natvis format. This is to aid in quickly trying to convert classes/structures into a format which is fairly readable.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published