<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">###############################################################################
#
#   Package: NaturalDocs::SymbolTable::File
#
###############################################################################
#
#   A class representing a file, keeping track of what symbols and references are defined in it.
#
###############################################################################

# 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::SymbolTable::File;


###############################################################################
# Group: Implementation

#
#   Constants: Members
#
#   The class is implemented as a blessed arrayref.  The following constants are its members.
#
#       SYMBOLS       - An existence hashref of the &lt;SymbolStrings&gt; it defines.
#       REFERENCES  - An existence hashref of the &lt;ReferenceStrings&gt; in the file.
#

# DEPENDENCY: New() depends on the order of these constants.  If they change, New() has to be updated.
use constant SYMBOLS =&gt; 0;
use constant REFERENCES =&gt; 1;


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


#
#   Function: New
#
#   Creates and returns a new object.
#
sub New
    {
    my $package = shift;

    # Let's make it safe, since normally you can pass values to New.  Having them just be ignored would be an obscure error.
    if (scalar @_)
        {  die "You can't pass values to NaturalDocs::SymbolTable::File-&gt;New()\n";  };

    # DEPENDENCY: This code depends on the order of the member constants.
    my $object = [ { }, { } ];
    bless $object, $package;

    return $object;
    };


#
#   Function: AddSymbol
#
#   Adds a &lt;SymbolString&gt; definition.
#
#   Parameters:
#
#       symbol - The &lt;SymbolString&gt; being added.
#
sub AddSymbol #(symbol)
    {
    my ($self, $symbol) = @_;
    $self-&gt;[SYMBOLS]{$symbol} = 1;
    };


#
#   Function: DeleteSymbol
#
#   Removes a &lt;SymbolString&gt; definition.
#
#   Parameters:
#
#       symbol - The &lt;SymbolString&gt; to delete.
#
sub DeleteSymbol #(symbol)
    {
    my ($self, $symbol) = @_;
    delete $self-&gt;[SYMBOLS]{$symbol};
    };


#
#   Function: AddReference
#
#   Adds a reference definition.
#
#   Parameters:
#
#       referenceString - The &lt;ReferenceString&gt; being added.
#
sub AddReference #(referenceString)
    {
    my ($self, $referenceString) = @_;
    $self-&gt;[REFERENCES]{$referenceString} = 1;
    };


#
#   Function: DeleteReference
#
#   Removes a reference definition.
#
#   Parameters:
#
#       referenceString - The &lt;ReferenceString&gt; to delete.
#
sub DeleteReference #(referenceString)
    {
    my ($self, $referenceString) = @_;
    delete $self-&gt;[REFERENCES]{$referenceString};
    };



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


#
#   Function: HasAnything
#
#   Returns whether the file has any symbol or reference definitions at all.
#
sub HasAnything
    {
    return (scalar keys %{$_[0]-&gt;[SYMBOLS]} || scalar keys %{$_[0]-&gt;[REFERENCES]});
    };

#
#   Function: Symbols
#
#   Returns an array of all the &lt;SymbolStrings&gt; defined in this file.  If none, returns an empty array.
#
sub Symbols
    {
    return keys %{$_[0]-&gt;[SYMBOLS]};
    };


#
#   Function: References
#
#   Returns an array of all the &lt;ReferenceStrings&gt; defined in this file.  If none, returns an empty array.
#
sub References
    {
    return keys %{$_[0]-&gt;[REFERENCES]};
    };


#
#   Function: DefinesSymbol
#
#   Returns whether the file defines the passed &lt;SymbolString&gt; or not.
#
sub DefinesSymbol #(symbol)
    {
    my ($self, $symbol) = @_;
    return exists $self-&gt;[SYMBOLS]{$symbol};
    };


#
#   Function: DefinesReference
#
#   Returns whether the file defines the passed &lt;ReferenceString&gt; or not.
#
sub DefinesReference #(referenceString)
    {
    my ($self, $referenceString) = @_;
    return exists $self-&gt;[REFERENCES]{$referenceString};
    };

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