Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
159e5589
Commit
159e5589
authored
Jun 16, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support iteration over std::string in C++
parent
2bac445c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
Cython/Includes/libcpp/string.pxd
Cython/Includes/libcpp/string.pxd
+34
-0
tests/run/cpp_stl_string.pyx
tests/run/cpp_stl_string.pyx
+10
-0
No files found.
Cython/Includes/libcpp/string.pxd
View file @
159e5589
...
...
@@ -15,6 +15,40 @@ cdef extern from "<string>" namespace "std" nogil:
# as a string formed by a repetition of character c, n times.
string
(
size_t
,
char
)
except
+
cppclass
iterator
:
iterator
()
char
&
operator
*
()
iterator
(
iterator
&
)
iterator
operator
++
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
cppclass
reverse_iterator
:
char
&
operator
*
()
iterator
operator
++
()
iterator
operator
--
()
iterator
operator
+
(
size_t
)
iterator
operator
-
(
size_t
)
bint
operator
==
(
reverse_iterator
)
bint
operator
!=
(
reverse_iterator
)
bint
operator
<
(
reverse_iterator
)
bint
operator
>
(
reverse_iterator
)
bint
operator
<=
(
reverse_iterator
)
bint
operator
>=
(
reverse_iterator
)
cppclass
const_iterator
(
iterator
):
pass
cppclass
const_reverse_iterator
(
reverse_iterator
):
pass
iterator
begin
()
const_iterator
const_begin
"begin"
()
iterator
end
()
const_iterator
const_end
"end"
()
reverse_iterator
rbegin
()
const_reverse_iterator
const_rbegin
"rbegin"
()
reverse_iterator
rend
()
const_reverse_iterator
const_rend
"rend"
()
const
char
*
c_str
()
const
char
*
data
()
size_t
size
()
...
...
tests/run/cpp_stl_string.pyx
View file @
159e5589
...
...
@@ -300,3 +300,13 @@ def test_greater_than(char *a, char *b):
cdef
string
s
=
string
(
a
)
cdef
string
t
=
string
(
b
)
return
(
s
>
t
,
s
>
b
,
s
>=
b
)
def
test_iteration
(
string
s
):
"""
>>> test_iteration(b'xyz')
[120, 121, 122]
>>> test_iteration(b'')
[]
"""
return
[
c
for
c
in
s
]
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