Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
c8f68b3d
Commit
c8f68b3d
authored
Mar 02, 2016
by
hulucc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add wstring caster
parent
937d646b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
include/pybind11/cast.h
+23
-0
No files found.
include/pybind11/cast.h
View file @
c8f68b3d
...
@@ -348,6 +348,29 @@ public:
...
@@ -348,6 +348,29 @@ public:
PYBIND11_TYPE_CASTER
(
std
::
string
,
_
(
PYBIND11_STRING_NAME
));
PYBIND11_TYPE_CASTER
(
std
::
string
,
_
(
PYBIND11_STRING_NAME
));
};
};
template
<>
class
type_caster
<
std
::
wstring
>
{
public
:
bool
load
(
handle
src
,
bool
)
{
object
temp
;
handle
load_src
=
src
;
if
(
!
PyUnicode_Check
(
load_src
.
ptr
()))
{
temp
=
object
(
PyUnicode_FromObject
(
load_src
.
ptr
()),
false
);
if
(
!
temp
)
{
PyErr_Clear
();
return
false
;
}
load_src
=
temp
;
}
wchar_t
*
buffer
=
PyUnicode_AS_UNICODE
(
load_src
.
ptr
());
size_t
length
=
PyUnicode_GET_SIZE
(
load_src
.
ptr
());
value
=
std
::
wstring
(
buffer
,
length
);
return
true
;
}
static
handle
cast
(
const
std
::
wstring
&
src
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
return
PyUnicode_FromWideChar
(
src
.
c_str
(),
src
.
length
());
}
PYBIND11_TYPE_CASTER
(
std
::
wstring
,
_
(
PYBIND11_STRING_NAME
));
};
template
<>
class
type_caster
<
char
>
{
template
<>
class
type_caster
<
char
>
{
public
:
public
:
bool
load
(
handle
src
,
bool
)
{
bool
load
(
handle
src
,
bool
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment