C++ equivalent of Python's “construct” library

2019-06-03 17:17发布

I'm looking for a library equivalent Python's "construct", maybe somebody has ported it.

Construct is a powerful declarative parser for binary data.

It is based on the concept of defining data structures in a declarative manner, rather than procedural code: Simple constructs can be combined hierarchically to form increasingly complex data structures. It's the first library that makes parsing fun, instead of the usual headache it is today.

This is similar question for java. Java equivalent of Python's "construct" library

Thanks.

2条回答
女痞
2楼-- · 2019-06-03 18:10

You might be interested in taking a look at Protocol Buffers. This library will let you write a description of your data in an intermediate language that can be compiled to C++, Java or python.

查看更多
干净又极端
3楼-- · 2019-06-03 18:11

Why yes, structs, native to C and C++. Unless you want the ability to produce structs with a set of fields that can only be determined at runtime; in this case, malloc (to allocate the memory the struct variable will need) and some memcpys (to write data to the struct variable) should do the trick.

查看更多
登录 后发表回答