笔记笔记
  • Home
  • AI&ML
  • Example
  • Zoo
  • 关于
⌘ K
C++
Oat++
最后更新时间:
Copyright © 2023-2024 | Powered by dumi | GuoDapeng | 冀ICP备20004032号-1 | 冀公网安备 冀公网安备 13024002000293号

TABLE OF CONTENTS

‌
‌
‌
‌

Oat++

创建项目

vcpkg - 跨平台 C/C++ 依赖项管理器

教程:通过 CMake 安装和使用包

Oat++ 相关项目和事例

这里省略掉一些配置 vcpkg 步骤。

# 创建项目目录
mkdir work_node && cd work_node
# 创建 vcpkg.json vcpkg-configuration.json 文件
vcpkg new --application
# 添加依赖包
vcpkg add port oatpp oatpp-swagger
# 安装依赖
vcpkg install
# 生成项目
cmake --preset=vcpkg
# 编译
cmake --build build

会在 build 目录下生成可执行文件。

http://127.0.0.1:8100/swagger/ui 这个地址可以访问到 swagger 的页面。

oatpp::Fields

代码:

const oatpp::Fields<oatpp::Any> fields({});
printf("fields size %lu\n", fields->size());
if (fields["user_id"] != nullptr) printf("user_id != nullptr");
printf("fields size %lu\n", fields->size());

输出:

fields size 0
fields size 1

非常困惑。之后就通过 for 循环遍历检查字段是否存在。

for (const auto &pair: *filterFields) {
printf("fields %s\n", pair.first->c_str());
}