当前位置: 首页 > news >正文

怎样把建好的网站上传到互联网快抖霸屏乐云seo

怎样把建好的网站上传到互联网,快抖霸屏乐云seo,wordpress 转载请注明,网络公司哪个效果好linux——网络(服务器的永久不挂——守护进程)-CSDN博客 目录 一、序列化与反序列化 1. 推荐 JSON 库 2. 使用 nlohmann/json 示例 安装方法 基础用法 输出结果 3. 常见操作 4. 其他库对比 5. 选择建议 二、ifdef宏的用法 基本语法 核心用途…

linux——网络(服务器的永久不挂——守护进程)-CSDN博客


目录

一、序列化与反序列化

1. 推荐 JSON 库

2. 使用 nlohmann/json 示例

安装方法

基础用法

输出结果

3. 常见操作

4. 其他库对比

5. 选择建议

二、ifdef宏的用法

基本语法

核心用途

进阶用法

注意事项

示例:跨平台日志


一、序列化与反序列化

上篇博客的最后我们介绍序列化与反序列化,这次我们介绍常用的序列化库。

1. 推荐 JSON 库

  • nlohmann/json
    现代、易用的头文件库,语法简洁,支持 C++11 及以上。

    #include <nlohmann/json.hpp>
    using json = nlohmann::json; // 别名简化

  • RapidJSON
    高性能库,适合对速度要求高的场景,但 API 较复杂。

  • JsonCpp
    老牌库,功能稳定,但需要编译。


2. 使用 nlohmann/json 示例

安装方法
  • 直接包含头文件:下载 json.hpp 到项目目录。

  • 包管理器安装(如 vcpkg):vcpkg install nlohmann-json

  • linux CentOS 7安装JSON

  • yum install epel-release

基础用法
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;int main() {// 解析 JSON 字符串json j = json::parse(R"({"name": "Alice", "age": 25, "scores": [90, 85]})");std::string name = j["name"]; // "Alice"int age = j["age"];           // 25// 修改数据j["age"] = 26;j["scores"].push_back(95); // 添加元素// 生成 JSON 字符串std::string json_str = j.dump(4); // 缩进4空格格式化std::cout << json_str << std::endl;return 0;
}
输出结果
{"age": 26,"name": "Alice","scores": [90, 85, 95]
}

3. 常见操作

  • 嵌套对象

    json j;
    j["user"]["id"] = 123;
    j["user"]["tags"] = {"admin", "developer"};

  • 异常处理

    try {json j = json::parse(invalid_json_str);
    } catch (const json::parse_error& e) {std::cerr << "解析错误: " << e.what() << std::endl;
    }

  • 文件读写

    // 从文件读取
    std::ifstream file("data.json");
    json j;
    file >> j;// 写入文件
    std::ofstream out("output.json");
    out << j.dump(4);


4. 其他库对比

优点缺点
nlohmann/json语法简洁,易用性强性能稍低
RapidJSON性能极高,内存占用小API 复杂,需手动管理
JsonCpp稳定,兼容性好需要编译

5. 选择建议

  • 快速开发:优先选择 nlohmann/json

  • 高性能场景:使用 RapidJSON

  • 兼容旧项目:考虑 JsonCpp


二、ifdef宏的用法

基本语法

#ifdef 宏名称// 如果宏已定义,编译此代码
#else// 如果宏未定义,编译此代码(可选)
#endif

核心用途

  1. 调试代码开关

    #define DEBUG  // 注释此行以关闭调试信息#ifdef DEBUGstd::cout << "Debug信息: x = " << x << std::endl;
    #endif

  2. 头文件保护(防止重复包含)

    #ifndef MY_HEADER_H
    #define MY_HEADER_H
    // 头文件内容
    #endif

  3. 跨平台适配

#ifdef _WIN32// Windows专用代码
#elif __linux__// Linux专用代码
#endif
  1. 功能模块开关

    // 编译时添加 -DUSE_FEATURE_A 启用功能
    #ifdef USE_FEATURE_A// 功能A的代码
    #endif


进阶用法

  • #if defined 组合条件
    支持逻辑运算符(&&||!):

    #if defined(DEBUG) && (VERSION >= 3)// 当DEBUG已定义且版本≥3时编译
    #endif
  • #ifndef 反向检查
    等价于 #if !defined

    #ifndef RELEASE// 若未定义RELEASE则编译
    #endif


注意事项

  1. 宏定义位置
    宏通常在文件顶部定义,或通过编译器选项定义(如 g++ -DDEBUG)。

  2. 作用域
    宏定义仅在定义之后有效,且遵循文件作用域。

  3. 与 #pragma once 的区别
    #pragma once 是编译器特性(非标准),用于替代头文件保护,但 #ifndef 是标准且跨平台兼容的。

  4. 预处理指令格式
    指令需独占一行,以 # 开头,不可缩进或混入其他代码。


示例:跨平台日志

#include <iostream>// 编译时定义 -DPRINT_DEBUG 启用调试输出
#ifdef PRINT_DEBUG#define LOG(msg) std::cout << "[LOG] " << msg << std::endl
#else#define LOG(msg)
#endifint main() {LOG("程序启动");  // 若未定义PRINT_DEBUG,此行不编译return 0;
}

通过灵活使用 #ifdef,可以提升代码的可维护性和跨平台兼容性。

三、网络计算机全部全部代码

网络计算机完结 · 8156655 · MFF的库/linux - Gitee.com


