File: glade2cpp.pl

package info (click to toggle)
mysql-workbench 6.3.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 113,932 kB
  • ctags: 87,814
  • sloc: ansic: 955,521; cpp: 427,465; python: 59,728; yacc: 59,129; xml: 54,204; sql: 7,091; objc: 965; makefile: 638; sh: 613; java: 237; perl: 30; ruby: 6; php: 1
file content (34 lines) | stat: -rwxr-xr-x 816 bytes parent folder | download
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
#!/usr/bin/perl
use strict;
use File::Basename;

open (FH, $ARGV[0]) || die ("Cant open $ARGV[1]");

my $fname=basename($ARGV[0]);

$fname =~ s/\./_/;
my $header=$fname.".h";
my $source=$fname.".cpp";
my $size = 0;

open SRC, ">", $source || die ("Can't create header file %s");

printf SRC "\n//This file is auto-generated. Do not modify.\n\n\nextern const char *modelXml = ";
foreach my $line (<FH>)
{
  $size += length($line);
  $line =~ s/\"/\\"/g;
  chomp $line;
  #print '"'."$line".'"';
  printf SRC '"';
  printf SRC $line;
  printf SRC "\\n\"\n";
}
print SRC "\"\";\n";
close(SRC);

open HDR, ">", $header || die ("Can't create header file %s");
printf HDR "#ifndef __".$fname."_h__\n#define __"."$fname"."_h__\n\nextern const char *modelXml;\nenum {modelXmlSize=$size};\n#endif\n";
close(HDR);

close(FH);