class BinData::Sanitizer

valid.
and default parameters and ensuring the values of known parameters are
BinData object. Sanitizing consists of checking for mandatory, optional
The Sanitizer sanitizes the parameters that are passed when creating a

def as_sanitized_params(params, the_class)

def as_sanitized_params(params, the_class)
  if SanitizedParameters === params
    params
  else
    SanitizedParameters.new(params || {}, the_class)
  end
end

def create_sanitized_choices(choices)

def create_sanitized_choices(choices)
  SanitizedChoices.new(self, choices)
end

def create_sanitized_endian(endian)

def create_sanitized_endian(endian)
  SanitizedEndian.new(endian)
end

def create_sanitized_fields(endian = nil)

def create_sanitized_fields(endian = nil)
  SanitizedFields.new(self, endian)
end

def create_sanitized_object_prototype(obj_type, obj_params, endian = nil)

def create_sanitized_object_prototype(obj_type, obj_params, endian = nil)
  SanitizedPrototype.new(self, obj_type, obj_params, endian)
end

def create_sanitized_params(params, the_class)

def create_sanitized_params(params, the_class)
  sanitized_params = as_sanitized_params(params, the_class)
  sanitized_params.sanitize!(self)
  sanitized_params
end

def initialize

def initialize
  @endian = nil
end

def lookup_class(type)

def lookup_class(type)
  registered_class = RegisteredClasses.lookup(type, @endian)
  if registered_class.nil?
    raise UnknownTypeError, type.to_s
  end
  registered_class
end

def sanitize(params, the_class)

Returns sanitized parameters.
Sanitize +params+ for +the_class+.
def sanitize(params, the_class)
  if params.is_a?(SanitizedParameters) and params.all_sanitized?
    params
  else
    sanitizer = self.new
    sanitizer.create_sanitized_params(params, the_class)
  end
end

def with_endian(endian, &block)

def with_endian(endian, &block)
  if endian != nil
    saved_endian = @endian
    @endian = endian.is_a?(SanitizedEndian) ? endian.endian : endian
    yield
    @endian = saved_endian
  else
    yield
  end
end