Package ghidra.app.decompiler

# Class PrettyPrinter

java.lang.Object
ghidra.app.decompiler.PrettyPrinter

public class PrettyPrinter extends Object
This class is used to convert a C/C++ language token group into readable C/C++ code.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `INDENT_STRING`
  The indent string to use when printing.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PrettyPrinter(Function function, ClangTokenGroup tokgroup, NameTransformer transformer)`
  Constructs a new pretty printer using the specified C language token group.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Function`
  `getFunction()`
  `ArrayList<ClangLine>`
  `getLines()`
  Returns an array list of the C language lines contained in the C language token group.
  `DecompiledFunction`
  `print()`
  Prints the C language token group into a string of C code.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### INDENT_STRING

    public static final String INDENT_STRING
    The indent string to use when printing.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### PrettyPrinter

    public PrettyPrinter(Function function, ClangTokenGroup tokgroup, NameTransformer transformer)
    Constructs a new pretty printer using the specified C language token group. The printer takes a NameTransformer that will be applied to symbols, which can replace illegal characters in the symbol name for instance. A null indicates no transform is applied.
    Parameters:
      `function` - is the function to be printed
      `tokgroup` - the C language token group
      `transformer` - the transformer to apply to symbols

- ## Method Details

  - ### getFunction

    public Function getFunction()

  - ### getLines

    public ArrayList<ClangLine> getLines()
    Returns an array list of the C language lines contained in the C language token group.
    Returns:
      an array list of the C language lines

  - ### print

    public DecompiledFunction print()
    Prints the C language token group into a string of C code.
    Returns:
      a string of readable C code