|
| 1 | +/* |
| 2 | +* Copyright 2021 The casbin Authors. All Rights Reserved. |
| 3 | +* |
| 4 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +* you may not use this file except in compliance with the License. |
| 6 | +* You may obtain a copy of the License at |
| 7 | +* |
| 8 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +* |
| 10 | +* Unless required by applicable law or agreed to in writing, software |
| 11 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +* See the License for the specific language governing permissions and |
| 14 | +* limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +#include <pybind11/pybind11.h> |
| 18 | +#include <pybind11/stl.h> |
| 19 | +#include <casbin/casbin.h> |
| 20 | + |
| 21 | +namespace py = pybind11; |
| 22 | + |
| 23 | +void bindPyConfig(py::module &m) { |
| 24 | + py::class_<casbin::Config>(m, "Config") |
| 25 | + .def(py::init<>()) |
| 26 | + .def(py::init<const std::string&>()) |
| 27 | + .def_static("NewConfig", &casbin::Config::NewConfig, R"doc( |
| 28 | + /** |
| 29 | + * NewConfig create an empty configuration representation from file. |
| 30 | + * |
| 31 | + * @param confName the path of the model file. |
| 32 | + * @return the constructor of Config. |
| 33 | + */ |
| 34 | + )doc") |
| 35 | + .def_static("NewConfigFromText", &casbin::Config::NewConfigFromText, R"doc( |
| 36 | + /** |
| 37 | + * newConfigFromText create an empty configuration representation from text. |
| 38 | + * |
| 39 | + * @param text the model text. |
| 40 | + * @return the constructor of Config. |
| 41 | + */ |
| 42 | + )doc") |
| 43 | + .def("GetBool", &casbin::Config::GetBool) |
| 44 | + .def("GetInt", &casbin::Config::GetInt) |
| 45 | + .def("GetFloat", &casbin::Config::GetFloat) |
| 46 | + .def("GetString", &casbin::Config::GetString) |
| 47 | + .def("GetStrings", &casbin::Config::GetStrings) |
| 48 | + .def("Set", &casbin::Config::Set) |
| 49 | + .def("Get", &casbin::Config::Get); |
| 50 | +} |
0 commit comments