aboutsummaryrefslogtreecommitdiffstats
path: root/libical/scripts/readvaluesfile.pl
blob: d5e2d36fd8ea19e55829cd7be7e79c243b26d16d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130


sub read_values_file {
  
  my $path = shift;
  my %h;

  open(F,$path) || die "Can't open values file $path";

  while(<F>){
    
    chop; 
 
    s/#.*$//g;
    s/\"//g;
   
    next if ! $_;

    @column = split(/,/,$_);
    
    my $value_name = $column[0];

    my $c_type_str =  $column[1];
    my $c_autogen = ($c_type_str =~ /\(a\)/);

    my $c_type = $c_type_str;
    $c_type =~ s/\(.\)//;

    my $python_type =  $column[2];
    my $components = $column[3];
    my $enum_values = $column[4];

    my @components;
    if($components ne "unitary"){
      @components = split(/;/,$components);
    } else {
      @components = ();
    }

    my @enums;
    if($enum_values) {
      @enums  = split(/;/,$enum_values);

    } else {
      @enums = ();
    }

    $h{$value_name} = { C => [$c_autogen,$c_type],
            perl => $perl_type,
            python => $python_type,
            components=>[@components],
            enums=>[@enums]
              };
  }

  return %h;
}

sub read_properties_file {
  
  my $path = shift;
  my %h;

  open(F,$path) || die "Can't open properties file $path";

  while(<F>){
    
    chop; 
 
    s/#.*$//g;
    s/\"//g;
   
    next if ! $_;

    @column = split(/,/,$_);
    
    my $property_name = $column[0];

    my $lic_value = $column[1];
    my $default_value = $column[2];
    
    $h{$property_name} = { lic_value => $lic_value,
               default_value => $default_value
             };
  }

  return %h;
}

sub read_parameters_file {
  
  my $path = shift;
  my %h;

  open(F,$path) || die "Can't open parameters file $path";

  while(<F>){
    
    chop; 
 
    s/#.*$//g;
    s/\"//g;
   
    next if ! $_;

    @column = split(/\,/,$_);
  
    my $parameter_name = $column[0];

    my $data_type = $column[1];
    my $enum_string = $column[2];

    my @enums;
    if($enum_string){
      @enums =  split(/;/,$enum_string);
    }
    
    $h{$parameter_name} = { C => $data_type,
               enums => [@enums]
             };
  }

  close(F);

  return %h;
}



1;