ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/UserQuery.pm
(Generate patch)

Comparing COMP/SCRAM/src/ActiveDoc/UserQuery.pm (file contents):
Revision 1.3 by williamc, Thu Sep 23 10:35:02 1999 UTC vs.
Revision 1.5 by williamc, Mon Oct 25 15:14:38 1999 UTC

# Line 1 | Line 1
1   #
2   #  UserQuery
3   #
4 < #  Set up and record Queries requested fromthe user
4 > #  Set up and record Queries requested from the user
5   #
6   # Interface
7   # ---------
8   # new(UserInterface)    : A new query object with a specific interface
9 + # dump(fh,expr)         : dump out parameters that match expr to filehandle
10 + # store(fh)             : dump every param to fh
11 + # restore(fh)           : restore from filehandle
12 + # params()              : return list of all params
13   # setparam(name,value)  : set a parameter
14   # setifundef(name,value) : only set param to value if undefined
15   # getparam(name)        : return value of named parameter
# Line 33 | Line 37 | sub new {
37          return $self;
38   }
39  
40 + sub dump {
41 +        my $self=shift;
42 +        my $fh=shift;
43 +        my $string=shift;
44 +
45 +        foreach $key ( keys %{$self->{params}} ) {
46 +          if ( $key=~/$string/ ) {
47 +                print $fh "k:".$key."\n";
48 +                print $fh "v:".$self->{params}{$key}."\n";
49 +          }
50 +        }
51 +        print $fh "#End\n";
52 + }
53 +
54 + sub store {
55 +        my $self=shift;
56 +        my $fh=shift;
57 +
58 +        my $key;
59 +        foreach $key ( keys %{$self->{params}} ) {
60 +          print $fh "k:".$key."\n";
61 +          print $fh "v:".$self->{params}{$key}."\n";
62 +        }
63 +        print $fh "#End\n";
64 + }
65 +
66 + sub restore {
67 +        my $self=shift;
68 +        my $fh=shift;
69 +
70 +        my $check="k:";
71 +        my $key="";
72 +        while ( $line=<$fh> ) {
73 +          chomp $line;
74 +          last if ( $line eq "\#End" );
75 +          if ( $line!~/^$check/ ) {
76 +                die "Data Corruption Error when restoring $self\n";
77 +          }
78 +          if ( $check eq "k:" ) {
79 +                $check="v:";
80 +                ($key=$line)=~s/k://;
81 +          }
82 +          else {
83 +                $check="k:";
84 +                ($value=$line)=~s/v://;
85 +                $self->setparam($key,$value);
86 +          }
87 +        } #end while
88 + }
89 +
90   sub setparam {
91          my $self=shift;
92          my $name=shift;
93          my $value=shift;
94  
95 +        print "Setting $name = $value\n";
96          $self->{params}{$name}=$value;
97   }
98  
99 + sub params {
100 +        my $self=shift;
101 +        
102 +        return ( keys %{$self->{params}} );
103 + }
104 +
105   sub setifundef {
106          my $self=shift;
107          my $name=shift;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines