简体   繁体   English

跨平台C ++解析器库

[英]Cross-Platform C++ Parser Library

What would a good cross-platform C++ parser for use on a space and tab delimited txt file? 一个用于空格和制表符分隔的txt文件的跨平台C ++解析器会是什么? I am looking to parse the file and then output a new txt file based off the parsed info. 我想解析该文件,然后根据已解析的信息输出一个新的txt文件。

The input file contains details for a network traffic script with several columns such as Host IP Address, Host Interface, Subnet, etc. 输入文件包含网络流量脚本的详细信息,其中包含几列,例如“主机IP地址”,“主机接口”,“子网”等。

I need to take the information from the input file and create the traffic script in the format that another application requires. 我需要从输入文件中获取信息,并以其他应用程序所需的格式创建流量脚本。

Here is an example of the format for the input file: 这是输入文件格式的示例:

Hostname    HostIP Area    Host Interface   Number of Routes
test1    128.1.1.1 0.0.0.0       128.100.1.1       100   
test1    128.1.1.2 0.0.0.0
test1    128.1.1.3 0.0.0.0
test2    128.2.2.4 0.0.0.0       128.200.5.6       100
test2    128.2.2.5 0.0.0.0
test2    128.2.2.6 0.0.0.0

I am asking for a library that would be ideal to parse this type of data and create a new text file. 我想要一个理想的库,用于解析此类数据并创建一个新的文本文件。

For a simple input file like the example you've give, you could write your own just for this file type. 对于简单的输入文件(例如您提供的示例),您可以只为此文件类型编写自己的文件。 You can use the standard C++ classes and build your own file interpreter. 您可以使用标准的C ++类并构建自己的文件解释器。 Here's a great guide: 这是一个很好的指南:

http://www.cplusplus.com/doc/tutorial/files http://www.cplusplus.com/doc/tutorial/files

Boost may be a solution. 增强可能是一种解决方案。 If you simply wish to split data based on spaces and tabs, check out boost::split . 如果您只是希望基于空格和制表符拆分数据,请查看boost :: split

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM