| 1 | package ExtUtils::Typemaps::STL::String; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use ExtUtils::Typemaps; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | our $VERSION = '1.05'; | |
| 8 | |||
| 9 | 1 | 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 | $var = std::string( SvPV_nolen( $arg ), SvCUR( $arg ) ); | ||
| 40 | |||
| 41 | T_STD_STRING_PTR | ||
| 42 | $var = new std::string( SvPV_nolen( $arg ), SvCUR( $arg ) ); | ||
| 43 | |||
| 44 | OUTPUT | ||
| 45 | T_STD_STRING | ||
| 46 | $arg = newSVpvn( $var.c_str(), $var.length() ); | ||
| 47 | |||
| 48 | T_STD_STRING_PTR | ||
| 49 | $arg = newSVpvn( $var->c_str(), $var->length() ); | ||
| 50 | |||
| 51 | =head1 METHODS | ||
| 52 | |||
| 53 | These are the overridden methods: | ||
| 54 | |||
| 55 | =head2 new | ||
| 56 | |||
| 57 | Creates a new C<ExtUtils::Typemaps::STL::String> object. | ||
| 58 | It acts as any other C<ExtUtils::Typemaps> object, except that | ||
| 59 | it has the string type maps initialized. | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | 3 | ▶ | sub new { |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||
| 64 | 3 | my $class = shift; | |
| 65 | |||
| 66 | 3 | my $self = $class->SUPER::new(@_); | |
| 67 | 3 | $self->add_string(string => <<'END_TYPEMAP'); | |
| 68 | TYPEMAP | ||
| 69 | std::string T_STD_STRING | ||
| 70 | std::string* T_STD_STRING_PTR | ||
| 71 | |||
| 72 | INPUT | ||
| 73 | T_STD_STRING | ||
| 74 | $var = std::string( SvPV_nolen( $arg ), SvCUR( $arg ) ); | ||
| 75 | |||
| 76 | T_STD_STRING_PTR | ||
| 77 | $var = new std::string( SvPV_nolen( $arg ), SvCUR( $arg ) ); | ||
| 78 | |||
| 79 | OUTPUT | ||
| 80 | T_STD_STRING | ||
| 81 | $arg = newSVpvn( $var.c_str(), $var.length() ); | ||
| 82 | |||
| 83 | T_STD_STRING_PTR | ||
| 84 | $arg = newSVpvn( $var->c_str(), $var->length() ); | ||
| 85 | END_TYPEMAP | ||
| 86 | |||
| 87 | 3 | return $self; | |
| 88 | } | ||
| 89 | |||
| 90 | 1 | 1; | |
| 91 | |||
| 92 | __END__ | ||