X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=perl-module%2Flib%2FPSPP.pm;h=fd2f5a5f5d579ae20f933248af74088524d15c43;hb=3e30fb40d64fcf006b327a5f81934c14ef842111;hp=8a54094ea2f76d8c489f48d4725ee988a8164962;hpb=27a0c1b1d9dc57d2109d8accfccd8df1303d8c46;p=pspp-builds.git diff --git a/perl-module/lib/PSPP.pm b/perl-module/lib/PSPP.pm index 8a54094e..fd2f5a5f 100644 --- a/perl-module/lib/PSPP.pm +++ b/perl-module/lib/PSPP.pm @@ -2,11 +2,9 @@ use 5.008008; use strict; use warnings; -do 'pspp-vers.pl' || die "No version set"; - =head1 NAME -PSPP - Perl extension to PSPP +PSPP-Perl - Perl extension to PSPP =head1 SYNOPSIS @@ -14,17 +12,21 @@ PSPP - Perl extension to PSPP =head1 DESCRIPTION -PSPP:: provides an interface to the libraries used by pspp to create -system files. +PSPP-Perl provides an interface to the libraries used by pspp to read and +write system files. =head1 EXPORT None by default. =cut +BEGIN { + $PSPP::VERSION='0.7.3'; + require XSLoader; + XSLoader::load('PSPP', $PSPP::VERSION); +} -require XSLoader; -XSLoader::load('PSPP', $PSPP::VERSION); +PSPP::onBoot($PSPP::VERSION); =pod @@ -41,8 +43,9 @@ use POSIX ; use constant { SYSMIS => -(POSIX::DBL_MAX), PERL_EPOCH => 12219379200 # Number of seconds between + # 14th October 1582 + # and # 1st January 1970 - # and 14th October 1582 }; @@ -77,11 +80,61 @@ Sets the weighting variable to C. sub new { my $class = shift; - my $self = _dict_new (); + my $self = pxs_dict_new (); bless ($self, $class); return $self; } +=pod + +=head3 get_var_cnt () + +Returns the number of variables in the dictionary. + +=head3 get_var ($idx) + +Returns the Cth variable from the dictionary. +Returns undef if C is greater than or equal to the number +of variables in the dictionary. + +=cut + +sub get_var +{ + my $dict = shift; + my $idx = shift; + my $var = pxs_get_variable ($dict, $idx); + + if ( ref $var ) + { + bless ($var, "PSPP::Var"); + } + return $var; +} + +=pod + +=head3 get_var_by_name ($name) + +Returns the variable from the dictionary whose name is C. +If there is no such variable, a null reference will be returned. + +=cut + +sub get_var_by_name +{ + my $dict = shift; + my $name = shift; + my $var = pxs_get_var_by_name ($dict, $name); + + if ( ref $var ) + { + bless ($var, "PSPP::Var"); + } + return $var; +} + + package PSPP::Fmt; =pod @@ -144,7 +197,7 @@ package PSPP::Var; =head3 new ($dict, $name, %input_fmt) Creates and returns a new variable in the dictionary C. The -new variable will have the name C. +new variable will have the name C. C must be a valid UTF8 string. The input format is set by the C parameter (See L). By default, the write and print formats are the same as the input format. @@ -161,7 +214,7 @@ sub new my $dict = shift; my $name = shift; my %format = @_; - my $self = _dict_create_var ($dict, $name, \%format); + my $self = pxs_dict_create_var ($dict, $name, \%format); if ( ref $self ) { bless ($self, $class); @@ -173,7 +226,7 @@ sub new =head3 set_label ($label) -Sets the variable label to C