Package ghidra.program.model.data

# Class StringRenderParser

java.lang.Object
ghidra.program.model.data.StringRenderParser

public class StringRenderParser extends Object
A parser to invert `StringDataInstance.getStringRepresentation()`, `StringDataInstance.getCharRepresentation()`, and related.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `StringRenderParser.StringParseException`
  An exception for when a string representation cannot be parsed.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StringRenderParser(char quoteChar, Endian endian, String charsetName, boolean includeBOM)`
  Construct a parser

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `encodeBufferedCodePoint(ByteBuffer out)`
  `protected void`
  `encodeChar(ByteBuffer out, char c)`
  `protected void`
  `encodeCodePoint(ByteBuffer out, int cp)`
  `void`
  `finish(ByteBuffer out)`
  Finish parsing and encoded a string or character representation
  `protected void`
  `initCharset(ByteBuffer out, String reprCharsetName)`
  `void`
  `parse(ByteBuffer out, CharBuffer in)`
  Parse and encode a portion of a string or character representation
  `ByteBuffer`
  `parse(CharBuffer in)`
  Parse and encode a complete string or character representation
  `protected ghidra.program.model.data.StringRenderParser.State`
  `parseChar(ByteBuffer out, char c)`
  `protected ghidra.program.model.data.StringRenderParser.State`
  `parseCharByte(ByteBuffer out, char c)`
  `protected ghidra.program.model.data.StringRenderParser.State`
  `parseCharByteSuffix(ByteBuffer out, char c)`
  `protected ghidra.program.model.data.StringRenderParser.State`
  `parseCharCodePoint(ByteBuffer out, char c)`
  `protected ghidra.program.model.data.StringRenderParser.State`
  `parseCharComma(ByteBuffer out, char c)`
  `protected ghidra.program.model.data.StringRenderParser.State`
  `parseCharEscape(ByteBuffer out, char c)`
  `protected ghidra.program.model.data.StringRenderParser.State`
  `parseCharInit(ByteBuffer out, char c)`
  `protected ghidra.program.model.data.StringRenderParser.State`
  `parseCharPrefix(ByteBuffer out, char c)`
  `protected ghidra.program.model.data.StringRenderParser.State`
  `parseCharStr(ByteBuffer out, char c)`
  `protected ghidra.program.model.data.StringRenderParser.State`
  `parseCharUnit(ByteBuffer out, char c)`
  `void`
  `reset()`
  Reset the parser
  `protected int`
  `valHexDigit(char c)`

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

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

- ## Constructor Details

  - ### StringRenderParser

    public StringRenderParser(char quoteChar, Endian endian, String charsetName, boolean includeBOM)
    Construct a parser
    Parameters:
      `quoteChar` - the character expected to enclose the representation. Use double quote (") for strings. Use single quote (') for characters.
      `endian` - the endian for unicode strings
      `charsetName` - the character set name, as in `Charset.forName(String)`
      `includeBOM` - true to prepend a byte order marker, if applicable

- ## Method Details

  - ### reset

    public void reset()
    Reset the parser

  - ### initCharset

    protected void initCharset(ByteBuffer out, String reprCharsetName)

  - ### valHexDigit

    protected int valHexDigit(char c)

  - ### parseCharInit

    protected ghidra.program.model.data.StringRenderParser.State parseCharInit(ByteBuffer out, char c)

  - ### parseCharPrefix

    protected ghidra.program.model.data.StringRenderParser.State parseCharPrefix(ByteBuffer out, char c)

  - ### parseCharUnit

    protected ghidra.program.model.data.StringRenderParser.State parseCharUnit(ByteBuffer out, char c)

  - ### encodeCodePoint

    protected void encodeCodePoint(ByteBuffer out, int cp) throws MalformedInputException, UnmappableCharacterException
    Throws:
      `MalformedInputException`
      `UnmappableCharacterException`

  - ### encodeChar

    protected void encodeChar(ByteBuffer out, char c) throws MalformedInputException, UnmappableCharacterException
    Throws:
      `MalformedInputException`
      `UnmappableCharacterException`

  - ### encodeBufferedCodePoint

    protected void encodeBufferedCodePoint(ByteBuffer out) throws MalformedInputException, UnmappableCharacterException
    Throws:
      `MalformedInputException`
      `UnmappableCharacterException`

  - ### parseCharStr

    protected ghidra.program.model.data.StringRenderParser.State parseCharStr(ByteBuffer out, char c) throws MalformedInputException, UnmappableCharacterException
    Throws:
      `MalformedInputException`
      `UnmappableCharacterException`

  - ### parseCharByte

    protected ghidra.program.model.data.StringRenderParser.State parseCharByte(ByteBuffer out, char c)

  - ### parseCharByteSuffix

    protected ghidra.program.model.data.StringRenderParser.State parseCharByteSuffix(ByteBuffer out, char c)

  - ### parseCharComma

    protected ghidra.program.model.data.StringRenderParser.State parseCharComma(ByteBuffer out, char c)

  - ### parseCharEscape

    protected ghidra.program.model.data.StringRenderParser.State parseCharEscape(ByteBuffer out, char c) throws MalformedInputException, UnmappableCharacterException
    Throws:
      `MalformedInputException`
      `UnmappableCharacterException`

  - ### parseCharCodePoint

    protected ghidra.program.model.data.StringRenderParser.State parseCharCodePoint(ByteBuffer out, char c) throws MalformedInputException, UnmappableCharacterException
    Throws:
      `MalformedInputException`
      `UnmappableCharacterException`

  - ### parseChar

    protected ghidra.program.model.data.StringRenderParser.State parseChar(ByteBuffer out, char c) throws MalformedInputException, UnmappableCharacterException
    Throws:
      `MalformedInputException`
      `UnmappableCharacterException`

  - ### parse

    public ByteBuffer parse(CharBuffer in) throws StringRenderParser.StringParseException, MalformedInputException, UnmappableCharacterException
    Parse and encode a complete string or character representation
    Parameters:
      `in` - the buffer containing the representation
    Returns:
      a buffer containing the encoded string or character
    Throws:
      `StringRenderParser.StringParseException` - if the representation could not be parsed
      `MalformedInputException` - if a character sequence in the representation is not valid
      `UnmappableCharacterException` - if a character cannot be encoded

  - ### parse

    public void parse(ByteBuffer out, CharBuffer in) throws StringRenderParser.StringParseException, MalformedInputException, UnmappableCharacterException
    Parse and encode a portion of a string or character representation
    Parameters:
      `out` - the destination buffer for the encoded string or character, having matching byte order to the charset.
      `in` - the source buffer for the representation
    Throws:
      `StringRenderParser.StringParseException` - if the representation could not be parsed
      `MalformedInputException` - if a character sequence in the representation is not valid
      `UnmappableCharacterException` - if a character cannot be encoded

  - ### finish

    public void finish(ByteBuffer out) throws StringRenderParser.StringParseException
    Finish parsing and encoded a string or character representation
    Parameters:
      `out` - the destination buffer for the encoded string or character
    Throws:
      `StringRenderParser.StringParseException` - if the representation is not complete