blib/lib/Getopt/Gen/cmdline_c.pm

filter: Statementstmt 30.7% 4 / 13 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 1 / 2 Podpod 100% 1 / 1 totaltotal 33.3% 6 / 18 CC 2 SCAR 14.7
CC
2
Cov
27%
fill_in
6.0
BEGIN
1.0
CRAP 4.3
« blib/lib/Getopt/Gen.pm ↑ Summary blib/lib/Getopt/Gen/cmdline_h.pm »
1 # -*- Mode: CPerl -*-
2  
3 #############################################################################
4 #
5 # File: Getopt::Gen::cmdline_c.pm
6 # Author: Bryan Jurish <Gen/cmdline_pod.pm>
7 # Description: template for gengetopt-style c source files
8 #
9 #############################################################################
10  
11 package Getopt::Gen::cmdline_c;
12 1 ▶use Getopt::Gen qw(:utils);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # fill_in(%args)
15 # + provides 'SOURCE', 'TYPE', and 'PREPEND'
16 0 ▶sub fill_in {
Subroutine fill_in: not called CC=2 SCAR=17.9
Pod documented
17 0 my ($og,%args) = @_;
18 0 my $datapos = tell(DATA); # save the DATA handle
19  
20 0 my $prepend = 'use Getopt::Gen qw(:utils);';
21 0 ▶ if (exists($args{PREPEND})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"PREPEND"}) 0 0 0
22 0 $prepend .= $args{PREPEND};
23 0 delete($args{PREPEND});
24 }
25  
26 0 my $rc = Getopt::Gen::fill_in($og,
27 TYPE=>'FILEHANDLE',
28 SOURCE=>\*DATA,
29 PREPEND=>$prepend,
30 BROKEN_ARG=>{SOURCE=>__PACKAGE__."::DATA"},
31 %args);
32  
33 0 seek(DATA,$datapos,0); # reset DATA handle
34 0 return $rc;
35 }
36  
37 1 1;
38  
39 ###############################################################
40 # POD docs
41 ###############################################################
42 =pod
43  
44 =head1 NAME
45  
46 Getopt::Gen::cmdline_c.pm - built-in template for generating C source files.
47  
48 =head1 SYNOPSIS
49  
50 use Getopt::Gen;
51  
52 $og = Getopt::Gen::cmdline_c->new(%args);
53 $og->parse($options_file);
54 $og->fill_in(%extra_text_template_fill_in_args);
55  
56 =cut
57  
58 ###############################################################
59 # DESCRIPTION
60 ###############################################################
61 =pod
62  
63 =head1 DESCRIPTION
64  
65 Generate C source files
66 from option specifications.
67  
68 =cut
69  
70 ###############################################################
71 # METHODS
72 ###############################################################
73 =pod
74  
75 =head1 METHODS
76  
77 Most are inherited from L<Getopt::Gen>.
78  
79 =over 4
80  
81 =item * C<fill_in(%args)>
82  
83 Just like the Getopt::Gen method, except you do
84 not need to specify 'TYPE' or 'SOURCE' parameters.
85  
86 =back
87  
88 =cut
89  
90 ###############################################################
91 # Bugs
92 ###############################################################
93 =pod
94  
95 =head1 BUGS
96  
97 Probably many.
98  
99 =cut
100  
101 ###############################################################
102 # Footer
103 ###############################################################
104 =pod
105  
106 =head1 ACKNOWLEDGEMENTS
107  
108 perl by Larry Wall.
109  
110 'gengetopt' was originally written by Roberto Arturo Tena Sanchez,
111 and it is currently maintained by Lorenzo Bettini.
112  
113 =head1 AUTHOR
114  
115 Bryan Jurish E<lt>Gen/cmdline_pod.pmE<gt>
116  
117 =head1 SEE ALSO
118  
119 perl(1).
120 Getopt::Gen(3pm).
121 Getopt::Gen::cmdline_h(3pm).
122 Getopt::Gen::cmdline_pod(3pm).
123 Text::Template(3pm).
124  
125 =cut
126  
127  
128 ###############################################################
129 # TEMPLATE DATA
130 ###############################################################
131 __DATA__
« blib/lib/Getopt/Gen.pm ↑ Summary blib/lib/Getopt/Gen/cmdline_h.pm »