#include "vdf_parser.hpp" #include #include #include #include namespace py = pybind11; struct python_object { py::dict dict; std::string name; void add_attribute(std::string key, std::string value) { dict[py::cast(std::move(key))] = py::cast(std::move(value)); } void add_child(std::unique_ptr< python_object > child) { std::string n = std::move(child->name); dict[py::cast(n)] = std::move(child->dict); } void set_name(std::string n) { name = std::move(n); } }; py::dict py_read_file(const char* filename) { std::ifstream input(filename); return tyti::vdf::read(input).dict; } py::dict py_read(const std::string& filename) { return tyti::vdf::read(std::begin(filename), std::end(filename)).dict; } PYBIND11_MODULE(vdf, m) { m.doc() = "Read and Write Valve's vdf files."; m.def("read", &py_read, "Read vdf from memory"); m.def("read_file", &py_read_file, "Read vdf file"); }