| Class | Racket::Misc::VT |
| In: |
lib/racket/misc/vt.rb
(CVS)
|
| Parent: | Object |
Simple class to represent a datastructure that is made up of a null terminted string followed by an arbitrary number of arbitrarily sized values, followed by a "rest" field.
Given data, return the value and an array of the types as dictated by this instance
# File lib/racket/misc/vt.rb, line 52 def decode(data) null = data.index(0x00) value = data.unpack("a#{null}")[0] data = data.slice(null+1, data.length) n = 0 types = [] @lengths.each do |l| types[n] = data.unpack("#{punpack_string(l)}")[0] data = data.slice(l, data.length) n += 1 end [value, types, data] end
Given data, set the value and types array accordingly
# File lib/racket/misc/vt.rb, line 70 def decode!(data) @value, @types, @rest = self.decode(data) end