Module: Ronin::Support::Binary::Stream::Methods Private

Included in:
IO, Ronin::Support::Binary::Stream
Defined in:
lib/ronin/support/binary/stream/methods.rb

Overview

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

Adds read_*/write_* methods for reading and writing binary data types.

Since:

  • 1.0.0

Reader Methods collapse

Writer Methods collapse

Instance Method Details

#read_array(type, length) ⇒ Binary::Array

Reads an array of the given type and length from the stream.

Parameters:

  • type (Symbol)

    The element type for the new array.

  • length (Integer)

    The number of elements for the new array.

Returns:

See Also:

Since:

  • 1.0.0



899
900
901
# File 'lib/ronin/support/binary/stream/methods.rb', line 899

def read_array(type,length)
  Array.read_from(self,type,length)
end

#read_array_of(type, count) ⇒ Array<Object>

Reads an array of the given type, starting at the given with the given length.

Parameters:

  • type (Symbol)

    The type of the value to read.

  • count (Integer)

    The number of desired elements within the array.

Returns:

  • (Array<Object>)

    The read array of types.

Since:

  • 1.0.0



436
437
438
439
440
441
442
# File 'lib/ronin/support/binary/stream/methods.rb', line 436

def read_array_of(type,count)
  type       = type_system[type]
  array_type = type[count]
  data       = read(array_type.size)

  return array_type.unpack(data)
end

#read_array_of_byte(count) ⇒ Array<Integer, nil> Also known as: read_bytes

Alias to read_array_of(:byte,count).

Parameters:

  • count (Integer)

    The number of bytes to read.

Returns:

See Also:

Since:

  • 1.0.0



457
458
459
# File 'lib/ronin/support/binary/stream/methods.rb', line 457

def read_array_of_byte(count)
  read_array_of(:byte,count)
end

#read_array_of_char(count) ⇒ Array<Integer, nil> Also known as: read_chars

Alias to read_array_of(:char,count).

Parameters:

  • count (Integer)

    The number of chars to read.

Returns:

See Also:

Since:

  • 1.0.0



476
477
478
# File 'lib/ronin/support/binary/stream/methods.rb', line 476

def read_array_of_char(count)
  read_array_of(:char,count)
end

#read_array_of_double(count) ⇒ Array<Float, nil> Also known as: read_doubles

Alias to read_array_of(:double,count).

Parameters:

  • count (Integer)

    The number of double values to read.

Returns:

  • (Array<Float, nil>)

    The read array of double values.

See Also:

Since:

  • 1.0.0



843
844
845
# File 'lib/ronin/support/binary/stream/methods.rb', line 843

def read_array_of_double(count)
  read_array_of(:double,count)
end

#read_array_of_float(count) ⇒ Array<Float, nil> Also known as: read_floats

Alias to read_array_of(:float,count).

Parameters:

  • count (Integer)

    The number of float values to read.

Returns:

  • (Array<Float, nil>)

    The read array of float values.

See Also:

Since:

  • 1.0.0



824
825
826
# File 'lib/ronin/support/binary/stream/methods.rb', line 824

def read_array_of_float(count)
  read_array_of(:float,count)
end

#read_array_of_float32(count) ⇒ Array<Float, nil>

Alias to read_array_of(:float32,count).

Parameters:

  • count (Integer)

    The number of float32 values to read.

Returns:

  • (Array<Float, nil>)

    The read array of float32 values.

See Also:

Since:

  • 1.0.0



790
791
792
# File 'lib/ronin/support/binary/stream/methods.rb', line 790

def read_array_of_float32(count)
  read_array_of(:float32,count)
end

#read_array_of_float64(count) ⇒ Array<Float, nil>

Alias to read_array_of(:float64,count).

Parameters:

  • count (Integer)

    The number of float64 values to read.

Returns:

  • (Array<Float, nil>)

    The read array of float64 values.

See Also:

Since:

  • 1.0.0



807
808
809
# File 'lib/ronin/support/binary/stream/methods.rb', line 807

def read_array_of_float64(count)
  read_array_of(:float64,count)
end

#read_array_of_int(count) ⇒ Array<Integer, nil> Also known as: read_ints

Alias to read_array_of(:int,count).

Parameters:

  • count (Integer)

    The number of int values to read.

Returns:

See Also:

Since:

  • 1.0.0



667
668
669
# File 'lib/ronin/support/binary/stream/methods.rb', line 667

def read_array_of_int(count)
  read_array_of(:int,count)
