Class spng_chunk

All Implemented Interfaces:
AutoCloseable, NativeResource, Pointer

public class spng_chunk extends Struct<spng_chunk> implements NativeResource

 struct spng_chunk {
     size_t offset;
     uint32_t length;
     uint8_t type[4];
     uint32_t crc;
 }
  • Field Details

    • SIZEOF

      public static final int SIZEOF
      The struct size in bytes.
    • ALIGNOF

      public static final int ALIGNOF
      The struct alignment in bytes.
    • OFFSET

      public static final int OFFSET
      The struct member offsets.
    • LENGTH

      public static final int LENGTH
      The struct member offsets.
    • TYPE

      public static final int TYPE
      The struct member offsets.
    • CRC

      public static final int CRC
      The struct member offsets.
  • Constructor Details

    • spng_chunk

      public spng_chunk(ByteBuffer container)
      Creates a spng_chunk instance at the current position of the specified ByteBuffer container. Changes to the buffer's content will be visible to the struct instance and vice versa.

      The created instance holds a strong reference to the container object.

  • Method Details

    • sizeof

      public int sizeof()
      Description copied from class: Struct
      Returns sizeof(struct).
      Specified by:
      sizeof in class Struct<spng_chunk>
    • offset

      public long offset()
      Returns:
      the value of the offset field.
    • length

      public int length()
      Returns:
      the value of the length field.
    • type

      public ByteBuffer type()
      Returns:
      a ByteBuffer view of the type field.
    • type

      public byte type(int index)
      Returns:
      the value at the specified index of the type field.
    • crc

      public int crc()
      Returns:
      the value of the crc field.
    • offset

      public spng_chunk offset(long value)
      Sets the specified value to the offset field.
    • length

      public spng_chunk length(int value)
      Sets the specified value to the length field.
    • type

      public spng_chunk type(ByteBuffer value)
      Copies the specified ByteBuffer to the type field.
    • type

      public spng_chunk type(int index, byte value)
      Sets the specified value at the specified index of the type field.
    • crc

      public spng_chunk crc(int value)
      Sets the specified value to the crc field.
    • set

      public spng_chunk set(long offset, int length, ByteBuffer type, int crc)
      Initializes this struct with the specified values.
    • set

      public spng_chunk set(spng_chunk src)
      Copies the specified struct data to this struct.
      Parameters:
      src - the source struct
      Returns:
      this struct
    • malloc

      public static spng_chunk malloc()
      Returns a new spng_chunk instance allocated with memAlloc. The instance must be explicitly freed.
    • calloc

      public static spng_chunk calloc()
      Returns a new spng_chunk instance allocated with memCalloc. The instance must be explicitly freed.
    • create

      public static spng_chunk create()
      Returns a new spng_chunk instance allocated with BufferUtils.
    • create

      public static spng_chunk create(long address)
      Returns a new spng_chunk instance for the specified memory address.
    • createSafe

      public static @Nullable spng_chunk createSafe(long address)
      Like create, but returns null if address is NULL.
    • malloc

      public static spng_chunk.Buffer malloc(int capacity)
      Returns a new spng_chunk.Buffer instance allocated with memAlloc. The instance must be explicitly freed.
      Parameters:
      capacity - the buffer capacity
    • calloc

      public static spng_chunk.Buffer calloc(int capacity)
      Returns a new spng_chunk.Buffer instance allocated with memCalloc. The instance must be explicitly freed.
      Parameters:
      capacity - the buffer capacity
    • create

      public static spng_chunk.Buffer create(int capacity)
      Returns a new spng_chunk.Buffer instance allocated with BufferUtils.
      Parameters:
      capacity - the buffer capacity
    • create

      public static spng_chunk.Buffer create(long address, int capacity)
      Create a spng_chunk.Buffer instance at the specified memory.
      Parameters:
      address - the memory address
      capacity - the buffer capacity
    • createSafe

      public static @Nullable spng_chunk.Buffer createSafe(long address, int capacity)
      Like create, but returns null if address is NULL.
    • malloc

      public static spng_chunk malloc(MemoryStack stack)
      Returns a new spng_chunk instance allocated on the specified MemoryStack.
      Parameters:
      stack - the stack from which to allocate
    • calloc

      public static spng_chunk calloc(MemoryStack stack)
      Returns a new spng_chunk instance allocated on the specified MemoryStack and initializes all its bits to zero.
      Parameters:
      stack - the stack from which to allocate
    • malloc

      public static spng_chunk.Buffer malloc(int capacity, MemoryStack stack)
      Returns a new spng_chunk.Buffer instance allocated on the specified MemoryStack.
      Parameters:
      capacity - the buffer capacity
      stack - the stack from which to allocate
    • calloc

      public static spng_chunk.Buffer calloc(int capacity, MemoryStack stack)
      Returns a new spng_chunk.Buffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
      Parameters:
      capacity - the buffer capacity
      stack - the stack from which to allocate
    • noffset

      public static long noffset(long struct)
      Unsafe version of offset().
    • nlength

      public static int nlength(long struct)
      Unsafe version of length().
    • ntype

      public static ByteBuffer ntype(long struct)
      Unsafe version of type().
    • ntype

      public static byte ntype(long struct, int index)
      Unsafe version of type.
    • ncrc

      public static int ncrc(long struct)
      Unsafe version of crc().
    • noffset

      public static void noffset(long struct, long value)
      Unsafe version of offset.
    • nlength

      public static void nlength(long struct, int value)
      Unsafe version of length.
    • ntype

      public static void ntype(long struct, ByteBuffer value)
      Unsafe version of type.
    • ntype

      public static void ntype(long struct, int index, byte value)
      Unsafe version of type.
    • ncrc

      public static void ncrc(long struct, int value)
      Unsafe version of crc.