OSSP CVS Repository

ossp - Check-in [3413]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3413
Date: 2003-May-29 20:43:50 (local)
2003-May-29 18:43:50 (UTC)
User:rse
Branch:
Comment: o fix auto-indentation generation on unfolding o add "storage" mode functionality
Tickets:
Inspections:
Files:
ossp-pkg/string-divert/ChangeLog      1.2 -> 1.3     2 inserted, 1 deleted
ossp-pkg/string-divert/Divert.pm      1.3 -> 1.4     35 inserted, 8 deleted
ossp-pkg/string-divert/Divert.pod      1.2 -> 1.3     19 inserted, 2 deleted

ossp-pkg/string-divert/ChangeLog 1.2 -> 1.3

--- ChangeLog    2003/05/23 20:37:32     1.2
+++ ChangeLog    2003/05/29 18:43:50     1.3
@@ -2,8 +2,9 @@
   ChangeLog
   =========
 
-  0.92 (23-Apr-2003)
+  0.92 (29-Apr-2003)
       o fix auto-indentation generation on unfolding
+      o add "storage" mode functionality
   0.91 (23-Apr-2003)
       o direct MakeMaker to not install sample[12].pl
       o cleanup naming of module, etc.


ossp-pkg/string-divert/Divert.pm 1.3 -> 1.4

--- Divert.pm    2003/05/23 20:37:32     1.3
+++ Divert.pm    2003/05/29 18:43:50     1.4
@@ -40,7 +40,7 @@
 
 our @ISA       = qw(Exporter);
 our @EXPORT_OK = qw(new destroy DESTROY
-                    name overwrite
+                    name overwrite storage
                     assign append string bool
                     fold unfold folding folder
                     divert undivert diversion
@@ -56,6 +56,7 @@
 
     $self->{name}      = (defined($name) ? $name : '');
     $self->{overwrite} = 'none';
+    $self->{storage}   = 'all';
     $self->{chunks}    = [ '' ];
     $self->{diversion} = [];
     $self->{foldermk}  = '{#%s#}';
@@ -103,6 +104,20 @@
     return $old_mode;
 }
 
+#   operation: set/get storage mode
+sub storage ($;$) {
+    my ($self, $mode) = @_;
+    return $self->{diversion}->[-1]->storage($mode)
+        if (@{$self->{diversion}} > 0);
+    my $old_mode = $self->{storage};
+    if (defined($mode)) {
+        die "invalid mode argument"
+            if ($mode !~ m/^(none|fold|all)$/);
+        $self->{storage} = $mode;
+    }
+    return $old_mode;
+}
+
 #   internal: split string into chunks
 sub _chunking ($) {
     my ($self, $string) = @_;
@@ -110,17 +125,19 @@
     my $folderre = $self->{folderre};
     while ($string =~ m/${folderre}()/s) {
         my ($prolog, $id) = ($`, $1);
-        push(@chunks, $prolog) if ($prolog ne '');
+        push(@chunks, $prolog) if ($prolog ne '' and $self->{storage} !~ m/^(none|fold)/);
         die "empty folding object name"
             if ($id eq '');
-        my $object = $self->folding($id);
-        $object = $self->new($id) if (not defined($object));
-        die "cannot reuse or create folding sub object \"$id\""
-            if (not defined($object));
-        push(@chunks, $object);
+        if ($self->{storage} ne 'none') {
+            my $object = $self->folding($id);
+            $object = $self->new($id) if (not defined($object));
+            die "cannot reuse or create folding sub object \"$id\""
+                if (not defined($object));
+            push(@chunks, $object);
+        }
         $string = $';
     }
-    push(@chunks, $string) if ($string ne '');
+    push(@chunks, $string) if ($string ne '' and $self->{storage} !~ m/^(none|fold)/);
     return @chunks;
 }
 
@@ -229,6 +246,7 @@
         if (@{$self->{diversion}} > 0);
     die "undefined folding object identifier"
         if (not defined($id));
+    return undef if ($self->{storage} eq 'none');
     if (ref($id)) {
         die "folding object not of class String::Divert"
             if (   UNIVERSAL::isa($id, "String::Divert")
@@ -318,6 +336,7 @@
     }
     else {
         #   create folder
+        return "" if ($self->{storage} eq 'none');
         my $folder = sprintf($self->{foldermk}, $a);
         return $folder;
     }
@@ -337,6 +356,14 @@
 sub undivert ($;$) {
     my ($self, $num) = @_;
     $num = 1 if (not defined($num));
+    if ($num !~ m|^\d+$|) {
+        my $name = $num;
+        for ($num = 1; $num <= @{$self->{diversion}}; $num++) {
+            last if ($self->{diversion}->[-$num]->{name} eq $name);
+        }
+        die "no object named \"$name\" found for undiversion"
+            if ($num > @{$self->{diversion}});
+    }
     $num = @{$self->{diversion}} if ($num == 0);
     die "less number (".scalar(@{$self->{diversion}}).") of diversions active than requested ($num) to undivert"
         if ($num > @{$self->{diversion}});


ossp-pkg/string-divert/Divert.pod 1.2 -> 1.3

--- Divert.pod   2003/05/23 11:09:57     1.2
+++ Divert.pod   2003/05/29 18:43:50     1.3
@@ -157,7 +157,18 @@
 I<Overwrite Mode>. Retrieves the current overwrite mode of string object
 C<$x> or sets a new overwrite mode. The mode can be C<"none"> (no
 overwriting), C<"once"> (no overwriting once on next B<append> operation
-only), or C<"always"> (overwriting on every B<append> operation).
+only), or C<"always"> (overwriting on every B<append> operation). The
+default is C<"none">.
+
+=item SAPI: C<$mode = $x-E<gt>>B<storage>C<;>
+
+=item SAPI: [C<$old_mode =>] C<$x-E<gt>>B<storage>C<($new_mode);>
+
+I<Storage Mode>. Retrieves the current storage mode of string object
+C<$x> or sets a new storage mode. The mode can be C<"none"> (neither
+contents nor foldings is stored), C<"fold"> (only foldings are stored),
+or C<"all"> (both contents and foldings are stored). The default is
+C<"all">.
 
 =back
 
@@ -274,11 +285,17 @@
 
 =item SAPI: [C<$x =>] C<$x-E<gt>>B<undivert>C<($num);>
 
+=item SAPI: [C<$x =>] C<$x-E<gt>>B<undivert>C<($name);>
+
 =item XAPI: C<$x E<lt>E<lt> $num;>
 
+=item XAPI: C<$x E<lt>E<lt> $name;>
+
 I<Content Diversion Deactivation>. This deactivates the last C<$num>
 activated diversions. If C<$num> is C<0>, deactivates all activated
-diversions.
+diversions. If C<$name> is given (i.e. the argument is not numeric), it
+deactivates all last activated diversion up to and including the one to
+the string object named C<$name>.
 
 =item SAPI: C<$y = $x-E<gt>>B<diversion>C<;>
 

CVSTrac 2.0.1