diff --git a/src/perl/make_parameter_source.pl b/src/perl/make_parameter_source.pl --- a/src/perl/make_parameter_source.pl +++ b/src/perl/make_parameter_source.pl @@ -28,68 +28,68 @@ # and sample parameter file %funname = ( - "double" => fgetpar, - "float" => fgetpar, - "int" => igetpar, - "bool" => bgetpar, - "char *" => sgetpar, - "string" => sgetpar, - "double *" => dgetparlist, - ); + "double" => fgetpar, + "float" => fgetpar, + "int" => igetpar, + "bool" => bgetpar, + "char *" => sgetpar, + "string" => sgetpar, + "double *" => dgetparlist, + ); %typetrans = ( - "double" => "double", - "float" => "double", - "int" => "int", - "bool" => "bool", - "char *" => "char *", - "string" => "char *", - "directory" => "char *", - "doublelist" => "double *", - "label" => "label", - "title" => "title", -); + "double" => "double", + "float" => "double", + "int" => "int", + "bool" => "bool", + "char *" => "char *", + "string" => "char *", + "directory" => "char *", + "doublelist" => "double *", + "label" => "label", + "title" => "title", + ); open parfile,"<$ARGV[0]"; open cppfile,">parameter.cpp"; $i=0; while () { #ignore comments - if (/^#/) { - next; - } - @line=split(/=/); + if (/^#/) { + next; + } + @line=split(/=/); #ignore empty lines - if ($#line<1) { - next; - } - $param[$i]=$line[0]; - $value_type=$line[1]; + if ($#line<1) { + next; + } + $param[$i]=$line[0]; + $value_type=$line[1]; - @typel=split(/ \/ /,$value_type); - $value[$i] = $typel[0]; - $type[$i] = $typel[1]; - + @typel=split(/ \/ /,$value_type); + $value[$i] = $typel[0]; + $type[$i] = $typel[1]; + #get rid of spaces - $param[$i] =~ s/ //g; - $value[$i] =~ s/ //g; - $type[$i] =~ s/ //g; - $type[$i] =~s/\n//g; - $convtype[$i]=$typetrans{$type[$i]}; + $param[$i] =~ s/ //g; + $value[$i] =~ s/ //g; + $type[$i] =~ s/ //g; + $type[$i] =~s/\n//g; + $convtype[$i]=$typetrans{$type[$i]}; - if ($convtype[$i] eq "char *") { - $value[$i] = "\"$value[$i]\""; - } - #print cppfile "param = $param, value = $value, type = $type\n"; + if ($convtype[$i] eq "char *") { + $value[$i] = "\"$value[$i]\""; + } + #print cppfile "param = $param, value = $value, type = $type\n"; - $i++; + $i++; } $lines=$i; print cppfile < @@ -104,292 +104,292 @@ print cppfile < -using namespace std; + using namespace std; Parameter::Parameter() { -END_HEADER + END_HEADER -for ($i=0;$i<$lines;$i++) { - if ($convtype[$i] ne "label" && $convtype[$i] ne "title") { - if ($convtype[$i] eq "char *") { - print cppfile " $param[$i] = strdup($value[$i]);\n"; - } else { - if ($convtype[$i] eq "double *") { - #comma separated list expected - @paramlist = split(/,/, $value[$i]); - $length = $#paramlist+1; - print cppfile " $param[$i] = new double\[$length\];\n"; - for ($j=0;$j<=$#paramlist;$j++) { - print cppfile " $param[$i]\[$j\] = $paramlist[$j];\n"; - } - } else { - print cppfile " $param[$i] = $value[$i];\n"; - } + for ($i=0;$i<$lines;$i++) { + if ($convtype[$i] ne "label" && $convtype[$i] ne "title") { + if ($convtype[$i] eq "char *") { + print cppfile " $param[$i] = strdup($value[$i]);\n"; + } else { + if ($convtype[$i] eq "double *") { + #comma separated list expected + @paramlist = split(/,/, $value[$i]); + $length = $#paramlist+1; + print cppfile " $param[$i] = new double\[$length\];\n"; + for ($j=0;$j<=$#paramlist;$j++) { + print cppfile " $param[$i]\[$j\] = $paramlist[$j];\n"; + } + } else { + print cppfile " $param[$i] = $value[$i];\n"; + } + } + } } - } -} -print cppfile < valarray) {\n"; -print cppfile; + print cppfile "void Parameter::AssignValArrayToPar(const char *namec, vector valarray) {\n"; + print cppfile; -for ($i=0;$i<$lines;$i++) { + for ($i=0;$i<$lines;$i++) { - if ($convtype[$i] eq "double *") { - @paramlist = split(/,/,$value[$i]); - print cppfile "if (!strcmp(namec, \"$param[$i]\")) {\n"; - print cppfile " int i=0;\n"; - print cppfile " vector::const_iterator v=valarray.begin();\n"; - print cppfile " while (v!=valarray.end() && i <= $#paramlist ) {\n"; - print cppfile " $param[$i]\[i++\]=*(v++);\n"; - print cppfile " }\n"; - print cppfile "}\n"; - } -} -print cppfile "}\n"; + if ($convtype[$i] eq "double *") { + @paramlist = split(/,/,$value[$i]); + print cppfile "if (!strcmp(namec, \"$param[$i]\")) {\n"; + print cppfile " int i=0;\n"; + print cppfile " vector::const_iterator v=valarray.begin();\n"; + print cppfile " while (v!=valarray.end() && i <= $#paramlist ) {\n"; + print cppfile " $param[$i]\[i++\]=*(v++);\n"; + print cppfile " }\n"; + print cppfile "}\n"; + } + } + print cppfile "}\n"; -print cppfile <xmlChildrenNode; - while (cur!=NULL) { - if ((!xmlStrcmp(cur->name, (const xmlChar *)"parameter"))){ - xmlNode *par_node = cur->xmlChildrenNode; - while (par_node!=NULL) { - { - if (!xmlStrcmp(par_node->name, (const xmlChar *)"par")) { - xmlChar *namec = xmlGetProp(par_node, BAD_CAST "name"); - xmlChar *valc = xmlGetProp(par_node, BAD_CAST "val"); - if (valc) { - AssignValToPar((const char*)namec,(const char*)valc); - } else { - // Probably a valarray - xmlNode *sub_par_node = par_node->xmlChildrenNode; - vector valarray; - while (sub_par_node != NULL) { - if (!xmlStrcmp(sub_par_node->name, (const xmlChar *)"valarray")) { - valarray = XMLIO::XMLReadValArray(sub_par_node); + /* void Parameter::XMLRead(xmlNode *root) { + + xmlNode *cur = root->xmlChildrenNode; + while (cur!=NULL) { + if ((!xmlStrcmp(cur->name, (const xmlChar *)"parameter"))){ + xmlNode *par_node = cur->xmlChildrenNode; + while (par_node!=NULL) { + { + if (!xmlStrcmp(par_node->name, (const xmlChar *)"par")) { + xmlChar *namec = xmlGetProp(par_node, BAD_CAST "name"); + xmlChar *valc = xmlGetProp(par_node, BAD_CAST "val"); + if (valc) { + AssignValToPar((const char*)namec,(const char*)valc); + } else { + // Probably a valarray + xmlNode *sub_par_node = par_node->xmlChildrenNode; + vector valarray; + while (sub_par_node != NULL) { + if (!xmlStrcmp(sub_par_node->name, (const xmlChar *)"valarray")) { + valarray = XMLIO::XMLReadValArray(sub_par_node); + } + sub_par_node = sub_par_node->next; + } + AssignValArrayToPar((const char*)namec, valarray); + } + } + } + par_node = par_node->next; + } + } - sub_par_node = sub_par_node->next; - } - AssignValArrayToPar((const char*)namec, valarray); + cur=cur->next; } - } - } - par_node = par_node->next; - } + + }*/ - } - cur=cur->next; - } - -}*/ + ostream &operator<<(ostream &os, Parameter &p) { + p.Write(os); + return os; + } -ostream &operator<<(ostream &os, Parameter &p) { - p.Write(os); - return os; -} - -END_TRAILER + END_TRAILER # parameter.h -open hfile, ">parameter.h"; -print hfile <parameter.h"; + print hfile < #include -class Parameter { - - public: - Parameter(); - ~Parameter(); - void CleanUp(void); - void Read(const char *filename); - void Write(ostream &os) const; - void XMLAdd(xmlNode *root) const; - void XMLRead(xmlNode *root); - void AssignValToPar(const char *namec, const char *valc); - void AssignValArrayToPar(const char *namec, vector valarray); -END_HEADER2 + class Parameter { + + public: + Parameter(); + ~Parameter(); + void CleanUp(void); + void Read(const char *filename); + void Write(ostream &os) const; + void XMLAdd(xmlNode *root) const; + void XMLRead(xmlNode *root); + void AssignValToPar(const char *namec, const char *valc); + void AssignValArrayToPar(const char *namec, vector valarray); + END_HEADER2 - for ($i=0;$i<$lines;$i++) { - if ($convtype[$i] ne "label" && $convtype[$i] ne "title") { - print hfile " $convtype[$i] $param[$i];\n"; - } - } + for ($i=0;$i<$lines;$i++) { + if ($convtype[$i] ne "label" && $convtype[$i] ne "title") { + print hfile " $convtype[$i] $param[$i];\n"; + } + } -print hfile <default.par"; + open parfile,">default.par"; -for ($i=0;$i<$lines;$i++) { - if ($type[$i] ne "title" && $type[$i] ne "label") { - $value[$i] =~ s/\"//g; - print parfile " $param[$i] = $value[$i]\n"; - } -} + for ($i=0;$i<$lines;$i++) { + if ($type[$i] ne "title" && $type[$i] ne "label") { + $value[$i] =~ s/\"//g; + print parfile " $param[$i] = $value[$i]\n"; + } + } + +# finis