| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | ############################################################################### | 
| 2 |  |  |  |  |  |  | #Undefined.pm | 
| 3 |  |  |  |  |  |  | #Last Change: 2009-28-01 | 
| 4 |  |  |  |  |  |  | #Copyright (c) 2009 Marc-Seabstian "Maluku" Lucksch | 
| 5 |  |  |  |  |  |  | #Version 0.3 | 
| 6 |  |  |  |  |  |  | #################### | 
| 7 |  |  |  |  |  |  | #This file is part of the sofu.pm project, a parser library for an all-purpose | 
| 8 |  |  |  |  |  |  | #ASCII file format. More information can be found on the project web site | 
| 9 |  |  |  |  |  |  | #at http://sofu.sourceforge.net/ . | 
| 10 |  |  |  |  |  |  | # | 
| 11 |  |  |  |  |  |  | #sofu.pm is published under the terms of the MIT license, which basically means | 
| 12 |  |  |  |  |  |  | #"Do with it whatever you want". For more information, see the license.txt | 
| 13 |  |  |  |  |  |  | #file that should be enclosed with libsofu distributions. A copy of the license | 
| 14 |  |  |  |  |  |  | #is (at the time of this writing) also available at | 
| 15 |  |  |  |  |  |  | #http://www.opensource.org/licenses/mit-license.php . | 
| 16 |  |  |  |  |  |  | ############################################################################### | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | =head1 NAME | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | Data::Sofu::Undefined - A Sofu non type | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | Provides a interface similar to the original SofuD (sofu.sf.net) | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | This Object is similar to Perl's undef . | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | It is nothing (not even a C) but it is still there (in Lists or Maps for example) | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | =head1 Synopsis | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | require Data::Sofu::Undefined; | 
| 34 |  |  |  |  |  |  | require Data::Sofu::Map; | 
| 35 |  |  |  |  |  |  | my $u = Data::Sofu::Undefined->new(); | 
| 36 |  |  |  |  |  |  | my $map = Data::Sofu::Map->new(); | 
| 37 |  |  |  |  |  |  | $map->setAttribute("Nx",$u); | 
| 38 |  |  |  |  |  |  | $map->hasMap("Nx"); # Returns 0 | 
| 39 |  |  |  |  |  |  | $map->hasValue("Nx"); # Returns 0 | 
| 40 |  |  |  |  |  |  | $map->hasAttribute("Nx"); # Returns 1 | 
| 41 |  |  |  |  |  |  | # It is also there in $map->each() and $map->next(); | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | =head1 SYNTAX | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | This Module is pure OO, exports nothing | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | =cut | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | package Data::Sofu::Undefined; | 
| 51 |  |  |  |  |  |  |  | 
| 52 | 3 |  |  | 3 |  | 16 | use strict; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 95 |  | 
| 53 | 3 |  |  | 3 |  | 14 | use warnings; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 775 |  | 
| 54 |  |  |  |  |  |  | require Data::Sofu::Object; | 
| 55 |  |  |  |  |  |  | require Data::Sofu::List; | 
| 56 |  |  |  |  |  |  | our @ISA = qw/Data::Sofu::Object/; | 
| 57 |  |  |  |  |  |  | our $VERSION="0.3"; | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | =head1 METHODS | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | Also look at C for methods, cause Undefined inherits from it | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =head2 new() | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | Creates a new C and returns it | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | $val = Data::Sofu::Undefined->new(); | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =cut | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | sub new { | 
| 73 | 37 |  |  | 37 | 1 | 124 | my $self={}; | 
| 74 | 37 |  |  |  |  | 117 | bless $self,shift; | 
| 75 | 37 | 50 |  |  |  | 122 | return Data::Sofu::Value(@_) if @_; | 
| 76 | 37 |  |  |  |  | 122 | return $self; | 
| 77 |  |  |  |  |  |  | } | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =head2 isDefined() | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | Returns false | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | =cut | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | sub isDefined { | 
| 86 | 3 |  |  | 3 | 1 | 17 | return 0; | 
| 87 |  |  |  |  |  |  | } | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =head2 stringify(LEVEL, TREE) | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | Returns the string representation of this Object. | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | Which is the string "UNDEF" | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | LEVEL and TREE are ignored. | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | =cut | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | sub stringify { | 
| 100 | 3 |  |  | 3 | 1 | 4 | my $self=shift; | 
| 101 | 3 |  |  |  |  | 5 | my $level=shift; | 
| 102 | 3 |  |  |  |  | 4 | my $tree=shift; | 
| 103 | 3 | 50 |  |  |  | 8 | return "Value = UNDEF".$self->stringComment()."\n" unless $level; | 
| 104 | 3 |  |  |  |  | 15 | return "UNDEF".$self->stringComment()."\n"; | 
| 105 |  |  |  |  |  |  | } | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | =head2 binarify (TREE, BDRIVER) | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | Returns a binary representation of this Object. Don't call this (will be called from packBinary() and writeBinary()) | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | =cut | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | sub binarify { | 
| 114 | 6 |  |  | 6 | 1 | 22 | my $self=shift; | 
| 115 | 6 |  |  |  |  | 11 | my $tree=shift; | 
| 116 | 6 |  |  |  |  | 11 | my $bin=shift; | 
| 117 | 6 |  |  |  |  | 21 | my $str=$bin->packType(0); | 
| 118 | 6 |  |  |  |  | 24 | $str.=$self->packComment($bin); | 
| 119 | 6 |  |  |  |  | 29 | return $str; | 
| 120 |  |  |  |  |  |  | } | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | =head1 BUGS | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | This still tests true when using: | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | my $u=Data::Sofu::Undefined->new(); | 
| 128 |  |  |  |  |  |  | if ($u) { | 
| 129 |  |  |  |  |  |  | #This will happen. | 
| 130 |  |  |  |  |  |  | } | 
| 131 |  |  |  |  |  |  | if ($u->isDefined()) { | 
| 132 |  |  |  |  |  |  | #This will not happen. | 
| 133 |  |  |  |  |  |  | } | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | L, L, L, L, L, L, L | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | =cut | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | 1; |