end

#read_array_of_int16(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:int16,count).

Parameters:

  • count (Integer)

    The number of int16 values to read.

Returns:

See Also:

Since:

  • 1.0.0



531
532
533
# File 'lib/ronin/support/binary/stream/methods.rb', line 531

def read_array_of_int16(count)
  read_array_of(:int16,count)
end

#read_array_of_int32(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:int32,count).

Parameters:

  • count (Integer)

    The number of int32 values to read.

Returns:

See Also:

Since:

  • 1.0.0



548
549
550
# File 'lib/ronin/support/binary/stream/methods.rb', line 548

def read_array_of_int32(count)
  read_array_of(:int32,count)
end

#read_array_of_int64(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:int64,count).

Parameters:

  • count (Integer)

    The number of int64 values to read.

Returns:

See Also:

Since:

  • 1.0.0



565
566
567
# File 'lib/ronin/support/binary/stream/methods.rb', line 565

def read_array_of_int64(count)
  read_array_of(:int64,count)
end

#read_array_of_int8(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:int8,count).

Parameters:

  • count (Integer)

    The number of int8 values to read.

Returns:

See Also:

Since:

  • 1.0.0



514
515
516
# File 'lib/ronin/support/binary/stream/methods.rb', line 514

def read_array_of_int8(count)
  read_array_of(:int8,count)
end

#read_array_of_long(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:long,count).

Parameters:

  • count (Integer)

    The number of long values to read.

Returns:

See Also:

Since:

  • 1.0.0



686
687
688
# File 'lib/ronin/support/binary/stream/methods.rb', line 686

def read_array_of_long(count)
  read_array_of(:long,count)
end

#read_array_of_long_long(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:long_long,count).

Parameters:

  • count (Integer)

    The number of long_long values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of long_long values.

See Also:

Since:

  • 1.0.0



703
704
705
# File 'lib/ronin/support/binary/stream/methods.rb', line 703

def read_array_of_long_long(count)
  read_array_of(:long_long,count)
end

#read_array_of_short(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:short,count).

Parameters:

  • count (Integer)

    The number of short values to read.

Returns:

See Also:

Since:

  • 1.0.0



650
651
652
# File 'lib/ronin/support/binary/stream/methods.rb', line 650

def read_array_of_short(count)
  read_array_of(:short,count)
end

#read_array_of_uchar(count) ⇒ Array<Integer, nil> Also known as: read_uchars

Alias to read_array_of(:uchar,count).

Parameters:

  • count (Integer)

    The number of unsigned chars to read.

Returns:

  • (Array<Integer, nil>)

    The read array of unsigned chars.

See Also:

Since:

  • 1.0.0



495
496
497
# File 'lib/ronin/support/binary/stream/methods.rb', line 495

def read_array_of_uchar(count)
  read_array_of(:uchar,count)
end

#read_array_of_uint(count) ⇒ Array<Integer, nil> Also known as: read_uints

Alias to read_array_of(:uint,count).

Parameters:

  • count (Integer)

    The number of uint values to read.

Returns:

See Also:

Since:

  • 1.0.0



737
738
739
# File 'lib/ronin/support/binary/stream/methods.rb', line 737

def read_array_of_uint(count)
  read_array_of(:uint,count)
end

#read_array_of_uint16(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:uint16,count).

Parameters:

  • count (Integer)

    The number of uint16 values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of uint16 values.

See Also:

Since:

  • 1.0.0



599
600
601
# File 'lib/ronin/support/binary/stream/methods.rb', line 599

def read_array_of_uint16(count)
  read_array_of(:uint16,count)
end

#read_array_of_uint32(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:uint32,count).

Parameters:

  • count (Integer)

    The number of uint32 values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of uint32 values.

See Also:

Since:

  • 1.0.0



616
617
618
# File 'lib/ronin/support/binary/stream/methods.rb', line 616

def read_array_of_uint32(count)
  read_array_of(:uint32,count)
end

#read_array_of_uint64(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:uint64,count).

Parameters:

  • count (Integer)

    The number of uint64 values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of uint64 values.

See Also:

Since:

  • 1.0.0



633
634
635
# File 'lib/ronin/support/binary/stream/methods.rb', line 633

def read_array_of_uint64(count)
  read_array_of(:uint64,count)
end

#read_array_of_uint8(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:uint8,count).

Parameters:

  • count (Integer)

    The number of uint8 values to read.

Returns:

