7:134
  8   ˆl–Ðz¾”ja,j
€Á;q·”Å£�þYiæÖn8Ûl#oÊð?ŸÆ„-4ßÅÄÃÂ 4…    package AptPkg::Cache;

require 5.005_62;
use strict;
use warnings;
use AptPkg;
use AptPkg::hash;

require Exporter;

our @ISA = qw(Exporter AptPkg::hash);
our @EXPORT = ();
our $VERSION = 1.25;

sub new
{
    my $class = shift;
    my $self = $class->SUPER::new;
    $self->_xs->Open(@_) ? $self : undef;
}

sub files
{
    my $self = shift;
    my $files = $self->_priv->{files} ||= [
	map AptPkg::Cache::PkgFile->new($_), $self->_xs->FileList
    ];

    wantarray ? @$files : $files;
}

sub packages
{
    my $self = shift;
    $self->_priv->{packages} ||= do {
	require AptPkg::PkgRecords;
	bless \$self->_xs->Packages, 'AptPkg::PkgRecords';
    };
}

sub policy
{
    my $self = shift;
    $self->_priv->{policy} ||= do {
	require AptPkg::Policy;
	bless \$self->_xs->Policy, 'AptPkg::Policy';
    };
}

sub exists { shift->_xs->FindPkg(@_) }
sub get
{
    my $value = shift->exists(@_);
    $value ? AptPkg::Cache::Package->new($value) : undef;
}

sub is_multi_arch { shift->_xs->MultiArchCache() }
sub native_arch { shift->_xs->NativeArch() }

package AptPkg::Cache::Iter;

sub new
{
    my $class = shift;
    my $obj = shift;
    my $self = $obj->_xs->PkgBegin(@_);

    bless \$self, $class;
}

sub next
{
    my $self = shift;
    my $obj = $$self or return;
    my $key = $obj->FullName;
    $obj->Next or $$self = undef;
    $key;
}

package AptPkg::Cache;

# helper functions to convert XS iterators to tied hashes
sub _make_class
{
    my ($obj, $class) = @_;
    (my $method = (caller 1)[3]) =~ s/^.*:://;
    my $value = $obj->_xs->$method or return;
    $class->new($value);
}

sub _make_class_list
{
    my ($obj, $class) = @_;
    (my $method = (caller 1)[3]) =~ s/^.*:://;
    my @values = $obj->_xs->$method or return;
    [ map $class->new($_), @values ];
}

package AptPkg::Cache::Package;

our @ISA = qw(AptPkg::hash::method);
our @KEYS = qw(
    Name FullName ShortName Arch Section VersionList CurrentVer RevDependsList
    ProvidesList Index SelectedState InstState CurrentState Flags
);

sub ShortName
{
    # Same as Name for native, and FullName for non-native packages.
    shift->_xs->FullName(1); # Pretty=true
}

sub VersionList
{
    AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Version';
}

sub CurrentVer
{
    AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Version';
}

sub RevDependsList
{
    AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Depends';
}

sub ProvidesList
{
    AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Provides';
}

package AptPkg::Cache::Package::Iter;
our @ISA = qw(AptPkg::hash::method::iter);

package AptPkg::Cache::Version;

our @ISA = qw(AptPkg::hash::method);
our @KEYS = qw(
    VerStr Section Arch MultiArch ParentPkg DescriptionList
    TranslatedDescription DependsList ProvidesList FileList InstalledSize
    Size Index Priority
);

sub ParentPkg
{
    AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Package';
}

sub DescriptionList
{
    AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Description';
}

sub TranslatedDescription
{
    AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Description';
}

sub DependsList
{
    AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Depends';
}

sub ProvidesList
{
    AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Provides';
}

sub FileList
{
    AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::VerFile';
}

package AptPkg::Cache::Version::Iter;
our @ISA = qw(AptPkg::hash::method::iter);

package AptPkg::Cache::Depends;

our @ISA = qw(AptPkg::hash::method);
our @KEYS = qw(
    TargetVer TargetPkg ParentVer ParentPkg Index CompType CompTypeDeb
    DepType
);

sub TargetPkg { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Package' }
sub ParentVer { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Version' }
sub ParentPkg { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Package' }

package AptPkg::Cache::Depends::Iter;
our @ISA = qw(AptPkg::hash::method::iter);

package AptPkg::Cache::Provides;

our @ISA = qw(AptPkg::hash: