Package ghidra.program.model.data
Class StringRenderParser
java.lang.Object
ghidra.program.model.data.StringRenderParser
A parser to invert
StringDataInstance.getStringRepresentation(),
StringDataInstance.getCharRepresentation(), and related.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn exception for when a string representation cannot be parsed. -
Constructor Summary
ConstructorsConstructorDescriptionStringRenderParser(char quoteChar, Endian endian, String charsetName, boolean includeBOM) Construct a parser -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidencodeChar(ByteBuffer out, char c) protected voidencodeCodePoint(ByteBuffer out, int cp) voidfinish(ByteBuffer out) Finish parsing and encoded a string or character representationprotected voidinitCharset(ByteBuffer out, String reprCharsetName) voidparse(ByteBuffer out, CharBuffer in) Parse and encode a portion of a string or character representationparse(CharBuffer in) Parse and encode a complete string or character representationprotected ghidra.program.model.data.StringRenderParser.StateparseChar(ByteBuffer out, char c) protected ghidra.program.model.data.StringRenderParser.StateparseCharByte(ByteBuffer out, char c) protected ghidra.program.model.data.StringRenderParser.StateparseCharByteSuffix(ByteBuffer out, char c) protected ghidra.program.model.data.StringRenderParser.StateparseCharCodePoint(ByteBuffer out, char c) protected ghidra.program.model.data.StringRenderParser.StateparseCharComma(ByteBuffer out, char c) protected ghidra.program.model.data.StringRenderParser.StateparseCharEscape(ByteBuffer out, char c) protected ghidra.program.model.data.StringRenderParser.StateparseCharInit(ByteBuffer out, char c) protected ghidra.program.model.data.StringRenderParser.StateparseCharPrefix(ByteBuffer out, char c) protected ghidra.program.model.data.StringRenderParser.StateparseCharStr(ByteBuffer out, char c) protected ghidra.program.model.data.StringRenderParser.StateparseCharUnit(ByteBuffer out, char c) voidreset()Reset the parserprotected intvalHexDigit(char c)
-
Constructor Details
-
StringRenderParser
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 stringscharsetName- the character set name, as inCharset.forName(String)includeBOM- true to prepend a byte order marker, if applicable
-
-
Method Details
-
reset
public void reset()Reset the parser -
initCharset
-
valHexDigit
protected int valHexDigit(char c) -
parseCharInit
-
parseCharPrefix
protected ghidra.program.model.data.StringRenderParser.State parseCharPrefix(ByteBuffer out, char c) -
parseCharUnit
-
encodeCodePoint
protected void encodeCodePoint(ByteBuffer out, int cp) throws MalformedInputException, UnmappableCharacterException -
encodeChar
protected void encodeChar(ByteBuffer out, char c) throws MalformedInputException, UnmappableCharacterException -
encodeBufferedCodePoint
protected void encodeBufferedCodePoint(ByteBuffer out) throws MalformedInputException, UnmappableCharacterException -
parseCharStr
protected ghidra.program.model.data.StringRenderParser.State parseCharStr(ByteBuffer out, char c) throws MalformedInputException, UnmappableCharacterException -
parseCharByte
-
parseCharByteSuffix
protected ghidra.program.model.data.StringRenderParser.State parseCharByteSuffix(ByteBuffer out, char c) -
parseCharComma
-
parseCharEscape
protected ghidra.program.model.data.StringRenderParser.State parseCharEscape(ByteBuffer out, char c) throws MalformedInputException, UnmappableCharacterException -
parseCharCodePoint
protected ghidra.program.model.data.StringRenderParser.State parseCharCodePoint(ByteBuffer out, char c) throws MalformedInputException, UnmappableCharacterException -
parseChar
protected ghidra.program.model.data.StringRenderParser.State parseChar(ByteBuffer out, char c) 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 parsedMalformedInputException- if a character sequence in the representation is not validUnmappableCharacterException- 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 parsedMalformedInputException- if a character sequence in the representation is not validUnmappableCharacterException- if a character cannot be encoded
-
finish
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
-