- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
根据 The Library Evolution Incubator 的最新 session ,获得大力支持的设施之一是 std::web_view
。
提案在 P1108R2 中描述并将用于
enables modern, natural, multimodal user interaction by leveraging existing web standards and technologies.
std::web_view w("web_view test app");
w.set_uri_scheme_handler("wv", [&](const std::string &uri, std::ostream &os) {
std::cout << "request: " << uri << "\n";
os << "<html><head><title>" << uri << "</title></head><body><p>" << uri << "</p><table>";
for (auto &a : args)
os << "<tr><td>" << a << "</td></tr>" << "\n"; // we need some kind of "to_html" utility function.
os << "</table>";
os << "<p><a href=\"" << uri << "/more.html" << "\">more</a></p>";
os << "<ul id='dl'></ul>";
os << "</body></html>";
从我提出的示例中可以看出,该设计基本上会发出 JavaScript/HMTL 代码。
我没有正确理解这种方法会产生什么好处。有人可以更深入地了解该设施吗?
最佳答案
我将首先以正确的 StackExchange 方式回答这个问题。您链接的文档在简介部分中非常清楚地说明了其动机:
Reality is that most users do not interact with applications using a command prompt (i.e., console I/O), but rather, use some graphical user interface. The C++ standard, however, provides no useful facilities in this regard, and as a result, users either need to make use of system-specific APIs, third-party libraries, or move to a different programming language.
[...]
Unfortunately, this committee has neither the time nor the expertise to address this problem by directly creating some sufficiently-comprehensive API. [...] The only feasible way forward is to reach out to the large and vibrant community tackling this issue, creating portable standards in this space, and make direct use of their efforts.
因此,简而言之,C++ 社区没有足够的资源(人员和专业知识)来实现完整的 GUI 和高级服务库。毕竟,我自己只能提到一个在功能上可以与 HTML+JS 匹敌的 C++ GUI 库,这就是 Qt 库。
现在我还想在答案中添加更多自以为是的部分,因为这个问题有点自问自答。即使没有 JavaScript,HTML 和 CSS 在几行代码中显示您想要的内容方面也非常强大。他们提出了一个广为人知的展示事物的框架。在大多数其他 GUI 框架中,您还会在“HTML 面板”中遇到 HTML,通常是在尝试呈现格式化文本时。
HTML+JavaScript 可以让初学者在编程一段时间后获得视觉上有趣的结果,这一点也很重要。在没有编程知识的情况下使用 C++ 启动 GUI 应用程序并不容易 - 您需要获取并构建一个 GUI 框架。如果我们让初学者能够通过 HTML 呈现他们用 C++ 编写的程序,社区可能会发展壮大。
关于c++ - 将 std::web_view 工具引入标准有什么好处?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57126253/
我正在开发一个小型图书馆,我需要做的一件事是让访问者访问一些数据并返回结果。 在一些较旧的 C++ 代码中,访问者需要声明一个 typedef return_type .例如,boost::stati
我正在尝试使用std:map类型的键和值制作std::any Visual Studio 2017 std::map m("lastname", "Ivanov"); std::cout (m["la
我已经在 C++ 的 map 中声明了一个集合为 std::map> .如何循环访问或打印设定值? 最佳答案 如果你知道如何迭代 std::map或 std::set单独地,您应该可以毫无问题地组合迭
如何循环? 我已经试过了: //----- code std::vector >::iterator it; for ( it = users.begin(); it != users.end();
我有两个用例。 A.我想同步访问两个线程的队列。 B.我想同步两个线程对队列的访问并使用条件变量,因为其中一个线程将等待另一个线程将内容存储到队列中。 对于用例 A,我看到了使用 std::lock_
我正在查看这两种类型特征的文档,但不确定有什么区别。我不是语言律师,但据我所知,它们都适用于“memcpy-able”类型。 它们可以互换使用吗? 最佳答案 不,这些术语不能互换使用。这两个术语都表示
我有以下测试代码,其中有一个参数 fS,它是 ofstream 的容器: #include #include #include #include int
这是这个问题的延续 c++ function ptr in unorderer_map, compile time error 我试图使用 std::function 而不是函数指针,并且只有当函数是
std::unordered_map str_bool_map = { {"a", true}, {"b", false}, {"c", true} }; 我们可以在此映射上使
我有以下对象 std::vector> vectorList; 然后我添加到这个使用 std::vector vec_tmp; vec_tmp.push_back(strDRG); vec_tmp.p
为什么 std::initializer_list不支持std::get<> , std::tuple_size和 std::tuple_element ?在constexpr中用得很多现在的表达式,
我有一个像这样定义的变量 auto drum = std::make_tuple ( std::make_tuple ( 0.3f , Ex
假设我有一个私有(private)std::map在我的类(class)里std::map 。我怎样才能将其转换为std::map返回给用户?我想要下面的原型(prototype) const std
假设我有一个私有(private)std::map在我的类(class)里std::map 。我怎样才能将其转换为std::map返回给用户?我想要下面的原型(prototype) const std
问题 我正在尝试将 lambda 闭包传递给 std::thread,它使用任意封闭参数调用任意封闭函数。 template std::thread timed_thread(Function&& f
我想创建一个模板类,可以容纳容器和容器的任意组合。例如,std::vector或 std::map ,例如。 我尝试了很多组合,但我必须承认模板的复杂性让我不知所措。我编译的关闭是这样的: templ
我有一个 std::vector>我将其分配给相同类型的第二个 vector 。 我收到这个编译器错误: /opt/gcc-8.2.0/include/c++/8.2.0/bits/stl_algob
有时候,我们有一个工厂可以生成一个 std::unique_ptr vector ,后来我们想在类/线程/你命名的之间共享这些指针。因此,最好改用 std::shared_ptr 。当然有一种方法可以
这个问题在这里已经有了答案: Sorting a vector of custom objects (14 个答案) 关闭 6 年前。 我创建了一个 vector vector ,我想根据我定义的参
我有三个类(class)成员: public: std::vector > getObjects(); std::vector > getObjects() const; privat
我是一名优秀的程序员,十分优秀!