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`

- ## 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()`
  `List<ClangLine>`
  `getLines()`
  Returns a list of the C language lines contained in the C language token group.
  `static String`
  `getText(ClangLine line)`
  Returns the text of the given line as seen in the UI.
  `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
    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 List<ClangLine> getLines()
    Returns a list of the C language lines contained in the C language token group.
    Returns:
      a 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

  - ### getText

    public static String getText(ClangLine line)
    Returns the text of the given line as seen in the UI.
    Parameters:
      `line` - the line
    Returns:
      the text