See Also:

Since:

  • 1.0.0



582
583
584
# File 'lib/ronin/support/binary/stream/methods.rb', line 582

def read_array_of_uint8(count)
  read_array_of(:uint8,count)
end

#read_array_of_ulong(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:ulong,count).

Parameters:

  • count (Integer)

    The number of ulong values to read.

Returns:

See Also:

Since:

  • 1.0.0



756
757
758
# File 'lib/ronin/support/binary/stream/methods.rb', line 756

def read_array_of_ulong(count)
  read_array_of(:ulong,count)
end

#read_array_of_ulong_long(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:ulong_long,count).

Parameters:

  • count (Integer)

    The number of ulong_long values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of ulong_long values.

See Also:

Since:

  • 1.0.0



773
774
775
# File 'lib/ronin/support/binary/stream/methods.rb', line 773

def read_array_of_ulong_long(count)
  read_array_of(:ulong_long,count)
end

#read_array_of_ushort(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:ushort,count).

Parameters:

  • count (Integer)

    The number of ushort values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of ushort values.

See Also:

Since:

  • 1.0.0



720
721
722
# File 'lib/ronin/support/binary/stream/methods.rb', line 720

def read_array_of_ushort(count)
  read_array_of(:ushort,count)
end

#read_buffer(count) ⇒ Buffer

Reads a buffer of count bytes from the stream.

Parameters:

  • count (Integer)

    The number of bytes to read from the stream.

Returns:

  • (Buffer)

    The newly read buffer.

See Also:

Since:

  • 1.0.0



879
880
881
# File 'lib/ronin/support/binary/stream/methods.rb', line 879

def read_buffer(count)
  Buffer.read_from(self,count)
end

#read_byteInteger

Alias for read_value(:byte).

Returns:

See Also:

Since:

  • 1.0.0



70
71
72
# File 'lib/ronin/support/binary/stream/methods.rb', line 70

def read_byte
  read_value(:byte)
end

#read_charString

Alias for read_value(:char).

Returns:

See Also:

Since:

  • 1.0.0



84
85
86
# File 'lib/ronin/support/binary/stream/methods.rb', line 84

def read_char
  read_value(:char)
end

#read_doubleFloat?

Alias for read_value(:double).

Returns:

  • (Float, nil)

    The read double.

See Also:

Since:

  • 1.0.0



417
418
419
# File 'lib/ronin/support/binary/stream/methods.rb', line 417

def read_double
  read_value(:double)
end

#read_floatFloat?

Alias for read_value(:float).

Returns:

  • (Float, nil)

    The read float.

See Also:

Since:

  • 1.0.0



403
404
405
# File 'lib/ronin/support/binary/stream/methods.rb', line 403

def read_float
  read_value(:float)
end

#read_float32Float?

Alias for read_value(:float32).

Returns:

  • (Float, nil)

    The read float32.

See Also:

Since:

  • 1.0.0



375
376
377
# File 'lib/ronin/support/binary/stream/methods.rb', line 375

def read_float32
  read_value(:float32)
end

#read_float64Float?

Alias for read_value(:float64).

Returns:

  • (Float, nil)

    The read float64.

See Also:

Since:

  • 1.0.0



389
390
391
# File 'lib/ronin/support/binary/stream/methods.rb', line 389

def read_float64
  read_value(:float64)
end

#read_intInteger?

Alias for read_value(:int).

Returns:

See Also:

Since:

  • 1.0.0



277
278
279
# File 'lib/ronin/support/binary/stream/methods.rb', line 277

def read_int
  read_value(:int)
end

#read_int16Integer?

Alias for read_value(:int16).

Returns:

  • (Integer, nil)

    The read int16.

See Also:

Since:

  • 1.0.0



165
166
167
# File 'lib/ronin/support/binary/stream/methods.rb', line 165

def read_int16
  read_value(:int16)
end

#read_int32Integer?

Alias for read_value(:int32).

Returns:

  • (Integer, nil)

    The read int32.

See Also:

Since:

  • 1.0.0



179
180
181
# File 'lib/ronin/support/binary/stream/methods.rb', line 179

def read_int32
  read_value(:int32)
end

#read_int64Integer?

Alias for read_value(:int64).

Returns:

  • (Integer, nil)

    The read int64.

See Also:

Since:

  • 1.0.0



193
194
195
# File 'lib/ronin/support/binary/stream/methods.rb', line 193

def read_int64
  read_value(:int64)
end

