Package ghidra.program.model.data
Class StringRenderParser
- java.lang.Object
-
- ghidra.program.model.data.StringRenderParser
-
public class StringRenderParser extends java.lang.Object
A parser to invertStringDataInstance.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, java.lang.String charsetName, boolean includeBOM)
Construct a parser
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
encodeBufferedCodePoint(java.nio.ByteBuffer out)
protected void
encodeChar(java.nio.ByteBuffer out, char c)
protected void
encodeCodePoint(java.nio.ByteBuffer out, int cp)
void
finish(java.nio.ByteBuffer out)
Finish parsing and encoded a string or character representationprotected void
initCharset(java.nio.ByteBuffer out, java.lang.String reprCharsetName)
void
parse(java.nio.ByteBuffer out, java.nio.CharBuffer in)
Parse and encode a portion of a string or character representationjava.nio.ByteBuffer
parse(java.nio.CharBuffer in)
Parse and encode a complete string or character representationprotected ghidra.program.model.data.StringRenderParser.State
parseChar(java.nio.ByteBuffer out, char c)
protected ghidra.program.model.data.StringRenderParser.State
parseCharByte(java.nio.ByteBuffer out, char c)
protected ghidra.program.model.data.StringRenderParser.State
parseCharByteSuffix(java.nio.ByteBuffer out, char c)
protected ghidra.program.model.data.StringRenderParser.State
parseCharCodePoint(java.nio.ByteBuffer out, char c)
protected ghidra.program.model.data.StringRenderParser.State
parseCharComma(java.nio.ByteBuffer out, char c)
protected ghidra.program.model.data.StringRenderParser.State
parseCharEscape(java.nio.ByteBuffer out, char c)
protected ghidra.program.model.data.StringRenderParser.State
parseCharInit(java.nio.ByteBuffer out, char c)
protected ghidra.program.model.data.StringRenderParser.State
parseCharPrefix(java.nio.ByteBuffer out, char c)
protected ghidra.program.model.data.StringRenderParser.State
parseCharStr(java.nio.ByteBuffer out, char c)
protected ghidra.program.model.data.StringRenderParser.State
parseCharUnit(java.nio.ByteBuffer out, char c)
void
reset()
Reset the parserprotected int
valHexDigit(char c)
-
-
-
Constructor Detail
-
StringRenderParser
public StringRenderParser(char quoteChar, Endian endian, java.lang.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 stringscharsetName
- the character set name, as inCharset.forName(String)
includeBOM
- true to prepend a byte order marker, if applicable
-
-
Method Detail
-
reset
public void reset()
Reset the parser
-
initCharset
protected void initCharset(java.nio.ByteBuffer out, java.lang.String reprCharsetName)
-
valHexDigit
protected int valHexDigit(char c)
-
parseCharInit
protected ghidra.program.model.data.StringRenderParser.State parseCharInit(java.nio.ByteBuffer out, char c)
-
parseCharPrefix
protected ghidra.program.model.data.StringRenderParser.State parseCharPrefix(java.nio.ByteBuffer out, char c)
-
parseCharUnit
protected ghidra.program.model.data.StringRenderParser.State parseCharUnit(java.nio.ByteBuffer out, char c)
-
encodeCodePoint
protected void encodeCodePoint(java.nio.ByteBuffer out, int cp) throws java.nio.charset.MalformedInputException, java.nio.charset.UnmappableCharacterException
- Throws:
java.nio.charset.MalformedInputException
java.nio.charset.UnmappableCharacterException
-
encodeChar
protected void encodeChar(java.nio.ByteBuffer out, char c) throws java.nio.charset.MalformedInputException, java.nio.charset.UnmappableCharacterException
- Throws:
java.nio.charset.MalformedInputException
java.nio.charset.UnmappableCharacterException
-
encodeBufferedCodePoint
protected void encodeBufferedCodePoint(java.nio.ByteBuffer out) throws java.nio.charset.MalformedInputException, java.nio.charset.UnmappableCharacterException
- Throws:
java.nio.charset.MalformedInputException
java.nio.charset.UnmappableCharacterException
-
parseCharStr
protected ghidra.program.model.data.StringRenderParser.State parseCharStr(java.nio.ByteBuffer out, char c) throws java.nio.charset.MalformedInputException, java.nio.charset.UnmappableCharacterException
- Throws:
java.nio.charset.MalformedInputException
java.nio.charset.UnmappableCharacterException
-
parseCharByte
protected ghidra.program.model.data.StringRenderParser.State parseCharByte(java.nio.ByteBuffer out, char c)
-
parseCharByteSuffix
protected ghidra.program.model.data.StringRenderParser.State parseCharByteSuffix(java.nio.ByteBuffer out, char c)
-
parseCharComma
protected ghidra.program.model.data.StringRenderParser.State parseCharComma(java.nio.ByteBuffer out, char c)
-
parseCharEscape
protected ghidra.program.model.data.StringRenderParser.State parseCharEscape(java.nio.ByteBuffer out, char c) throws java.nio.charset.MalformedInputException, java.nio.charset.UnmappableCharacterException
- Throws:
java.nio.charset.MalformedInputException
java.nio.charset.UnmappableCharacterException
-
parseCharCodePoint
protected ghidra.program.model.data.StringRenderParser.State parseCharCodePoint(java.nio.ByteBuffer out, char c) throws java.nio.charset.MalformedInputException, java.nio.charset.UnmappableCharacterException
- Throws:
java.nio.charset.MalformedInputException
java.nio.charset.UnmappableCharacterException
-
parseChar
protected ghidra.program.model.data.StringRenderParser.State parseChar(java.nio.ByteBuffer out, char c) throws java.nio.charset.MalformedInputException, java.nio.charset.UnmappableCharacterException
- Throws:
java.nio.charset.MalformedInputException
java.nio.charset.UnmappableCharacterException
-
parse
public java.nio.ByteBuffer parse(java.nio.CharBuffer in) throws StringRenderParser.StringParseException, java.nio.charset.MalformedInputException, java.nio.charset.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 parsedjava.nio.charset.MalformedInputException
- if a character sequence in the representation is not validjava.nio.charset.UnmappableCharacterException
- if a character cannot be encoded
-
parse
public void parse(java.nio.ByteBuffer out, java.nio.CharBuffer in) throws StringRenderParser.StringParseException, java.nio.charset.MalformedInputException, java.nio.charset.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 parsedjava.nio.charset.MalformedInputException
- if a character sequence in the representation is not validjava.nio.charset.UnmappableCharacterException
- if a character cannot be encoded
-
finish
public void finish(java.nio.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
-
-