src/xs/typemap/string.h

filter: Statementstmt 0.0% 0 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 3 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« src/xs/typemap/object.h ↑ Summary t/cookbook/recipe01.xsi »
1 #pragma once
2 #include "base.h"
3 #include "../Simple.h"
4 #include <string>
5 #include <panda/string.h>
6 #include <panda/string_view.h>
7  
8 namespace xs {
9  
10 template <> struct Typemap<panda::string> : TypemapBase<panda::string> {
11 static inline panda::string in (SV* arg) {
12 STRLEN len;
13 const char* data = SvPV_const(arg, len);
14 return panda::string(data, len);
15 }
16 static inline Sv out (const panda::string& str, const Sv& = Sv()) { return Simple(str); }
17 };
18  
19 template <> struct Typemap<std::string> : TypemapBase<std::string> {
20 static inline std::string in (SV* arg) {
21 STRLEN len;
22 const char* data = SvPV_const(arg, len);
23 return std::string(data, len);
24 }
25 static inline Sv out (const std::string& str, const Sv& = Sv()) { return Simple(panda::string_view(str.data(), str.length())); }
26 };
27  
28 template <> struct Typemap<panda::string_view> : TypemapBase<panda::string_view> {
29 0 static inline panda::string_view in (SV* arg) {
30 STRLEN len;
31 0 const char* data = SvPV_const(arg, len);
32 0 return panda::string_view(data, len);
33 }
34 static inline Sv out (const panda::string_view& str, const Sv& = Sv()) { return Simple(str); }
35 };
36  
37 }
« src/xs/typemap/object.h ↑ Summary t/cookbook/recipe01.xsi »