Typemaps/STL/String.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 21 / 21 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Typemaps/STL.pm ↑ Summary
1 package ExtUtils::Typemaps::STL::String;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use ExtUtils::Typemaps;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '1.07';
8  
9 2 our @ISA = qw(ExtUtils::Typemaps);
10  
11 =head1 NAME
12  
13 ExtUtils::Typemaps::STL::String - A set of typemaps for STL std::strings
14  
15 =head1 SYNOPSIS
16  
17 use ExtUtils::Typemaps::STL::String;
18 # First, read my own type maps:
19 my $private_map = ExtUtils::Typemaps->new(file => 'my.map');
20
21 # Then, get the object map set and merge it into my maps
22 $private_map->merge(typemap => ExtUtils::Typemaps::STL::String->new);
23
24 # Now, write the combined map to an output file
25 $private_map->write(file => 'typemap');
26  
27 =head1 DESCRIPTION
28  
29 C<ExtUtils::Typemaps::STL::String> is an C<ExtUtils::Typemaps>
30 subclass that provides a set of mappings for C++ STL strings.
31 These are:
32  
33 TYPEMAP
34 std::string T_STD_STRING
35 std::string* T_STD_STRING_PTR
36
37 INPUT
38 T_STD_STRING
39 {
40 size_t len;
41 const char * c = SvPV($arg, len);
42 $var = std::string(c, len);
43 }
44
45 T_STD_STRING_PTR
46 {
47 size_t len;
48 const char * c = SvPV($arg, len);
49 $var = new std::string(c, len);
50 }
51
52 OUTPUT
53 T_STD_STRING
54 $arg = newSVpvn( $var.c_str(), $var.length() );
55
56 T_STD_STRING_PTR
57 $arg = newSVpvn( $var->c_str(), $var->length() );
58  
59 =head1 METHODS
60  
61 These are the overridden methods:
62  
63 =head2 new
64  
65 Creates a new C<ExtUtils::Typemaps::STL::String> object.
66 It acts as any other C<ExtUtils::Typemaps> object, except that
67 it has the string type maps initialized.
68  
69 =cut
70  
71 5 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
72 5 my $class = shift;
73  
74 5 my $self = $class->SUPER::new(@_);
75 5 $self->add_string(string => <<'END_TYPEMAP');
76 TYPEMAP
77 std::string T_STD_STRING
78 std::string* T_STD_STRING_PTR
79  
80 INPUT
81 T_STD_STRING
82 {
83 size_t len;
84 const char * c = SvPV($arg, len);
85 $var = std::string(c, len);
86 }
87  
88 T_STD_STRING_PTR
89 {
90 size_t len;
91 const char * c = SvPV($arg, len);
92 $var = new std::string(c, len);
93 }
94  
95 OUTPUT
96 T_STD_STRING
97 $arg = newSVpvn( $var.c_str(), $var.length() );
98  
99 T_STD_STRING_PTR
100 $arg = newSVpvn( $var->c_str(), $var->length() );
101 END_TYPEMAP
102  
103 5 return $self;
104 }
105  
106 2 1;
107  
108 __END__
« Typemaps/STL.pm ↑ Summary