#!/usr/bin/perl ########################################################################### # processing2cpp.pl # --------------------- # begin : July 2015 # copyright : (C) 2015 by Juergen E. Fischer # email : jef at norbit dot de ########################################################################### # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation; either version 2 of the License, or # # (at your option) any later version. # # # ########################################################################### use XML::Simple; use Data::Dumper; die "usage: $0 dest.cpp\n" unless @ARGV==1; open F, ">$ARGV[0]"; print F <) { my $xml = XMLin($f, ForceArray=>1); foreach my $k (qw/longname group description/) { $strings{"OTBAlgorithm"}{$xml->{$k}->[0]} = 1; } } for my $f () { open I, $f; my $name = scalar(); my $desc = scalar(); my $group = scalar(); close I; chop $desc; chop $group; $strings{"GrassAlgorithm"}{$desc} = 1; $strings{"GrassAlgorithm"}{$group} = 1; } for my $f () { open I, $f; my $desc = scalar(); my $name = scalar(); my $group = scalar(); close I; chop $desc; chop $group; $strings{"TAUDEMAlgorithm"}{$desc} = 1; $strings{"TAUDEMAlgorithm"}{$group} = 1; } for my $f () { open I, $f; my $desc = scalar(); close I; chop $desc; $strings{"SAGAAlgorithm"}{$desc} = 1; } for my $f ( ("python/plugins/processing/gui/algclasssification.txt", "python/plugins/processing/gui/algnames.txt") ) { open I, $f; while() { chop; s/^.*,//; foreach my $v (split "/", $_) { $strings{"AlgorithmClassification"}{$v} = 1; } } close I; } foreach my $k (keys %strings) { foreach my $v (keys %{ $strings{$k} } ) { $v =~ s/\\/\\\\/g; $v =~ s/"/\\"/g; $v =~ s/\n/\\n/g; print F "translate(\"$k\", \"$v\");\n"; } } close F;