Easy way to parse a url in C++ cross platform?(在 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.
这篇关于在 C++ 跨平台中解析 url 的简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 C++ 跨平台中解析 url 的简单方法?


基础教程推荐
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 这个宏可以转换成函数吗? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09