#read_int8Integer?

Alias for read_value(:int8).

Returns:

  • (Integer, nil)

    The read int8.

See Also:

Since:

  • 1.0.0



151
152
153
# File 'lib/ronin/support/binary/stream/methods.rb', line 151

def read_int8
  read_value(:int8)
end

#read_into(memory) ⇒ Buffer, ...

Reads data from the stream into the memory object.

Parameters:

Returns:

See Also:

Since:

  • 1.0.0



862
863
864
# File 'lib/ronin/support/binary/stream/methods.rb', line 862

def read_into(memory)
  memory.read_from(self)
end

#read_longInteger?

Alias for read_value(:long).

Returns:

  • (Integer, nil)

    The read long.

See Also:

Since:

  • 1.0.0



291
292
293
# File 'lib/ronin/support/binary/stream/methods.rb', line 291

def read_long
  read_value(:long)
end

#read_long_longInteger?

Alias for read_value(:long_long).

Returns:

  • (Integer, nil)

    The read long_long.

See Also:

Since:

  • 1.0.0



305
306
307
# File 'lib/ronin/support/binary/stream/methods.rb', line 305

def read_long_long
  read_value(:long_long)
end

#read_shortInteger?

Alias for read_value(:short).

Returns:

  • (Integer, nil)

    The read short.

See Also:

Since:

  • 1.0.0



263
264
265
# File 'lib/ronin/support/binary/stream/methods.rb', line 263

def read_short
  read_value(:short)
end

#read_string(length = nil) ⇒ String

Reads a null-byte terminated C string from the buffer.

Parameters:

  • length (Integer, nil) (defaults to: nil)

    The optional maximum desired length of the string.

Returns:

  • (String)

    The read C string, without the null-byte.

Since:

  • 1.0.0



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/ronin/support/binary/stream/methods.rb', line 113

def read_string(length=nil)
  new_string = if (encoding = external_encoding)
                 String.new('', encoding: encoding)
               else
                 String.new('')
               end

  if length
    length.times do
      if eof? || ((c = read(1)) == "\0")
        break
      end

      new_string << c
    end
  else
    until eof?
      if ((c = read(1)) == "\0")
        break
      end

      new_string << c
    end
  end

  return new_string
end

#read_struct(struct_class) ⇒ Binary::Struct

Reads a struct from the stream.

Parameters:

Returns:

See Also:

Since:

  • 1.0.0



916
917
918
# File 'lib/ronin/support/binary/stream/methods.rb', line 916

def read_struct(struct_class)
  struct_class.read_from(self)
end

#read_ucharString

Alias for read_value(:uchar).

Returns:

  • (String)

    The read uchar.

See Also:

Since:

  • 1.0.0



98
99
100
# File 'lib/ronin/support/binary/stream/methods.rb', line 98

def read_uchar
  read_value(:uchar)
end

#read_uintInteger?

Alias for read_value(:uint).

Returns:

  • (Integer, nil)

    The read uint.

See Also:

Since:

  • 1.0.0



333
334
335
# File 'lib/ronin/support/binary/stream/methods.rb', line 333

def read_uint
  read_value(:uint)
end

#read_uint16Integer?

Alias for read_value(:uint16).

Returns:

  • (Integer, nil)

    The read uint16.

See Also:

Since:

  • 1.0.0



221
222
223
# File 'lib/ronin/support/binary/stream/methods.rb', line 221

def read_uint16
  read_value(:uint16)
end

#read_uint32Integer?

Alias for read_value(:uint32).

Returns:

  • (Integer, nil)

    The read uint32.

See Also:

Since:

  • 1.0.0



235
236
237
# File 'lib/ronin/support/binary/stream/methods.rb', line 235

def read_uint32
  read_value(:uint32)
end

#read_uint64Integer?

Alias for read_value(:uint64).

Returns:

  • (Integer, nil)

    The read uint64.

See Also:

Since:

  • 1.0.0



249
250
251
# File 'lib/ronin/support/binary/stream/methods.rb', line 249

def read_uint64
  read_value(:uint64)
end

#read_uint8Integer?

Alias for read_value(:uint8).

Returns:

  • (Integer, nil)

    The read uint8.

See Also:

Since:

  • 1.0.0



207
208
209
# File 'lib/ronin/support/binary/stream/methods.rb', line 207

def read_uint8
  read_value(:uint8)
end

#read_ulongInteger?

Alias for read_value(:ulong).