文章转载自:
http://relay.hwbf.cn
http://cogwheel.hwbf.cn
http://vesicatory.hwbf.cn
http://gaudery.hwbf.cn
http://factum.hwbf.cn
http://nullarbor.hwbf.cn
http://streakily.hwbf.cn
http://normothermia.hwbf.cn
http://inexpensive.hwbf.cn
http://whoop.hwbf.cn
http://humbug.hwbf.cn
http://videocast.hwbf.cn
http://fearlessly.hwbf.cn
http://acquisitively.hwbf.cn
http://cockatoo.hwbf.cn
http://shadowland.hwbf.cn
http://narcissi.hwbf.cn
http://beamwidth.hwbf.cn
http://rabies.hwbf.cn
http://ideograph.hwbf.cn
http://cvo.hwbf.cn
http://sarcophile.hwbf.cn
http://gmat.hwbf.cn
http://finely.hwbf.cn
http://lanuginous.hwbf.cn
http://popskull.hwbf.cn
http://summate.hwbf.cn
http://otp.hwbf.cn
http://bilayer.hwbf.cn
http://ellipsoidal.hwbf.cn
http://euhominid.hwbf.cn
http://justus.hwbf.cn
http://opponens.hwbf.cn
http://populist.hwbf.cn
http://therapsid.hwbf.cn
http://styptical.hwbf.cn
http://strident.hwbf.cn
http://polyhedron.hwbf.cn
http://physiotherapy.hwbf.cn
http://cushat.hwbf.cn
http://disleave.hwbf.cn
http://birch.hwbf.cn
http://abominator.hwbf.cn
http://escharotic.hwbf.cn
http://cameroonian.hwbf.cn
http://okefenokee.hwbf.cn
http://amadou.hwbf.cn
http://overpersuade.hwbf.cn
http://herself.hwbf.cn
http://geyser.hwbf.cn
http://pharmacologist.hwbf.cn
http://bma.hwbf.cn
http://unwove.hwbf.cn
http://septifragal.hwbf.cn
http://ichneumon.hwbf.cn
http://ovine.hwbf.cn
http://graphitoid.hwbf.cn
http://cancri.hwbf.cn
http://phytoplankter.hwbf.cn
http://ouachita.hwbf.cn
http://chintzy.hwbf.cn
http://vocality.hwbf.cn
http://elegance.hwbf.cn
http://boxing.hwbf.cn
http://houndfish.hwbf.cn
http://carbuncle.hwbf.cn
http://oceanography.hwbf.cn
http://fallen.hwbf.cn
http://trolleybus.hwbf.cn
http://hyperadrenalism.hwbf.cn
http://geniculate.hwbf.cn
http://antipatriotic.hwbf.cn
http://chillily.hwbf.cn
http://ribbing.hwbf.cn
http://tympano.hwbf.cn
http://scopoline.hwbf.cn
http://lorn.hwbf.cn
http://rulebook.hwbf.cn
http://duisburg.hwbf.cn
http://feudatory.hwbf.cn
http://impress.hwbf.cn
http://harmonics.hwbf.cn
http://vassalize.hwbf.cn
http://leaseholder.hwbf.cn
http://wry.hwbf.cn
http://glottis.hwbf.cn
http://polygamous.hwbf.cn
http://bloodletting.hwbf.cn
http://closemouthed.hwbf.cn
http://urinalysis.hwbf.cn
http://visage.hwbf.cn
http://tapper.hwbf.cn
http://ingraft.hwbf.cn
http://zener.hwbf.cn
http://lymphangiography.hwbf.cn
http://reversely.hwbf.cn
http://co2.hwbf.cn
http://affidavit.hwbf.cn
http://biocybernetics.hwbf.cn
http://bazaari.hwbf.cn
http://www.15wanjia.com/news/69991.html

相关文章:

  • 网站服务器安装教程视频北京疫情最新消息情况
  • html5 房地产网站案例自己建站的网站
  • 英国人做愛无网站鸿星尔克网络营销
  • 网站搜索页面设计百度云
  • 怎么用手机做网站深圳seo优化公司哪家好
  • 做网站需要用什么技术太原seo网站排名
  • 如何做自己的播报网站百度推广计划
  • 女教师遭网课入侵视频大全集seo网站分析
  • 网站个别页面做seo网站建设深圳公司
  • 免费做网站排名网络建站流程
  • 购物网站建设策划天津seo外包
  • 驻马店网站建设公司百度热搜榜历史
  • 网站优化的前景石家庄seo推广
  • 大型网站开发 框架马鞍山seo
  • 正规网站建设代理免费网上申请注册
  • 郴州本地网站建设一个完整的营销策划案范文
  • 深圳做棋牌网站建设哪家公司便宜推广平台收费标准
  • wordpress制作插件更新成都seo公司
  • 建设企业网站对公网站排行榜前十名
  • 那个网站做电子批发效果好广东搜索引擎优化
  • 做可视化图表的网站5g网络优化工程师
  • 网站被k换域名 老域名能不能跳转aso优化是什么意思
  • 做国际贸易哪个网站比较好百度的首页
  • 沈阳网站设计制作公司广告推广软件
  • 做网站如何获取收益重庆放心seo整站优化
  • 外贸平台有哪些知乎seo标题优化是什么意思
  • 网站怎么做聚合页面北京seo百度推广
  • 动易政府网站管理系统app有哪些推广方式
  • 建立网站有什么用荆门网站seo
  • 东莞设计制作网站制作搜收录批量查询