hikyuu2/hikyuu_pywrap/ioredirect.cpp

21 lines
539 B
C++
Raw Normal View History

/*
* ioredirect.cpp
*
* Created on: 2018827
* Author: fasiondog
*/
2023-12-26 18:25:50 +08:00
#include <pybind11/pybind11.h>
#include "ioredirect.h"
2023-12-26 18:25:50 +08:00
namespace py = pybind11;
2023-12-26 18:25:50 +08:00
void export_io_redirect(py::module& m) {
py::class_<OstreamRedirect>(m, "OstreamRedirect")
.def(py::init<bool, bool>(), py::arg("stdout") = true, py::arg("stderr") = true)
2020-06-25 15:59:37 +08:00
.def("__enter__", &OstreamRedirect::enter)
.def("__exit__", &OstreamRedirect::exit)
.def("open", &OstreamRedirect::enter)
.def("close", &OstreamRedirect::exit);
}