[interchange-cvs] interchange - heins modified lib/Vend/Table/Common.pm

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Thu Oct 18 05:36:01 2001


User:      heins
Date:      2001-10-18 09:35:46 GMT
Modified:  lib/Vend/Table Common.pm
Log:
	* Add get_slice() for DBM.

Revision  Changes    Path
2.3       +15 -0     interchange/lib/Vend/Table/Common.pm


rev 2.3, prev_rev 2.2
Index: Common.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Table/Common.pm,v
retrieving revision 2.2
retrieving revision 2.3
diff -u -r2.2 -r2.3
--- Common.pm	2001/10/18 04:16:16	2.2
+++ Common.pm	2001/10/18 09:35:46	2.3
@@ -1,6 +1,6 @@
 # Vend::Table::Common - Common access methods for Interchange databases
 #
-# $Id: Common.pm,v 2.2 2001/10/18 04:16:16 mheins Exp $
+# $Id: Common.pm,v 2.3 2001/10/18 09:35:46 mheins Exp $
 #
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -22,7 +22,7 @@
 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA  02111-1307  USA.
 
-$VERSION = substr(q$Revision: 2.2 $, 10);
+$VERSION = substr(q$Revision: 2.3 $, 10);
 use strict;
 
 package Vend::Table::Common;
@@ -307,6 +307,21 @@
 #::logDebug("setting $key indices '@index' to '@vals'");
         $s->set_row(@row);
     };
+}
+
+sub get_slice {
+    my ($s, $key, $fary) = @_;
+	$s = $s->import_db() if ! defined $s->[$TIE_HASH];
+
+	return undef unless $s->record_exists($key);
+
+	if(ref $fary ne 'ARRAY') {
+		shift; shift;
+		$fary = [ @_ ];
+	}
+
+	my @result = ($s->row($key))[ map { $s->column_index($_) } @$fary ];
+	return wantarray ? @result : \@result;
 }
 
 sub set_slice {