Class: BinData::Stringz

Inherits:
BasePrimitive show all
Defined in:
lib/bindata/stringz.rb

Overview

A BinData::Stringz object is a container for a zero (“0”) terminated string.

For convenience, the zero terminator is not necessary when setting the value. Likewise, the returned value will not be zero terminated.

require 'bindata'

data = "abcd\x00efgh"

obj = BinData::Stringz.new
obj.read(data)
obj.snapshot #=> "abcd"
obj.value #=> "abcd"
obj.num_bytes #=> 5
obj.to_binary_s #=> "abcd\000"

Parameters

Stringz objects accept all the params that BinData::BasePrimitive does, as well as the following:

:max_length

The maximum length of the string including the zero byte.

Instance Attribute Summary

Attributes inherited from Base

#parent

Method Summary

Methods inherited from BasePrimitive

#clear, #clear?, #eql?, #hash, #initialize, #method_missing, #respond_to?, #value, #value=

Methods inherited from Base

#==, accepted_parameters, #assign, #clear, #clear?, #debug_name, #debug_name_of, default_parameters, #eval_parameter, #get_parameter, #has_parameter?, #initialize, #inspect, mandatory_parameters, mutually_exclusive_parameters, #num_bytes, #offset, #offset_of, optional_parameters, #pretty_print, #read, read, #rel_offset, sanitize_parameters!, #snapshot, #to_binary_s, #to_s, #write

Constructor Details

This class inherits a constructor from BinData::BasePrimitive

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BinData::BasePrimitive