Class: Ronin::Support::Binary::CTypes::AggregateType Private

Inherits:
Type
  • Object
show all
Defined in:
lib/ronin/support/binary/ctypes/aggregate_type.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Base class for all aggregate types.

Since:

  • 1.0.0

Direct Known Subclasses

ArrayType, StructType, UnboundedArrayType, UnionType

Instance Attribute Summary

Attributes inherited from Type

#pack_string

Instance Method Summary collapse

Methods inherited from Type

#[], #align, #alignment, #dequeue_value, #enqueue_value, #initialize, #size, #uninitialized_value

Constructor Details

This class inherits a constructor from Ronin::Support::Binary::CTypes::Type

Instance Method Details

#lengthInteger, Float::INFINITY

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method is abstract.

The number of elements within the aggregate type.

Returns:

Raises:

  • (NotImplementedError)

Since:

  • 1.0.0



41
42
43
# File 'lib/ronin/support/binary/ctypes/aggregate_type.rb', line 41

def length
  raise(NotImplementedError,"#{self.class}##{__method__} was not implemented")
end

#pack(value) ⇒ String

Packs the value into the aggregate type's binary format.

Parameters:

Returns:

  • (String)

    The packed binary data.

Raises:

Since:

  • 1.0.0



59
60
61
62
63
64
65
66
67
68
# File 'lib/ronin/support/binary/ctypes/aggregate_type.rb', line 59

def pack(value)
  if @pack_string
    values = []
    enqueue_value(values,value)

    return values.pack(@pack_string)
  else
    raise(NotImplementedError,"#{self.class} does not define a #pack_string")
  end
end

#unpack(data) ⇒ Integer, ...

Unpacks the binary data.

Parameters:

  • data (String)

    The binary data to unpack.

Returns:

Raises:

Since:

  • 1.0.0



84
85
86
87
88
89
90
91
92
# File 'lib/ronin/support/binary/ctypes/aggregate_type.rb', line 84

def unpack(data)
  if @pack_string
    values = data.unpack(@pack_string)

    return dequeue_value(values)
  else
    raise(NotImplementedError,"#{self.class} does not define a #pack_string")
  end
end