Returns:

  • (Integer, nil)

    The read ulong.

See Also:

Since:

  • 1.0.0



347
348
349
# File 'lib/ronin/support/binary/stream/methods.rb', line 347

def read_ulong
  read_value(:ulong)
end

#read_ulong_longInteger?

Alias for read_value(:ulong_long).

Returns:

  • (Integer, nil)

    The read ulong_long.

See Also:

Since:

  • 1.0.0



361
362
363
# File 'lib/ronin/support/binary/stream/methods.rb', line 361

def read_ulong_long
  read_value(:ulong_long)
end

#read_union(union_class) ⇒ Binary::Union

Reads a union from the stream.

Parameters:

Returns:

See Also:

Since:

  • 1.0.0



933
934
935
# File 'lib/ronin/support/binary/stream/methods.rb', line 933

def read_union(union_class)
  union_class.read_from(self)
end

#read_ushortInteger?

Alias for read_value(:ushort).

Returns:

  • (Integer, nil)

    The read ushort.

See Also:

Since:

  • 1.0.0



319
320
321
# File 'lib/ronin/support/binary/stream/methods.rb', line 319

def read_ushort
  read_value(:ushort)
end

#read_value(type) ⇒ Integer, ...

Reads a value of the given type from the IO stream.

Parameters:

  • type (Symbol)

    The desired type of data to read.

Returns:

Since:

  • 1.0.0



52
53
54
55
56
57
58
# File 'lib/ronin/support/binary/stream/methods.rb', line 52

def read_value(type)
  type  = type_system[type]

  if (slice = read(type.size))
    type.unpack(slice)
  end
end

#write_array_of(type, array) ⇒ self

Writes an array of the given type.

Parameters:

  • type (Symbol)

    The type of the value to write.

  • array (Array<Object>)

    The array of values to write.

Returns:

  • (self)

Since:

  • 1.0.0



1365
1366
1367
1368
1369
1370
1371
1372
# File 'lib/ronin/support/binary/stream/methods.rb', line 1365

def write_array_of(type,array)
  type       = type_system[type]
  array_type = type[array.length]
  data       = array_type.pack(array)

  write(data)
  return self
end

#write_array_of_byte(bytes) ⇒ self Also known as: write_bytes

Alias to write_array_of(:byte,bytes).

Parameters:

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1386
1387
1388
# File 'lib/ronin/support/binary/stream/methods.rb', line 1386

def write_array_of_byte(bytes)
  write_array_of(:byte,bytes)
end

#write_array_of_char(chars) ⇒ self Also known as: write_chars

Alias to write_array_of(:char,bytes).

Parameters:

  • chars (String)

    The array of characters to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1404
1405
1406
# File 'lib/ronin/support/binary/stream/methods.rb', line 1404

def write_array_of_char(chars)
  write_array_of(:char,chars)
end

#write_array_of_double(floats) ⇒ self Also known as: write_doubles

Alias to write_array_of(:double,floats).

Parameters:

  • floats (Array<Float>)

    The array of double values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1750
1751
1752
# File 'lib/ronin/support/binary/stream/methods.rb', line 1750

def write_array_of_double(floats)
  write_array_of(:double,floats)
end

#write_array_of_float(floats) ⇒ self Also known as: write_floats

Alias to write_array_of(:float,floats).

Parameters:

  • floats (Array<Float>)

    The array of float values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1732
1733
1734
# File 'lib/ronin/support/binary/stream/methods.rb', line 1732

def write_array_of_float(floats)
  write_array_of(:float,floats)
end

#write_array_of_float32(floats) ⇒ self

Alias to write_array_of(:float32,floats).

Parameters:

  • floats (Array<Float>)

    The array of float32 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1700
1701
1702
# File 'lib/ronin/support/binary/stream/methods.rb', line 1700

def write_array_of_float32(floats)
  write_array_of(:float32,floats)
end

#write_array_of_float64(floats) ⇒ self

Alias to write_array_of(:float64,floats).

Parameters:

  • floats (Array<Float>)

    The array of float64 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1716
1717
1718
# File 'lib/ronin/support/binary/stream/methods.rb', line 1716

def write_array_of_float64(floats)
  write_array_of(:float64,floats)
end

#write_array_of_int(ints) ⇒ self Also known as: write_ints

Alias to write_array_of(:int,ints).

Parameters:

  • ints (Array<Integer>)

    The array of int values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1584
1585
1586
# File 'lib/ronin/support/binary/stream/methods.rb', line 1584

