Class: Ronin::Support::Binary::CTypes::StringType Private
- Defined in:
- lib/ronin/support/binary/ctypes/string_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.
Represents a C string type.
Instance Attribute Summary
Attributes inherited from Type
Instance Method Summary collapse
-
#alignment ⇒ 1
private
The alignment for the string type.
-
#dequeue_value(values) ⇒ String
private
Dequeues a string from the flat list of values.
-
#enqueue_value(values, value) ⇒ Object
private
Enqueues a string onto the flat list of values.
-
#initialize ⇒ StringType
constructor
private
Initializes the string type.
-
#pack(value) ⇒ String
Packs the String into a null-terminated C String.
-
#signed? ⇒ true
private
Indicates that the String contains signed characters.
-
#size ⇒ Float::INFINITY
(also: #length)
private
Indicates that Strings can have arbitrary size.
-
#unpack(data) ⇒ String?
Unpacks a null-terminated C String.
-
#unsigned? ⇒ false
private
Indicates that the String does not contains unsigned characters.
Methods inherited from Type
#[], #align, #uninitialized_value
Constructor Details
#initialize ⇒ StringType
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.
Initializes the string type.
37 38 39 |
# File 'lib/ronin/support/binary/ctypes/string_type.rb', line 37 def initialize super(pack_string: 'Z*') end |
Instance Method Details
#alignment ⇒ 1
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.
The alignment for the string type
57 58 59 |
# File 'lib/ronin/support/binary/ctypes/string_type.rb', line 57 def alignment 1 end |
#dequeue_value(values) ⇒ String
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.
Dequeues a string from the flat list of values.
135 136 137 |
# File 'lib/ronin/support/binary/ctypes/string_type.rb', line 135 def dequeue_value(values) values.shift end |
#enqueue_value(values, value) ⇒ Object
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.
Enqueues a string onto the flat list of values.
120 121 122 |
# File 'lib/ronin/support/binary/ctypes/string_type.rb', line 120 def enqueue_value(values,value) values.push(value) end |
#pack(value) ⇒ String
Packs the String into a null-terminated C String.
90 91 92 |
# File 'lib/ronin/support/binary/ctypes/string_type.rb', line 90 def pack(value) [value].pack(@pack_string) end |
#signed? ⇒ true
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.
Indicates that the String contains signed characters.
66 67 68 |
# File 'lib/ronin/support/binary/ctypes/string_type.rb', line 66 def signed? true end |
#size ⇒ Float::INFINITY Also known as: length
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.
Indicates that Strings can have arbitrary size.
46 47 48 |
# File 'lib/ronin/support/binary/ctypes/string_type.rb', line 46 def size Float::INFINITY end |
#unpack(data) ⇒ String?
Unpacks a null-terminated C String.
105 106 107 |
# File 'lib/ronin/support/binary/ctypes/string_type.rb', line 105 def unpack(data) data.unpack1(@pack_string) end |
#unsigned? ⇒ false
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.
Indicates that the String does not contains unsigned characters.
75 76 77 |
# File 'lib/ronin/support/binary/ctypes/string_type.rb', line 75 def unsigned? false end |