随笔分类 - C++
摘要:需求:需要对系统日志进行监控,获取增量日志 ### 获取文件最后一行内容 ``` // 获取上一行行尾位置 int MovetoLineStart(std::fstream* fs) { fs->seekg(-1, std::ios_base::cur); for (int i = fs->tell
阅读全文
摘要:## 目录结构 ├── CMakeLists.txt ├── README.md ├── scripts │ └── build_deb.sh ├── src │ └── app.cpp └── VERSION ## 打包脚本 ```bash #! /bin/bash PROJECT_NAME="m
阅读全文
摘要:## 1.Linux下CPU使用率计算 ### 1.1 获取CPU相关数据 CPU相关的数据都存储在/proc/stat文件下 ```bash cat /proc/stat ``` 可以获取的数据如下所示 ``` cpu 6001763 384590 1904835 211700174 157342
阅读全文
摘要:先到mstorsjo/llvm-mingw下载mingw的压缩包 64位选下图框出的 下载之后解压放到任意位置,例如E:\mingw 然后配置环境变量 计算机-属性-高级系统设置-环境变量 在[系统变量]中找到Path,选择编辑,然后在写入mingw路径 以E:\mingw为例则写入E:\mingw
阅读全文
摘要:显示的完整错误如下: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `ZN2c43yml9free_implEPvmS1' which may bind externally can not be used when making a sh
阅读全文
摘要:在Linux下可以使用System V共享内存段实现共享内存,一共有4个API: 创建共享内存段或使用已经创建的共享内存段-shmget() 将进程附加到已经创建的共享内存段-shmat() 从已连接的共享内存段中分离进程-shmdt() 共享内存段上的控制操作-shmctl() 使用System
阅读全文
摘要:// ui_frameless_dialog.h #pragma once #include <QWidget> #include <QMouseEvent> class FramelessDialog : public QWidget { Q_OBJECT public: FramelessDia
阅读全文
摘要:// thread_pool.h #pragma once #include <vector> #include <deque> #include <thread> #include <functional> #include <condition_variable> class ThreadPoo
阅读全文
摘要:#include <yaml-cpp/yaml.h> #include <string> using namespace std; int main() { std::string file_path; // 读取yaml文件 YAML::Node yaml_node = YAML::LoadFil
阅读全文
摘要:CMake文件 在vscode工作目录下创建CMakeLists.txt cmake_minimum_required(VERSION 3.5) project(test) set(CMAKE_CXX_STANDARD 11) add_executable(test test.cpp) C++文件
阅读全文
摘要:编写proto文件并生成4个C++文件 首先编写proto文件,命名为test.proto,保存在工作目录下 syntax = "proto3"; package test.idl; message Student{ int32 id=1; string name=2; int32 score=3;
阅读全文
摘要:#include <Poco/DigestEngine.h> #include <Poco/DigestStream.h> #include <Poco/MD5Engine.h> #include <Poco/StreamCopier.h> #include <fstream> #include <
阅读全文
摘要:#include <Poco/Net/HTTPClientSession.h> #include <Poco/Net/HTTPRequest.h> #include <Poco/Net/HTTPResponse.h> #include <Poco/StreamCopier.h> #include <
阅读全文
摘要:使用FramelessWindowHint设置之后Widget不能移动和拉伸,需要自己实现 setWindowFlags(Qt::FramelessWindowHint); .h文件 #pragma once #include <QWidget> class FramelessWidget : pu
阅读全文