def write_array_of_int(ints)
  write_array_of(:int,ints)
end

#write_array_of_int16(ints) ⇒ self

Alias to write_array_of(:int16,ints).

Parameters:

  • ints (Array<Integer>)

    The array of int16 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1456
1457
1458
# File 'lib/ronin/support/binary/stream/methods.rb', line 1456

def write_array_of_int16(ints)
  write_array_of(:int16,ints)
end

#write_array_of_int32(ints) ⇒ self

Alias to write_array_of(:int32,ints).

Parameters:

  • ints (Array<Integer>)

    The array of int32 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1472
1473
1474
# File 'lib/ronin/support/binary/stream/methods.rb', line 1472

def write_array_of_int32(ints)
  write_array_of(:int32,ints)
end

#write_array_of_int64(ints) ⇒ self

Alias to write_array_of(:int64,ints).

Parameters:

  • ints (Array<Integer>)

    The array of int64 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1488
1489
1490
# File 'lib/ronin/support/binary/stream/methods.rb', line 1488

def write_array_of_int64(ints)
  write_array_of(:int64,ints)
end

#write_array_of_int8(ints) ⇒ self

Alias to write_array_of(:int8,ints).

Parameters:

  • ints (Array<Integer>)

    The array of int8 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1440
1441
1442
# File 'lib/ronin/support/binary/stream/methods.rb', line 1440

def write_array_of_int8(ints)
  write_array_of(:int8,ints)
end

#write_array_of_long(ints) ⇒ self

Alias to write_array_of(:long,ints).

Parameters:

  • ints (Array<Integer>)

    The array of long values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1602
1603
1604
# File 'lib/ronin/support/binary/stream/methods.rb', line 1602

def write_array_of_long(ints)
  write_array_of(:long,ints)
end

#write_array_of_long_long(ints) ⇒ self

Alias to write_array_of(:long_long,ints).

Parameters:

  • ints (Array<Integer>)

    The array of long_long values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1618
1619
1620
# File 'lib/ronin/support/binary/stream/methods.rb', line 1618

def write_array_of_long_long(ints)
  write_array_of(:long_long,ints)
end

#write_array_of_short(ints) ⇒ self

Alias to write_array_of(:short,ints).

Parameters:

  • ints (Array<Integer>)

    The array of short values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1568
1569
1570
# File 'lib/ronin/support/binary/stream/methods.rb', line 1568

def write_array_of_short(ints)
  write_array_of(:short,ints)
end

#write_array_of_uchar(chars) ⇒ self Also known as: write_uchars

Alias to write_array_of(:uchar,bytes).

Parameters:

  • chars (String)

    The array of unsigned characters to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1422
1423
1424
# File 'lib/ronin/support/binary/stream/methods.rb', line 1422

def write_array_of_uchar(chars)
  write_array_of(:uchar,chars)
end

#write_array_of_uint(uints) ⇒ self Also known as: write_uints

Alias to write_array_of(:uint,uints).

Parameters:

  • uints (Array<Integer>)

    The array of uint values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1650
1651
1652
# File 'lib/ronin/support/binary/stream/methods.rb', line 1650

def write_array_of_uint(uints)
  write_array_of(:uint,uints)
end

#write_array_of_uint16(uints) ⇒ self

Alias to write_array_of(:uint16,uints).

Parameters:

  • uints (Array<Integer>)

    The array of uint16 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1520
1521
1522
# File 'lib/ronin/support/binary/stream/methods.rb', line 1520

def write_array_of_uint16(uints)
  write_array_of(:uint16,uints)
end

#write_array_of_uint32(uints) ⇒ self

Alias to write_array_of(:uint32,uints).

Parameters:

  • uints (Array<Integer>)

    The array of uint32 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1536
1537
1538
# File 'lib/ronin/support/binary/stream/methods.rb', line 1536

def write_array_of_uint32(uints)
  write_array_of(:uint32,uints)
end

#write_array_of_uint64(uints) ⇒ self

Alias to write_array_of(:uint64,uints).

Parameters:

  • uints (Array<Integer>)

    The array of uint64 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1552
1553
1554
# File 'lib/ronin/support/binary/stream/methods.rb', line 1552

def write_array_of_uint64(uints)
  write_array_of(:uint64,uints)
end

#write_array_of_uint8(uints) ⇒ self

Alias to write_array_of(:uint8,uints).

Parameters:

  • uints (Array<Integer>)

    The array of uint8 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1504
