<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">###############################################################################
#
#   Class: NaturalDocs::ClassHierarchy::File
#
###############################################################################
#
#   An object that stores information about what hierarchy information is present in a file.  It does not store its &lt;FileName&gt;; it
#   assumes that it will be stored in a hashref where the key is the &lt;FileName&gt;.
#
###############################################################################

# This file is part of Natural Docs, which is Copyright (C) 2003-2008 Greg Valure
# Natural Docs is licensed under the GPL

use strict;
use integer;

package NaturalDocs::ClassHierarchy::File;


#
#   Topic: Implementation
#
#   Since there's only one member in the class, and it's a hashref, the class is simply the hashref itself blessed as a class.
#   The keys are the class &lt;SymbolStrings&gt; that are defined in the file, and the values are existence hashrefs of each class'
#   parent &lt;ReferenceStrings&gt;, or undef if none.
#


###############################################################################
# Group: Modification Functions


#
#   Function: New
#
#   Creates and returns a new class.
#
sub New
    {
    my ($package) = @_;

    my $object = { };
    bless $object, $package;

    return $object;
    };

#
#   Function: AddClass
#   Adds a rew class &lt;SymbolString&gt; to the file.
#
sub AddClass #(class)
    {
    my ($self, $class) = @_;

    if (!exists $self-&gt;{$class})
        {  $self-&gt;{$class} = undef;  };
    };

#
#   Function: DeleteClass
#   Deletes a class &lt;SymbolString&gt; from the file.
#
sub DeleteClass #(class)
    {
    my ($self, $class) = @_;
    delete $self-&gt;{$class};
    };

#
#   Function: AddParentReference
#   Adds a parent &lt;ReferenceString&gt; to a class &lt;SymbolString&gt;.
#
sub AddParentReference #(class, parentReference)
    {
    my ($self, $class, $parent) = @_;

    if (!exists $self-&gt;{$class} || !defined $self-&gt;{$class})
        {  $self-&gt;{$class} = { };  };

    $self-&gt;{$class}-&gt;{$parent} = 1;
    };

#
#   Function: DeleteParentReference
#   Deletes a parent &lt;ReferenceString&gt; from a class &lt;SymbolString&gt;.
#
sub DeleteParentReference #(class, parent)
    {
    my ($self, $class, $parent) = @_;

    if (exists $self-&gt;{$class})
        {
        delete $self-&gt;{$class}-&gt;{$parent};

        if (!scalar keys %{$self-&gt;{$class}})
            {  $self-&gt;{$class} = undef;  };
        };
    };



###############################################################################
# Group: Information Functions


#
#   Function: Classes
#   Returns an array of the class &lt;SymbolStrings&gt; that are defined by this file, or an empty array if none.
#
sub Classes
    {
    my ($self) = @_;
    return keys %{$self};
    };

#
#   Function: HasClass
#   Returns whether the file defines the passed class &lt;SymbolString&gt;.
#
sub HasClass #(class)
    {
    my ($self, $class) = @_;
    return exists $self-&gt;{$class};
    };

#
#   Function: ParentReferencesOf
#   Returns an array of the parent &lt;ReferenceStrings&gt; that are defined by the class, or an empty array if none.
#
sub ParentReferencesOf #(class)
    {
    my ($self, $class) = @_;

    if (!exists $self-&gt;{$class} || !defined $self-&gt;{$class})
        {  return ( );  }
    else
        {  return keys %{$self-&gt;{$class}};  };
    };

#
#   Function: HasParentReference
#   Returns whether the file defines the passed class &lt;SymbolString&gt; and parent &lt;ReferenceString&gt;.
#
sub HasParentReference #(class, parent)
    {
    my ($self, $class, $parent) = @_;

    if (!$self-&gt;HasClass($class))
        {  return undef;  };

    return exists $self-&gt;{$class}-&gt;{$parent};
    };


1;
</pre></body></html>