Convert::Binary::C 0.64
Sponsored Links
Convert::Binary::C 0.64 Ranking & Summary
File size:
1.3 MB
Platform:
Any Platform
License:
Perl Artistic License
Price:
Downloads:
1215
Date added:
2006-07-05
Publisher:
Marcus Holland-Moritz
Convert::Binary::C 0.64 description
Convert::Binary::C is a Binary Data Conversion using C Types.
SYNOPSIS
Simple
use Convert::Binary::C;
#---------------------------------------------
# Create a new object and parse embedded code
#---------------------------------------------
my $c = Convert::Binary::C->new->parse( <<ENDC );
enum Month { JAN, FEB, MAR, APR, MAY, JUN,
JUL, AUG, SEP, OCT, NOV, DEC };
struct Date {
int year;
enum Month month;
int day;
};
ENDC
#-----------------------------------------------
# Pack Perl data structure into a binary string
#-----------------------------------------------
my $date = { year => 2002, month => DEC, day => 24 };
my $packed = $c->pack( Date, $date );
Advanced
use Convert::Binary::C;
use Data::Dumper;
#---------------------
# Create a new object
#---------------------
my $c = new Convert::Binary::C ByteOrder => BigEndian;
#---------------------------------------------------
# Add include paths and global preprocessor defines
#---------------------------------------------------
$c->Include( /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include,
/usr/include )
->Define( qw( __USE_POSIX __USE_ISOC99=1 ) );
#----------------------------------
# Parse the time.h header file
#----------------------------------
$c->parse_file( time.h );
#---------------------------------------
# See which files the object depends on
#---------------------------------------
print Dumper( [$c->dependencies] );
#-----------------------------------------------------------
# See if struct timespec is defined and dump its definition
#-----------------------------------------------------------
if( $c->def( struct timespec ) ) {
print Dumper( $c->struct( timespec ) );
}
#-------------------------------
# Create some binary dummy data
#-------------------------------
my $data = "binaryteststring";
#--------------------------------------------------------
# Unpack $data according to struct timespec definition
#--------------------------------------------------------
if( length($data) >= $c->sizeof( timespec ) ) {
my $perl = $c->unpack( timespec, $data );
print Dumper( $perl );
}
#--------------------------------------------------------
# See which member lies at offset 5 of struct timespec
#--------------------------------------------------------
my $member = $c->member( timespec, 5 );
print "member( timespec, 5 ) = $membern";
Convert::Binary::C is a preprocessor and parser for C type definitions. It is highly configurable and should support arbitrarily complex data structures. Its object-oriented interface has pack and unpack methods that act as replacements for Perls pack and unpack and allow to use the C types instead of a string representation of the data structure for conversion of binary data from and to Perls complex data structures.
Actually, what Convert::Binary::C does is not very different from what a C compiler does, just that it doesnt compile the source code into an object file or executable, but only parses the code and allows Perl to use the enumerations, structs, unions and typedefs that have been defined within your C source for binary data conversion, similar to Perls pack and unpack.
Beyond that, the module offers a lot of convenience methods to retrieve information about the C types that have been parsed.
SYNOPSIS
Simple
use Convert::Binary::C;
#---------------------------------------------
# Create a new object and parse embedded code
#---------------------------------------------
my $c = Convert::Binary::C->new->parse( <<ENDC );
enum Month { JAN, FEB, MAR, APR, MAY, JUN,
JUL, AUG, SEP, OCT, NOV, DEC };
struct Date {
int year;
enum Month month;
int day;
};
ENDC
#-----------------------------------------------
# Pack Perl data structure into a binary string
#-----------------------------------------------
my $date = { year => 2002, month => DEC, day => 24 };
my $packed = $c->pack( Date, $date );
Advanced
use Convert::Binary::C;
use Data::Dumper;
#---------------------
# Create a new object
#---------------------
my $c = new Convert::Binary::C ByteOrder => BigEndian;
#---------------------------------------------------
# Add include paths and global preprocessor defines
#---------------------------------------------------
$c->Include( /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include,
/usr/include )
->Define( qw( __USE_POSIX __USE_ISOC99=1 ) );
#----------------------------------
# Parse the time.h header file
#----------------------------------
$c->parse_file( time.h );
#---------------------------------------
# See which files the object depends on
#---------------------------------------
print Dumper( [$c->dependencies] );
#-----------------------------------------------------------
# See if struct timespec is defined and dump its definition
#-----------------------------------------------------------
if( $c->def( struct timespec ) ) {
print Dumper( $c->struct( timespec ) );
}
#-------------------------------
# Create some binary dummy data
#-------------------------------
my $data = "binaryteststring";
#--------------------------------------------------------
# Unpack $data according to struct timespec definition
#--------------------------------------------------------
if( length($data) >= $c->sizeof( timespec ) ) {
my $perl = $c->unpack( timespec, $data );
print Dumper( $perl );
}
#--------------------------------------------------------
# See which member lies at offset 5 of struct timespec
#--------------------------------------------------------
my $member = $c->member( timespec, 5 );
print "member( timespec, 5 ) = $membern";
Convert::Binary::C is a preprocessor and parser for C type definitions. It is highly configurable and should support arbitrarily complex data structures. Its object-oriented interface has pack and unpack methods that act as replacements for Perls pack and unpack and allow to use the C types instead of a string representation of the data structure for conversion of binary data from and to Perls complex data structures.
Actually, what Convert::Binary::C does is not very different from what a C compiler does, just that it doesnt compile the source code into an object file or executable, but only parses the code and allows Perl to use the enumerations, structs, unions and typedefs that have been defined within your C source for binary data conversion, similar to Perls pack and unpack.
Beyond that, the module offers a lot of convenience methods to retrieve information about the C types that have been parsed.
Convert::Binary::C 0.64 Screenshot
Convert::Binary::C 0.64 Keywords
Binary Data Conversion C Types
Binary Data Conversion
C 0.64
Types
C types
binary data
data conversion
using c
struct timespec
data
c
C-
binary
conversion
unpack
Convert::Binary::C
Bookmark Convert::Binary::C 0.64
Convert::Binary::C 0.64 Copyright
WareSeeker periodically updates pricing and software information of Convert::Binary::C 0.64 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of Convert::Binary::C 0.64 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed
Featured Software
Want to place your software product here?
Please contact us for consideration.
Contact WareSeeker.com
Related Information
Binary file
string or binary data would be truncated
binary data file
how to open binary data file
how do i open a binary data file
binary data in xml
binary data formats
xml binary data
binary data type
long binary data
binary data viewer
data conversion services
binary data definition
binary data analysis
data conversion calculator
conversion chart
binary data format
dataquick
Related Software
Convert::RACE is a conversion between Unicode and RACE. Free Download
cg is a semi-automatic newsgroup binary downloader. Free Download
Convert::BinHex can extract data from Macintosh BinHex files. Free Download
Convert::ASCII::Armor is a Perl module that can convert binary octets into ASCII armoured messages. Free Download
Convert::BER is a Perl module for ASN.1 Basic Encoding Rules. Free Download
Tree::Binary is a Object Oriented Binary Tree for Perl. Free Download
IFF Format Library provides header structures and utility functions for reading and writing data files in the Interchange Files. Free Download
GD::Convert is a Perl module with additional output formats for GD. Free Download
Latest Software
Popular Software
Favourite Software