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
Modifier and TypeClassDescriptionstatic class
An exception for when a string representation cannot be parsed. -
Constructor Summary
ConstructorDescriptionStringRenderParser
(char quoteChar, Endian endian, String charsetName, boolean includeBOM) Construct a parser -
Method Summary
Modifier and TypeMethodDescriptionprotected void
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 representationprotected void
initCharset
(ByteBuffer out, String reprCharsetName) void
parse
(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.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 parserprotected int
valHexDigit
(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
-