1505
1506
# File 'lib/ronin/support/binary/stream/methods.rb', line 1504

def write_array_of_uint8(uints)
  write_array_of(:uint8,uints)
end

#write_array_of_ulong(uints) ⇒ self

Alias to write_array_of(:ulong,uints).

Parameters:

  • uints (Array<Integer>)

    The array of ulong values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1668
1669
1670
# File 'lib/ronin/support/binary/stream/methods.rb', line 1668

def write_array_of_ulong(uints)
  write_array_of(:ulong,uints)
end

#write_array_of_ulong_long(uints) ⇒ self

Alias to write_array_of(:ulong_long,uints).

Parameters:

  • uints (Array<Integer>)

    The array of ulong_long values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1684
1685
1686
# File 'lib/ronin/support/binary/stream/methods.rb', line 1684

def write_array_of_ulong_long(uints)
  write_array_of(:ulong_long,uints)
end

#write_array_of_ushort(uints) ⇒ self

Alias to write_array_of(:ushort,uints).

Parameters:

  • uints (Array<Integer>)

    The array of ushort values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1634
1635
1636
# File 'lib/ronin/support/binary/stream/methods.rb', line 1634

def write_array_of_ushort(uints)
  write_array_of(:ushort,uints)
end

#write_byte(value) ⇒ self

Alias for write_value(:byte,value).

Parameters:

  • value (Integer)

    The char value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



974
975
976
# File 'lib/ronin/support/binary/stream/methods.rb', line 974

def write_byte(value)
  write_value(:byte,value)
end

#write_char(value) ⇒ self

Alias for write_value(:char,value).

Parameters:

  • value (String)

    The char value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



990
991
992
# File 'lib/ronin/support/binary/stream/methods.rb', line 990

def write_char(value)
  write_value(:char,value)
end

#write_double(value) ⇒ self

Alias for write_value(:double,value).

Parameters:

  • value (Float)

    The double value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1348
1349
1350
# File 'lib/ronin/support/binary/stream/methods.rb', line 1348

def write_double(value)
  write_value(:double,value)
end

#write_float(value) ⇒ self

Alias for write_value(:float,value).

Parameters:

  • value (Float)

    The float value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1332
1333
1334
# File 'lib/ronin/support/binary/stream/methods.rb', line 1332

def write_float(value)
  write_value(:float,value)
end

#write_float32(value) ⇒ self

Alias for write_value(:float32,value).

Parameters:

  • value (Float)

    The float32 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1300
1301
1302
# File 'lib/ronin/support/binary/stream/methods.rb', line 1300

def write_float32(value)
  write_value(:float32,value)
end

#write_float64(value) ⇒ self

Alias for write_value(:float64,value).

Parameters:

  • value (Float)

    The float64 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1316
1317
1318
# File 'lib/ronin/support/binary/stream/methods.rb', line 1316

def write_float64(value)
  write_value(:float64,value)
end

#write_int(value) ⇒ self

Alias for write_value(:int,value).

Parameters:

  • value (Integer)

    The int value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1188
1189
1190
# File 'lib/ronin/support/binary/stream/methods.rb', line 1188

def write_int(value)
  write_value(:int,value)
end

#write_int16(value) ⇒ self

Alias for write_value(:int16,value).

Parameters:

  • value (Integer)

    The int16 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1060
1061
1062
# File 'lib/ronin/support/binary/stream/methods.rb', line 1060

def write_int16(value)
  write_value(:int16,value)
end

#write_int32(value) ⇒ self

Alias for write_value(:int32,value).

Parameters:

  • value (Integer)

    The int32 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1076
1077
1078
# File 'lib/ronin/support/binary/stream/methods.rb', line 1076

def write_int32(value)
  write_value(:int32,value)
end

#write_int64(value) ⇒ self

Alias for write_value(:int64,value).

Parameters:

  • value (Integer)

    The int64 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1092
1093
1094
# File 'lib/ronin/support/binary/stream/methods.rb', line 1092

def write_int64(value)
  write_value(:int64,value)
end

#write_int8(value) ⇒ self

Alias for write_value(:int8,value).

Parameters:

  • value (Integer)

    The int8 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1044
1045
1046
# File 'lib/ronin/support/binary/stream/methods.rb', line 1044

def write_int8(value)
  write_value(:int8,value)
end

#write_long(value) ⇒ self

Alias for write_value(:long,value).

