Python“构造”库的C++等价

2024-05-29 08:00:17 发布

您现在位置:Python中文网/ 问答频道 /正文

可能有人在找一个类似的Python库。在

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.

这与java的问题类似。 Java equivalent of Python's "construct" library

谢谢。在


Tags: oftheparserfordataisonlibrary
3条回答

作为参考,OP正在讨论这个名为Construct的库。 该库允许您构建能够解析和重建原始二进制数据流的解析器/构造函数。”Construct是一个强大的声明性和对称的二进制数据解析器和构建器。它确实是独一无二的,是我真正想要的C++特性。在

我能找到的最近的库叫做binpac。但是,它只创建解析器,是生成C++代码的外部工具。在

为什么是,^ {CD1>},原生于C和C++。除非您希望能够生成带有一组只能在运行时确定的字段的结构;在这种情况下,malloc(分配结构变量所需的内存)和一些memcpys(将数据写入struct变量)就可以了。在

您可能有兴趣看看Protocol Buffers。这个库将允许您编写一个中间语言,可以编译为C++、java或Python。在

相关问题 更多 >

    热门问题