创建二进制文件编辑器
我有一个相当简单的二进制文件格式,我希望创建一个编辑器:
- 能够加载文件
- 能够保存文件
- 允许用户更改各个字段的值等
- 能够使用旧版本的文件转换文件 显然,
我可以用 C#、Python 等编写该内容...但是我想知道是否有更简单的选项来创建这样的基本编辑器,它只允许我描述文件和任何条件/验证,而不必自己编写所有 IO 和编辑代码?
I've got a fairly simple binary file format I wish to create an editor for:
- Able to load the files
- Able to save the files
- Allow the user to change the value of the various fields etc
- Able to convert a file using an older version of the format to a new version
Obviously I could just write the thing in C#, Python, etc. etc...However I was wondering if there are easier options for creating a basic editor like this which would just allow me to describe the contents of the file and any conditions/validation, without having to write all the IO and editing code myself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理此问题的最简单方法是编写软件将二进制文件与文本文件相互转换。然后您可以使用任何文本编辑器编辑数据。编辑后,运行该工具将其转换回二进制文件。
这也使得不同版本之间的转换变得容易。
这种方法的一些问题是浮点数精度的损失,如果二进制文件非常大,则转换所需的时间以及有时人们会忘记运行转换工具来更新实际的二进制副本。
The easiest way to handle this is to write software to convert the binary to and from a text file. Then you can edit the data using any text editor. After editing you run the tool to convert it back to binary.
This also makes it easy to convert to and from different versions.
Some of the problems with this approach are the loss of accuracy in floating point numbers, the time it takes to do the conversion if the binary is very large and the fact the sometimes people will forget to run the conversion tool to update the actual binary copy.