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-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
