11 #include <pybind11/iostream.h>
12 #include <pybind11/pybind11.h>
13 #include <pybind11/stl.h>
19 template <
typename StringType>
24 if (PYBIND11_BYTES_AS_STRING_AND_SIZE(
data.ptr(), &buffer, &length))
25 pybind11_fail(
"Unable to extract string contents! (invalid type)");
26 std::memcpy(start, buffer,
n);
34 if (PyUnicode_Check(
data.ptr())) {
35 data = reinterpret_steal<object>(PyUnicode_AsUTF8String(
data.ptr()));
37 pybind11_fail(
"Unable to extract string contents! (encoding issue)");
44 template <
typename StringType>
62 if (gptr() < egptr()) {
63 return traits_type::to_int_type(*gptr());
68 if (eback() == base) {
75 return traits_type::eof();
78 setg(base, start, start +
n);
79 return traits_type::to_int_type(*gptr());
96 std::unique_ptr<pybind11::detail::pythonbuf>
buf;
VisitorOStreamResources()=default
std::unique_ptr< std::ostream > ostream
std::unique_ptr< pybind11::detail::pythonbuf > buf
VisitorOStreamResources(pybind11::object object)
pythonibuf & operator=(const pythonibuf &)
std::streambuf::traits_type traits_type
pythonibuf(object pyistream)
pythonibuf(const pythonibuf &)
static const std::size_t buf_sz
static const std::size_t put_back_
int const size_t const size_t n
void operator()(char *start, size_t n, str data)
void operator()(char *start, size_t n, StringType data)