1/* -----------------------------------------------------------------------------
2 * See the LICENSE file for information on copyright, usage and redistribution
3 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
4 *
5 * std_common.i
6 *
7 * SWIG typemaps for STL - common utilities
8 * ----------------------------------------------------------------------------- */
9
10%include <std/std_except.i>
11
12%apply size_t { std::size_t };
13
14%{
15#include <string>
16
17double SwigSvToNumber(SV* sv) {
18    return SvIOK(sv) ? double(SvIVX(sv)) : SvNVX(sv);
19}
20std::string SwigSvToString(SV* sv) {
21    STRLEN len;
22    char *ptr = SvPV(sv, len);
23    return std::string(ptr, len);
24}
25void SwigSvFromString(SV* sv, const std::string& s) {
26    sv_setpvn(sv,s.data(),s.size());
27}
28%}
29
30