Class CString

  • All Implemented Interfaces:
    com.sun.jna.NativeMapped

    public class CString
    extends com.sun.jna.PointerType
    Represents an allocated C-String.

    Either call toString() or free(). Both methods make sure to reclaim the memory allocated for the string by calling Native.free.

    • Constructor Summary

      Constructors 
      Constructor Description
      CString()  
      CString​(com.sun.jna.Pointer p)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void free()
      Free the memory used by this C-String
      CString fromNative​(java.lang.Object nativeValue, com.sun.jna.FromNativeContext context)  
      java.lang.String toString()
      Returns a String representing the value of this C-String
      • Methods inherited from class com.sun.jna.PointerType

        equals, getPointer, hashCode, nativeType, setPointer, toNative
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CString

        public CString()
      • CString

        public CString​(com.sun.jna.Pointer p)
    • Method Detail

      • toString

        public java.lang.String toString()
        Returns a String representing the value of this C-String

        Side-effect: frees the memory of the C-String.

        Overrides:
        toString in class com.sun.jna.PointerType
        Returns:
        String represented by C-String or "(null)"
      • fromNative

        public CString fromNative​(java.lang.Object nativeValue,
                                  com.sun.jna.FromNativeContext context)
        Specified by:
        fromNative in interface com.sun.jna.NativeMapped
        Overrides:
        fromNative in class com.sun.jna.PointerType
      • free

        public void free()
        Free the memory used by this C-String