NISPlus

 view release on metacpan or  search on metacpan

NISPlus/Table.pm  view on Meta::CPAN

  else
  {
    return 1;
  }
}

=head2 first_entry

first_entry retrieves the first entry in the table.  Data is returned
in an array.

@fields = $table->first_entry();

=cut

sub first_entry
{
  my($me) = @_;
  my($ret, $cookie, $res);

  ($ret, $cookie, $res) = Net::NISPlus::nis_first_entry($me->fullPath);
  if ($ret != 0) {
    Warning("first_entry error: ", niserror($ret), "\n");
    return ();
  } else {
    $me->{'cookie'} = $cookie;
    return @{$res};
  }
}

=head2 next_entry

next_entry successively returns the next entry in the table.
first_entry should be called before next_entry.  Data is returned in
an array.

@fields = $table->next_entry();

=cut

sub next_entry
{
  my($me) = @_;
  my($ret, $cookie, $res);

  ($ret, $cookie, $res) = Net::NISPlus::nis_next_entry($me->fullPath,
						       $me->{'cookie'});
  if ($ret != 0) {
    Warning("next_entry error: ", niserror($ret), "\n");
    return ();
  } else {
    $me->{'cookie'} = $cookie;
    return @{$res};
  }
}

sub chmod
{
}

sub chown
{
}

sub DESTROY
{
}

# takes either a string of the form [a=b,c=d] or a hash reference of the form
# { 'a'=>'b', 'c'=>'d' } and returns a canonical indexed name.
sub indexedName
{
  my($me, $arg) = @_;
  my($name);
# if the argument is a hashref, then we build the indexed name from the hash.  
  if (ref($arg) eq "hash")
  {
    $name = "[";
    foreach $key (keys %$arg)
    {
      die "$key does not exist in ".$me->fullPath."\n" unless $me->isColname($key);
      $name .= "," unless length($name) == 1;
      $name .= "$key=$arg->{$key}";
    }
    $name .= "]";
  }
  else
# if the argument is not a hashref, then it should be a string
  {
    $name = $arg;
# if the user specifies a table name, it will be deleted and replaced
# with the full path
    $name =~ s/,.*//;
  }
  $name .= ",".$me->fullPath;
}

sub fullPath
{
  my($me) = shift;

  $me->{'full_path'};
}

=head2 isColname

returns TRUE if the given argument is a valid column name for the
table

$table->isColname("name");

=cut

sub isColname
{
  my($me, $val) = @_;
  my($colnames);
  $colnames = $me->colnames;
  return exists $colnames->{$val};
}



( run in 1.431 second using v1.01-cache-2.11-cpan-71847e10f99 )