require db4-devel
[platform/upstream/libical.git] / scripts / readvaluesfile.pl
1
2
3 sub read_values_file {
4   
5   my $path = shift;
6   my %h;
7
8   open(F,$path) || die "Can't open values file $path";
9
10   while(<F>){
11     
12     chop; 
13  
14     s/#.*$//g;
15     s/\"//g;
16     s/\r//g;
17    
18     next if ! $_;
19
20     @column = split(/,/,$_);
21     
22     my $value_name = $column[0];
23
24     my $c_type_str =  $column[1];
25     my $c_autogen = ($c_type_str =~ /\(a\)/);
26
27     my $c_type = $c_type_str;
28     $c_type =~ s/\(.\)//;
29
30     my $python_type =  $column[2];
31     my $components = $column[3];
32     my $enum_values = $column[4];
33
34     my @components;
35     if($components ne "unitary"){
36       @components = split(/;/,$components);
37     } else {
38       @components = ();
39     }
40
41     my @enums;
42     if($enum_values) {
43       @enums  = split(/;/,$enum_values);
44
45     } else {
46       @enums = ();
47     }
48
49     $h{$value_name} = { C => [$c_autogen,$c_type],
50                         perl => $perl_type,
51                         python => $python_type,
52                         components=>[@components],
53                         enums=>[@enums]
54                       };
55   }
56
57   return %h;
58 }
59
60 sub read_properties_file {
61   
62   my $path = shift;
63   my %h;
64
65   open(F,$path) || die "Can't open properties file $path";
66
67   while(<F>){
68     
69     chop; 
70  
71     s/#.*$//g;
72     s/\"//g;
73     s/\r//g;
74    
75     next if ! $_;
76
77     @column = split(/,/,$_);
78     
79     my $property_name = $column[0];
80
81     my $lic_value = $column[1];
82     my $default_value = $column[2];
83     
84     $h{$property_name} = { lic_value => $lic_value,
85                            default_value => $default_value
86                          };
87   }
88
89   return %h;
90 }
91
92 sub read_parameters_file {
93   
94   my $path = shift;
95   my %h;
96
97   open(F,$path) || die "Can't open parameters file $path";
98
99   while(<F>){
100     
101     chop; 
102  
103     s/#.*$//g;
104     s/\"//g;
105     s/\r//g;
106    
107     next if ! $_;
108
109     @column = split(/\,/,$_);
110   
111     my $parameter_name = $column[0];
112
113     my $enumConst = $column[1];
114     my $data_type = $column[2];
115     my $enum_string = $column[3];
116
117     my @enums;
118     if($enum_string){
119       @enums =  split(/;/,$enum_string);
120     }
121     
122     $h{$parameter_name} = { C => $data_type,
123                            kindEnum => $enumConst,
124                            enums => [@enums]
125                          };
126   }
127
128   close(F);
129
130   return %h;
131 }
132
133
134
135 1;