#include <pybind11/pybind11.h>#include <pybind11/stl.h>#include "class.h"namespace py = pybind11;class PyBase: public Base{public:using Base::Base;bool valid() override{PYBIND11_OVERRIDE_PURE(bool,Base,valid,);}};class PyPublicBase: public Base{public:using Base::valid;};void initClass(py::module &m){py::class_<Base, PyBase>(m, "Base").def(py::init<>()).def_readwrite_static("type", &Base::m_type).def("set", py::overload_cast<int>(&Base::set), "set int value").def("set", py::overload_cast<const std::string &>(&Base::set), "set string value").def("parse", [](Base &self, std::vector<std::string> args){std::vector<char *> ptrargs;ptrargs.reserve(args.size());for (auto &s : args){ptrargs.push_back(const_cast<char *>(s.c_str()));}return self.parse(ptrargs.size(), ptrargs.data());}).def("valid", &PyPublicBase::valid);}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。