Parameters:

  • value (Integer)

    The long value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1204
1205
1206
# File 'lib/ronin/support/binary/stream/methods.rb', line 1204

def write_long(value)
  write_value(:long,value)
end

#write_long_long(value) ⇒ self

Alias for write_value(:long_long,value).

Parameters:

  • value (Integer)

    The long_long value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1220
1221
1222
# File 'lib/ronin/support/binary/stream/methods.rb', line 1220

def write_long_long(value)
  write_value(:long_long,value)
end

#write_short(value) ⇒ self

Alias for write_value(:short,value).

Parameters:

  • value (Integer)

    The short value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1172
1173
1174
# File 'lib/ronin/support/binary/stream/methods.rb', line 1172

def write_short(value)
  write_value(:short,value)
end

#write_string(string) ⇒ self

Writes a null-terminated C string to the buffer.

Parameters:

  • string (String)

    The String to write into the buffer.

Returns:

  • (self)

Since:

  • 1.0.0



1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
# File 'lib/ronin/support/binary/stream/methods.rb', line 1004

def write_string(string)
  ascii_string = string.encode(Encoding::ASCII_8BIT)
  cstring      = if ascii_string.end_with?("\0")
                   ascii_string
                 else
                   "#{ascii_string}\0"
                 end

  write(cstring)
  return self
end

#write_uchar(value) ⇒ self

Alias for write_value(:uchar,value).

Parameters:

  • value (String)

    The uchar value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1028
1029
1030
# File 'lib/ronin/support/binary/stream/methods.rb', line 1028

def write_uchar(value)
  write_value(:uchar,value)
end

#write_uint(value) ⇒ self

Alias for write_value(:uint,value).

Parameters:

  • value (Integer)

    The uint value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1252
1253
1254
# File 'lib/ronin/support/binary/stream/methods.rb', line 1252

def write_uint(value)
  write_value(:uint,value)
end

#write_uint16(value) ⇒ self

Alias for write_value(:uint16,value).

Parameters:

  • value (Integer)

    The uint16 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1124
1125
1126
# File 'lib/ronin/support/binary/stream/methods.rb', line 1124

def write_uint16(value)
  write_value(:uint16,value)
end

#write_uint32(value) ⇒ self

Alias for write_value(:uint32,value).

Parameters:

  • value (Integer)

    The uint32 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1140
1141
1142
# File 'lib/ronin/support/binary/stream/methods.rb', line 1140

def write_uint32(value)
  write_value(:uint32,value)
end

#write_uint64(value) ⇒ self

Alias for write_value(:uint64,value).

Parameters:

  • value (Integer)

    The uint64 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1156
1157
1158
# File 'lib/ronin/support/binary/stream/methods.rb', line 1156

def write_uint64(value)
  write_value(:uint64,value)
end

#write_uint8(value) ⇒ self

Alias for write_value(:uint8,value).

Parameters:

  • value (Integer)

    The uint8 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1108
1109
1110
# File 'lib/ronin/support/binary/stream/methods.rb', line 1108

def write_uint8(value)
  write_value(:uint8,value)
end

#write_ulong(value) ⇒ self

Alias for write_value(:ulong,value).

Parameters:

  • value (Integer)

    The ulong value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1268
1269
1270
# File 'lib/ronin/support/binary/stream/methods.rb', line 1268

def write_ulong(value)
  write_value(:ulong,value)
end

#write_ulong_long(value) ⇒ self

Alias for write_value(:ulong_long,value).

Parameters:

  • value (Integer)

    The ulong_long value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1284
1285
1286
# File 'lib/ronin/support/binary/stream/methods.rb', line 1284

def write_ulong_long(value)
  write_value(:ulong_long,value)
end

#write_ushort(value) ⇒ self

Alias for write_value(:ushort,value).

Parameters:

  • value (Integer)

    The ushort value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1236
1237
1238
# File 'lib/ronin/support/binary/stream/methods.rb', line 1236

def write_ushort(value)
  write_value(:ushort,value)
end

#write_value(type, value) ⇒ self

Writes the value to the IO stream.

Parameters:

  • type (Symbol)

    The type of value to write.

  • value (Integer, Float, String)

    The value to write.

Returns:

  • (self)

Since:

  • 1.0.0



954
955
956
957
958
959
960
# File 'lib/ronin/support/binary/stream/methods.rb', line 954

def write_value(type,value)
  type = type_system[type]
  data = type.pack(value)

  write(data)
  return self
end