Class CString

java.lang.Object
com.sun.jna.PointerType
org.libvirt.jna.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(com.sun.jna.Pointer p)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Free the memory used by this C-String
    fromNative(Object nativeValue, com.sun.jna.FromNativeContext context)
     
    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 Details

    • CString

      public CString()
    • CString

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

    • toString

      public 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(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