diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-02 08:21:29 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-02 08:21:29 +0000 |
| commit | 61bfe2d70cae6be8c4086a210a5451135ccca9ea (patch) | |
| tree | 62bf7808b1b2bfe5f56fe1e329871fb0991d0687 /docs/tool/Modules/NaturalDocs/SymbolTable/File.pm | |
| parent | a13b94f9e0bca8ea892311d9d9e0c0bc48616ea7 (diff) | |
| download | zcatch-61bfe2d70cae6be8c4086a210a5451135ccca9ea.tar.gz zcatch-61bfe2d70cae6be8c4086a210a5451135ccca9ea.zip | |
added doc tool
Diffstat (limited to 'docs/tool/Modules/NaturalDocs/SymbolTable/File.pm')
| -rw-r--r-- | docs/tool/Modules/NaturalDocs/SymbolTable/File.pm | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/docs/tool/Modules/NaturalDocs/SymbolTable/File.pm b/docs/tool/Modules/NaturalDocs/SymbolTable/File.pm new file mode 100644 index 00000000..71f93645 --- /dev/null +++ b/docs/tool/Modules/NaturalDocs/SymbolTable/File.pm @@ -0,0 +1,186 @@ +############################################################################### +# +# 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 <SymbolStrings> it defines. +# REFERENCES - An existence hashref of the <ReferenceStrings> in the file. +# + +# DEPENDENCY: New() depends on the order of these constants. If they change, New() has to be updated. +use constant SYMBOLS => 0; +use constant REFERENCES => 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->New()\n"; }; + + # DEPENDENCY: This code depends on the order of the member constants. + my $object = [ { }, { } ]; + bless $object, $package; + + return $object; + }; + + +# +# Function: AddSymbol +# +# Adds a <SymbolString> definition. +# +# Parameters: +# +# symbol - The <SymbolString> being added. +# +sub AddSymbol #(symbol) + { + my ($self, $symbol) = @_; + $self->[SYMBOLS]{$symbol} = 1; + }; + + +# +# Function: DeleteSymbol +# +# Removes a <SymbolString> definition. +# +# Parameters: +# +# symbol - The <SymbolString> to delete. +# +sub DeleteSymbol #(symbol) + { + my ($self, $symbol) = @_; + delete $self->[SYMBOLS]{$symbol}; + }; + + +# +# Function: AddReference +# +# Adds a reference definition. +# +# Parameters: +# +# referenceString - The <ReferenceString> being added. +# +sub AddReference #(referenceString) + { + my ($self, $referenceString) = @_; + $self->[REFERENCES]{$referenceString} = 1; + }; + + +# +# Function: DeleteReference +# +# Removes a reference definition. +# +# Parameters: +# +# referenceString - The <ReferenceString> to delete. +# +sub DeleteReference #(referenceString) + { + my ($self, $referenceString) = @_; + delete $self->[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]->[SYMBOLS]} || scalar keys %{$_[0]->[REFERENCES]}); + }; + +# +# Function: Symbols +# +# Returns an array of all the <SymbolStrings> defined in this file. If none, returns an empty array. +# +sub Symbols + { + return keys %{$_[0]->[SYMBOLS]}; + }; + + +# +# Function: References +# +# Returns an array of all the <ReferenceStrings> defined in this file. If none, returns an empty array. +# +sub References + { + return keys %{$_[0]->[REFERENCES]}; + }; + + +# +# Function: DefinesSymbol +# +# Returns whether the file defines the passed <SymbolString> or not. +# +sub DefinesSymbol #(symbol) + { + my ($self, $symbol) = @_; + return exists $self->[SYMBOLS]{$symbol}; + }; + + +# +# Function: DefinesReference +# +# Returns whether the file defines the passed <ReferenceString> or not. +# +sub DefinesReference #(referenceString) + { + my ($self, $referenceString) = @_; + return exists $self->[REFERENCES]{$referenceString}; + }; + +1; |