在 C++ 跨平台中解析 url 的简单方法?
在我用 C++ 编写的应用程序中,我需要解析 URL 以获取协议、主机、路径和查询.该应用程序旨在跨平台.我很惊讶我在 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.
相关文章