Class::Bits

Class::Bits is a Perl module with class wrappers around bit vectors.
Download

Class::Bits Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Salvador Fandi
  • Publisher web site:
  • http://search.cpan.org/~salva/Net-SFTP-Foreign-1.42/lib/Net/SFTP/Foreign.pm

Class::Bits Tags


Class::Bits Description

Class::Bits is a Perl module with class wrappers around bit vectors. Class::Bits is a Perl module with class wrappers around bit vectors.SYNOPSIS package MyClass; use Class::Bits; make_bits( a => 4, # 0..15 b => 1, # 0..1 c => 1, # 0..1 d => 2, # 0..3 e => s4 # -8..7 f => s1 # -1..0 ); package; $o=MyClass->new(a=>12, d=>2); print "o->b is ", $o->b, "n"; print "bit vector is ", unpack("h*", $$o), "n"; $o2=$o->new(); $o3=MyClass->new($string);ABSTRACTClass::Bits creates class wrappers around bit vectors.Class::Bits defines classes using bit vectors as storage.Object attributes are stored in bit fields inside the bit vector. Bit field sizes have to be powers of 2 (1, 2, 4, 8, 16 or 32).There is a class constructor subroutine:make_bits( field1 => size1, field2 => size2, ...)exports in the calling package a ctor, accessor methods, some utility methods and some constants:Sizes can be prefixed by s or u to define signedness of the field. Default is unsigned.$class->new()creates a new object with all zeros.$class->new($bitvector)creates a new object over $bitvector.$class->new(%fields)creates a new object and initializes its fields with the values in %fields.$obj->new()clones an object.$obj->$field() $obj->$field($value)gets or sets the value of the bit field $field inside the bit vector.$class->length $obj->lenghtreturns the size in bits of the bit vector used for storage.$class->keys $obj->keysreturns an array with the names of the object attributes$obj->as_hashreturns a flatten hash with the object attributes, i.e.: my %values=$obj->as_hash;%INDEXhash with offsets as used by vec perl operator (to get an offset in bits, the value has to be multiplied by the corresponding bit field size).%SIZEShash with bit field sizes in bits.%SIGNEDhash with signedness of the fieldsBit fields are packed in the bit vector in the order specified as arguments to make_bits.Bit fields are padded inside the bit vector, i.e. a class created like make_bits(A=>1, B=>2, C=>1, D=>4, E=>8, F=>16);will have the layout AxBBCxxx DDDDxxxx EEEEEEEE xxxxxxxx FFFFFFFF FFFFFFFF Requirements: · Perl


Class::Bits Related Software