Module: BinData

Defined in:
lib/bindata.rb,
lib/bindata/io.rb,
lib/bindata/int.rb,
lib/bindata/base.rb,
lib/bindata/bits.rb,
lib/bindata/lazy.rb,
lib/bindata/rest.rb,
lib/bindata/array.rb,
lib/bindata/float.rb,
lib/bindata/trace.rb,
lib/bindata/choice.rb,
lib/bindata/params.rb,
lib/bindata/record.rb,
lib/bindata/string.rb,
lib/bindata/struct.rb,
lib/bindata/stringz.rb,
lib/bindata/wrapper.rb,
lib/bindata/registry.rb,
lib/bindata/sanitize.rb,
lib/bindata/primitive.rb,
lib/bindata/deprecated.rb,
lib/bindata/base_primitive.rb

Overview

BinData

A declarative way to read and write structured binary data.

A full reference manual is available online at bindata.rubyforge.org.

License

BinData is released under the same license as Ruby.

Copyright © 2007 - 2009 Dion Mendel.

Defined Under Namespace

Modules: BitField, FloatingPoint, Int Classes: AcceptedParameters, Array, Base, BasePrimitive, Choice, DoubleBe, DoubleLe, FloatBe, FloatLe, IO, Int8, LazyEvaluator, MultiValue, Primitive, Record, Registry, Rest, SanitizedChoices, SanitizedEndian, SanitizedField, SanitizedFields, SanitizedParameter, SanitizedParameters, SanitizedPrototype, Sanitizer, SingleValue, String, Stringz, Struct, Tracer, Uint8, UnknownTypeError, ValidityError, Wrapper

Constant Summary collapse

VERSION =
"1.0.0"
RegisteredClasses =

A singleton registry of all registered classes.

Registry.new

Class Method Summary collapse

Class Method Details

.trace_message {|@tracer| ... } ⇒ Object

:nodoc:

Yields:

  • (@tracer)


29
30
31
# File 'lib/bindata/trace.rb', line 29

def trace_message(&block) #:nodoc:
  yield @tracer if @tracer
end

.trace_reading(io = STDERR, &block) ⇒ Object

Turn on trace information when reading a BinData object. If block is given then the tracing only occurs for that block. This is useful for debugging a BinData declaration.



18
19
20
21
22
23
24
25
26
27
# File 'lib/bindata/trace.rb', line 18

def trace_reading(io = STDERR, &block)
  @tracer = Tracer.new(io)
  if block_given?
    begin
      block.call
    ensure
      @tracer = nil
    end
  end
end