Class StringRenderParser

    • 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 representation
      protected 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 representation
      java.nio.ByteBuffer parse​(java.nio.CharBuffer in)
      Parse and encode a complete string or character representation
      protected 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 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 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 strings
        charsetName - the character set name, as in Charset.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 parsed
        java.nio.charset.MalformedInputException - if a character sequence in the representation is not valid
        java.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 parsed
        java.nio.charset.MalformedInputException - if a character sequence in the representation is not valid
        java.nio.charset.UnmappableCharacterException - if a character cannot be encoded