简单的方法来解析在C ++跨平台的url? [英] Easy way to parse a url in C++ cross platform?

查看:207
本文介绍了简单的方法来解析在C ++跨平台的url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要解析一个网址,以便在我用C ++编写的应用程序中获取协议,主机,路径和查询。该应用程序旨在跨平台。我很惊讶,我在 boost POCO 库。是不是明显我不在看?有关适当的开源库的任何建议?还是这个东西我只需要做我的自我?这不是超级复杂,但它似乎像这样一个常见的任务我很惊讶,没有一个共同的解决方案。

I need to parse a URL to get the protocol, host, path, and query in an application I am writing in C++. The application is intended to be cross-platform. I'm surprised I can't find anything that does this in the boost or POCO libraries. Is it somewhere obvious I'm not looking? Any suggestions on appropriate open source libs? Or is this something I just have to do my self? It's not super complicated but it seems like such a common task I am surprised there isn't a common solution.

推荐答案

有一个库被推荐用于Boost包含,并允许您轻松解析HTTP URI。它使用Boost.Spirit,也是在Boost软件许可证下发布的。该库是cpp-netlib,您可以在 http://cpp-netlib.github.com/ 找到相关文档 - - 您可以从 http://github.com/cpp-netlib/cpp-netlib/downloads下载最新版本

There is a library that's proposed for Boost inclusion and allows you to parse HTTP URI's easily. It uses Boost.Spirit and is also released under the Boost Software License. The library is cpp-netlib which you can find the documentation for at http://cpp-netlib.github.com/ -- you can download the latest release from http://github.com/cpp-netlib/cpp-netlib/downloads .

您要使用的相关类型是 boost :: network :: http :: uri ,并在此处提供。

The relevant type you'll want to use is boost::network::http::uri and is documented here.

这篇关于简单的方法来解析在C ++跨平台的url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