ExtUti...:String(3pm)

πŸ’… ExtUtils::Typemaps::STL::String β€” the 3pm manual, bestie edition πŸŽ€

okay so this page lives in the User Contributed Perl Documentation section (3pm) of the manual, and it's literally all about ExtUtils::Typemaps::STL::String πŸ¦‹ β€” no cap, that's the whole vibe.


✨ NAME ✨

ExtUtils::Typemaps::STL::String β€” a whole set of typemaps for STL std::strings, periodt πŸ’–


🌸 SYNOPSIS 🌸

  use ExtUtils::Typemaps::STL::String;
  # First, read my own type maps:
  my $private_map = ExtUtils::Typemaps->new(file => 'my.map');

  # Then, get the object map set and merge it into my maps
  $private_map->merge(typemap => ExtUtils::Typemaps::STL::String->new);

  # Now, write the combined map to an output file
  $private_map->write(file => 'typemap');

like, read your own maps, merge these in, write it out β€” the whole glow-up in three steps ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

ExtUtils::Typemaps::STL::String is an ExtUtils::Typemaps subclass (yes, a subclass, main character energy πŸ‘‘) that hands you a set of mappings for C++ STL strings. These are them, exactly, no edits:

TYPEMAP
std::string   T_STD_STRING
std::string*  T_STD_STRING_PTR

INPUT
T_STD_STRING
    $var = std::string( SvPV_nolen( $arg ), SvCUR( $arg ) );

T_STD_STRING_PTR
    $var = new std::string( SvPV_nolen( $arg ), SvCUR( $arg ) );

OUTPUT
T_STD_STRING
    $arg = newSVpvn( $var.c_str(), $var.length() );

T_STD_STRING_PTR
    $arg = newSVpvn( $var->c_str(), $var->length() );

like β€” TYPEMAP says what maps to what, INPUT converts incoming Perl scalars into std::strings (the pointer one news it, obvs), and OUTPUT turns them back into SV's with newSVpvn. it's giving symmetry πŸ’…


🧚 METHODS 🧚

these are the overridden methods, iykyk:

⭐ new

creates a new ExtUtils::Typemaps::STL::String object πŸ’– it acts like any other ExtUtils::Typemaps object, except β€” plot twist β€” it already has the string type maps initialized. so you don't gotta do a thing, it just comes pre-loaded ✨


🌈 SEE ALSO 🌈

  • ExtUtils::Typemaps
  • ExtUtils::Typemaps::Default
  • ExtUtils::Typemaps::ObjectMap

go read those too, they're the supporting cast 🫢


πŸ’œ AUTHOR πŸ’œ

Steffen Mueller <smueller@cpan.org> β€” we stan 🫑


Copyright 2010, 2011, 2012, 2013 by Steffen Mueller

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

fr fr read the license before you go redistributing, bestie 😭 it's the same terms as Perl itself, so keep it cute and keep it legal πŸ’€

okay that's the whole page!! no notes ✨ this was perl v5.36.0, dated 2022-10-21, filed under ExtUti...:String(3pm) on the man shelf β€” mwah, slay, bye πŸ’…πŸ’–

πŸ“¦ where this page comes from