Add StructParser utility

This commit is contained in:
Pragyansh Chaturvedi
2025-10-19 22:02:19 +05:30
parent f7874137ad
commit 05d5bba4f7
3 changed files with 59 additions and 3 deletions

20
src/utils/struct_parser.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef PYLIBBPF_STRUCT_PARSER_H
#define PYLIBBPF_STRUCT_PARSER_H
#include <pybind11/pybind11.h>
#include <string>
#include <unordered_map>
namespace py = pybind11;
class StructParser {
private:
std::unordered_map<std::string, py::object> struct_types_;
public:
explicit StructParser(py::dict structs);
py::object parse(const std::string &struct_name, py::bytes data);
bool has_struct(const std::string &struct_name) const;
};
#endif