1 package PciIds::Address::Pci;
4 use PciIds::Address::Toplevel;
5 use base 'PciIds::Address::Base';
9 return PciIds::Address::Toplevel::new( $address ) if( $address =~ /^PC\/?$/ );
10 return bless PciIds::Address::Base::new( $address );
18 s/([0-9a-f]{4})([0-9a-f]{4})/$1 $2/g;
21 $prefix = 'Subsystem';
27 return $prefix.' '. $_;
31 my( $new ) = ( shift->get() );
32 $new =~ s/.*\/(.)/$1/;
33 $new =~ s/([0-9a-f]{4})([0-9a-f]{4})/$1 $2/g;
37 sub restrictRex( $$ ) {
38 my( $self, $restrict ) = @_;
39 my( $result ) = ( $restrict =~ /^([a-f0-9]{1,4})/ );#TODO every time?
44 return ( shift->get() =~ /\/.*\/.*\// );
48 my( $self, $suffix ) = @_;
49 return ( undef, 'You can not add to leaf node' ) if( $self->leaf() );
51 return ( undef, "Invalid ID syntax" ) unless ( ( ( $self->get() !~ /^PC\/.*\// ) && ( $suffix =~ /^[0-9a-f]{4}$/ ) ) || ( ( $self->get() =~ /^PC\/.*\// ) && ( $suffix =~ /^[0-9a-f]{8}$/ ) ) );
52 return ( PciIds::Address::Base::new( $self->{'value'} . ( ( $self->{'value'} =~ /\/$/ ) ? '' : '/' ) . $suffix ), undef );
57 my $result = PciIds::Address::Base::path( $self );
58 my( $vid ) = ( $self->get() =~ /^PC\/[0-9a-f]{4}\/[0-9a-f]{4}\/([0-9a-f]{4})/ );
59 splice @{$result}, 2, 0, PciIds::Address::new( "PC/$vid" ) if( defined $vid ) && ( $result->[1]->get() ne "PC/$vid" );