about summary refs log tree commit diff
path: root/docs/tool/Modules/NaturalDocs/ImageReferenceTable/String.pm
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-02 08:21:29 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-02 08:21:29 +0000
commit61bfe2d70cae6be8c4086a210a5451135ccca9ea (patch)
tree62bf7808b1b2bfe5f56fe1e329871fb0991d0687 /docs/tool/Modules/NaturalDocs/ImageReferenceTable/String.pm
parenta13b94f9e0bca8ea892311d9d9e0c0bc48616ea7 (diff)
downloadzcatch-61bfe2d70cae6be8c4086a210a5451135ccca9ea.tar.gz
zcatch-61bfe2d70cae6be8c4086a210a5451135ccca9ea.zip
added doc tool
Diffstat (limited to 'docs/tool/Modules/NaturalDocs/ImageReferenceTable/String.pm')
-rw-r--r--docs/tool/Modules/NaturalDocs/ImageReferenceTable/String.pm110
1 files changed, 110 insertions, 0 deletions
diff --git a/docs/tool/Modules/NaturalDocs/ImageReferenceTable/String.pm b/docs/tool/Modules/NaturalDocs/ImageReferenceTable/String.pm
new file mode 100644
index 00000000..982e9f13
--- /dev/null
+++ b/docs/tool/Modules/NaturalDocs/ImageReferenceTable/String.pm
@@ -0,0 +1,110 @@
+###############################################################################
+#
+#   Package: NaturalDocs::ImageReferenceTable::String
+#
+###############################################################################
+#
+#   A package for creating and managing <ImageReferenceStrings>.
+#
+###############################################################################
+
+# 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::ImageReferenceTable::String;
+
+
+#
+#   Type: ImageReferenceString
+#
+#   A string representing a unique image reference.  It's composed of the reference text and the directory of the source file.
+#   The source file name itself isn't included because two files in the same directory with the same reference text will always go
+#   to the same targets.
+#
+
+
+#
+#   Function: Make
+#
+#   Converts a source <FileName> and the reference text to an <ImageReferenceString>.
+#
+sub Make #(FileName sourceFile, string text) => ImageReferenceString
+    {
+    my ($self, $sourceFile, $text) = @_;
+
+    my $path = NaturalDocs::File->NoFileName($sourceFile);
+
+    # Condense whitespace and remove any separator characters.
+    $path =~ tr/ \t\r\n\x1C/ /s;
+    $text =~ tr/ \t\r\n\x1C/ /s;
+
+    return $path . "\x1C" . $text;
+    };
+
+
+#
+#   Function: InformationOf
+#
+#   Returns the information contained in the <ImageReferenceString> as the array ( path, text ).
+#
+sub InformationOf #(ImageReferenceString referenceString)
+    {
+    my ($self, $referenceString) = @_;
+    return split(/\x1C/, $referenceString);
+    };
+
+
+#
+#   Function: ToBinaryFile
+#
+#   Writes an <ImageReferenceString> to <NaturalDocs::BinaryFile>.  Can also encode an undef.
+#
+#   Format:
+#
+#       > [AString16: path] [AString16: reference text] ...
+#
+#       Undef is represented by the first AString16 being undef.
+#
+sub ToBinaryFile #(ImageReferenceString referenceString)
+    {
+    my ($self, $referenceString) = @_;
+
+    if (defined $referenceString)
+        {
+        my ($path, $text) = split(/\x1C/, $referenceString);
+
+        NaturalDocs::BinaryFile->WriteAString16($path);
+        NaturalDocs::BinaryFile->WriteAString16($text);
+        }
+    else
+        {
+        NaturalDocs::BinaryFile->WriteAString16(undef);
+        };
+    };
+
+
+#
+#   Function: FromBinaryFile
+#
+#   Loads an <ImageReferenceString> or undef from <NaturalDocs::BinaryFile> and returns it.
+#
+sub FromBinaryFile
+    {
+    my $self = shift;
+
+    my $path = NaturalDocs::BinaryFile->GetAString16();
+
+    if (!defined $path)
+        {  return undef;  };
+
+    my $text = NaturalDocs::BinaryFile->GetAString16();
+
+    return $path . "\x1C" . $text;
+    };
+
+
+1;