C++ STL
burke_____
这个作者很懒,什么都没留下…
展开
-
RTCM—CRC校验
1、RTCM—CRC校验RTK信息:例子:D3 00 13 3E D0 00 03 00 00 00 00 00 80 00 00 00 00 00 00 00 00 00 6D B8 8ED3:引导字00 13:计算消息长度:196D B8 8E:CRC校验int table[]={0x000000, 0x864CFB, 0x8AD50D, 0x0C99F6, 0x93E6E1, 0x15AA1A, 0x1933EC, 0x9F7F17,0xA1813...转载 2020-06-05 21:56:36 · 1330 阅读 · 0 评论 -
websocket 测试
#include <boost/algorithm/string.hpp>#include <string>#include <vector>#include <list>#include <iostream>#include <websocketpp/config/asio_no_tls.hpp>#include <websocketpp/server.hpp>//名称与值数据对struct Nam.原创 2020-05-28 13:45:17 · 467 阅读 · 0 评论 -
libyuv对YUV数据处理
#include <libyuv.h>// nv21 --> i420void nv21ToI420(unsigned char* src_nv21_data, int width, int height, unsigned char* src_i420_data){ int src_y_size = width * height; int src_u_size...原创 2020-04-01 22:36:43 · 1020 阅读 · 0 评论 -
libconfig
#include <libconfig.h++>#include <iostream>using namespace std;void write_test(){ libconfig::Config cfg; //1.声明 Config对象 auto& root = cfg.getRoot(); root.add("name", lib...原创 2019-11-02 22:49:42 · 218 阅读 · 0 评论 -
c++ windows api 获取文件版本号
#include <string>#include <windows.h>#pragma comment(lib,"version.lib")bool QueryValue(const std::string& ValueName, const std::string& szModuleName, std::str...原创 2019-03-13 10:31:26 · 2447 阅读 · 0 评论 -
STL容器和shared_ptr的正确用法
#include <string>#include <vector>#include <memory>#include <map>template <class T>using SPVEC = std::vector<std::shared_ptr<T>>;template <cla原创 2018-12-16 23:43:00 · 5133 阅读 · 0 评论 -
SHA-256算法
#include <iostream> #include <string>#ifndef SUCCESS#define SUCCESS 0#endif // SUCCESS#ifndef FAIL#define FAIL 0#endif // FAIL#define SHA256_ROTL(a,b) (((a>>(32-b))&(0...原创 2018-12-16 23:15:15 · 690 阅读 · 0 评论 -
rapidjosn 使用
std::string output; readFileContent("dotline.coh", output); printf("%d\n", output.size()); Document doc; doc.Parse(output.c_str()); bool IsObject=doc.IsObject(); auto ...转载 2018-12-20 11:00:08 · 317 阅读 · 0 评论 -
C++11 字符串与数字互转
#pragma once#ifndef _STRING_CONVERT#define _STRING_CONVERT#include <string>template<class T>std::string toString(const T &t){ std::stringstream os; os.precision(16);...原创 2018-11-22 11:31:43 · 402 阅读 · 0 评论 -
windows平台下的高精度定时器
class CHTimerListener{public: virtual void Update() = 0;};class CHTimer{public: CHTimer(); ~CHTimer(); bool start(CHTimerListener *listener, uint32_t _delay); void stop(CHT...原创 2018-11-03 20:44:18 · 441 阅读 · 0 评论 -
STL容器的内存管理
class Unit{public: Unit(); Unit(int id); ~Unit();private: int id = -1;};Unit::Unit(){}Unit::Unit(int _id) :id(_id){ printf("Unit construction. id=%d\n", id);}Unit::~Unit(){ prin...原创 2018-10-07 17:12:20 · 357 阅读 · 0 评论 -
opencv初化化Mat的方法
cv::Mat out = cv::Mat(cv::Size(w, h), CV_8UC(chn), imgBuf);原创 2018-09-06 14:02:01 · 153 阅读 · 0 评论 -
base64编解码
#include <string>void base64Decode(const std::string &input, std::string &output){ //解码表 const char DecodeTable[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...原创 2018-12-18 16:41:47 · 290 阅读 · 0 评论 -
C++简单配置文件程序(基于rapidjson)
#include <string>#include <map>#include <algorithm>#ifdef _WIN32#pragma warning(disable:4996)#include <windows.h>#include <io.h>#include <shlwapi.h>#pragm...原创 2018-12-29 15:24:45 · 620 阅读 · 0 评论 -
C++用宏定义实现PROPERTY
#define PROPERTY_RW(T,var) public: \void set_##var(const T& _var){m_##var=_var;}\T get_##var(){return m_##var;}\private: T m_##var;class Test{public: Test(); ~Test(); PROPERTY_RW(int, ...原创 2019-03-08 00:09:32 · 377 阅读 · 0 评论 -
c++ windows 生成 guid
std::string getNewGuid(){ GUID guid; ::CoCreateGuid(&guid); const int len = 36; char dst[len]; memset(dst, 0, len); snprintf(dst, len, "%08x%04x%04x%02x%02x%02x%...原创 2019-03-12 18:05:18 · 1411 阅读 · 0 评论 -
跨平台的计时函数 支持win/linux
源文件#if defined(WIN32) || defined(_WIN32) // Windows system specific#include <windows.h>#else // Unix based system specific#include <sys/time.h>#endif__int64 getCount()...原创 2019-03-22 14:38:41 · 194 阅读 · 0 评论 -
C++ STL 实现全排列与组合
#include <algorithm>#include <string>#include <vector>using namespace std;template <typename T>void combine_inner(T &data, int start, int n, int m, int depth, T...原创 2019-04-25 15:53:16 · 1174 阅读 · 0 评论 -
std::bind 用法
#include <string>#include <functional>#include <iostream>using namespace std;class Worker{public: static Worker* Get() { static Worker ff; return &ff; } string P...原创 2019-06-25 20:40:27 · 340 阅读 · 1 评论 -
C++ static的用法有哪些?
static的用法有哪些?(1)修饰局部变量。局部变量的生存期为声明之后,直至当前代码块结束。若使用static声明,该变量将变为静态持续性,存放在静态存储区,存在于整个程序运行周期。同时保证每个进入该代码块,变量保持上一次退出时的值。(2)修饰全局变量。会改变全局变量的链接性,使用static修饰后,全局变量由外部链接性变为内存链接性,这样其他源文件不能使用extern变量使用该变量,该...原创 2019-08-23 16:02:28 · 119 阅读 · 0 评论 -
STL 常用
void read_file(const std::string& path, std::string& out){ std::ifstream fs(path, std::ios_base::binary); fs.seekg(0, std::ios_base::end); auto size = fs.tellg(); fs.seekg(0);...原创 2018-07-14 21:22:05 · 231 阅读 · 0 评论 -
C++使用foreach any_of all_off none_of
#include <iostream>#include <algorithm>int main(){ int intArr[] = { 1, 2, 3, 4, 5 }; std::cout << "std::for_each ......" << std::endl; std::for_each(std::begin(...原创 2018-07-05 23:14:51 · 514 阅读 · 0 评论 -
UTF8 to ASCII & ASCII to UTF8
string UTF82ASCII(const char* cont){ if (NULL == cont) { return string(""); } int num = MultiByteToWideChar(CP_UTF8, NULL, cont, -1, NULL, NULL); wchar_t* buffw = new wcha...原创 2018-04-08 18:52:45 · 1262 阅读 · 1 评论 -
C++ 数字转字符串的两种方法
char text[100]; sprintf(text, "./out%d.txt", id);c++11std::string std::to_string(id)原创 2018-03-25 20:38:49 · 2173 阅读 · 0 评论 -
STL文件读写操作
#include <iostream>#include <fstream>#include <string>using namespace std;int main(){// ifstream input("./in.txt", ios::in | ios::binary);// ofstream output("./out.txt",ios::ou...原创 2018-03-25 13:16:42 · 3601 阅读 · 0 评论 -
C 整数数转字符串
string num2str( int _n){ string temp; do{ temp=(char)(_n%10+'0')+temp; _n=_n/10; }while(_n!=0); return temp;}原创 2017-12-01 23:55:27 · 180 阅读 · 0 评论 -
STL find 注意事项
#include #include #include #include #include using namespace std;bool cmp(const int &a){return a!=-1;}int main(){ int n=0; cin>>n; vector vec(n); for(int i=0;i>vec[i]; b原创 2017-12-01 00:39:19 · 192 阅读 · 0 评论 -
std::vector erase 没有清除对象的问题
vector中直接存储对象,clear erase 的时候,会释放内存#include #include using namespace std;class Test{public: Test(int i) ; ~Test() ;private: int id;};Test::Test(int i){ id = i; printf("%d construct\n原创 2017-11-05 20:22:26 · 1428 阅读 · 0 评论 -
C++/Qt中一个简单的加密解密程序
本例采用查表法实现加密解密,采用一个长度为256的字节数组,每一个对应一个assic码,将顺序打乱,最终是一个全排列,加密的各类有256!=8.5781777534284265411908227168123e+506种,直接上代码吧。在头文件中加入: const char data[256]= {-12,57,-104,-66,-29,-5,121,124,-85,106,123,-53原创 2017-08-13 11:46:38 · 7173 阅读 · 0 评论 -
C++ vector和list的区别
1.vector数据结构vector和数组类似,拥有一段连续的内存空间,并且起始地址不变。因此能高效的进行随机存取,时间复杂度为o(1);但因为内存空间是连续的,所以在进行插入和删除操作时,会造成内存块的拷贝,时间复杂度为o(n)。另外,当数组中内存空间不够时,会重新申请一块内存空间并进行内存拷贝。2.list数据结构list是由双向链表实现的,因此内存空间是不连续的。原创 2017-06-16 15:20:30 · 269 阅读 · 0 评论 -
标准C++中的string类的用法总结
相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用。但是如果离开了MFC框架,还有没有这样使用起来非常方便的类呢?答案是肯定的。也许有人会说,即使不用MFC框架,也可以想办法使用MFC中的API,具体的操作方法在本文最后给出操作方法。其实,可能很多人很可能会忽略掉标准C++中string类的使用。标准C++中提供的str...原创 2017-04-29 16:47:26 · 330 阅读 · 0 评论 -
SAFE_RELEASE
#ifndef SAFE_RELEASE#define SAFE_RELEASE(p) \ if ((p)) { \ delete (p); \ (p) = NULL; \ }#endif原创 2018-04-11 20:08:04 · 1376 阅读 · 0 评论 -
Qt ansi编码转utf8编码
#ifdef _CUR_SYS_LINUX_#include <iconv.h>#else#include <windows.h>#include <stdio.h>#endifQByteArray ViewImage::AnsiToUtf8(QByteArray &ansi){#ifdef _CUR_SYS_LINUX_ QByteAr...原创 2018-04-12 11:46:23 · 4355 阅读 · 0 评论 -
海康威视摄像头+opencv 实时读取
#include <cstdio> #include <cstring> #include <iostream> #include "Windows.h" #include "HCNetSDK.h" #include "plaympeg4.h" #include <opencv2\opencv.hpp> #in原创 2018-04-12 15:15:30 · 2745 阅读 · 1 评论 -
google c++ 编码规范
原创 2018-07-11 12:41:32 · 187 阅读 · 0 评论 -
C++ base64 opencv Mat 转换
static std::string base64Decode(const char* Data, int DataByte){ //解码表 const char DecodeTable[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...原创 2018-06-27 16:31:40 · 5880 阅读 · 0 评论 -
单例模式
class TestClass{public: TestClass(); ~TestClass(); static TestClass *get() { static TestClass ff; return &ff; } void print();private:};void TestClass::print() { printf("TestCla...原创 2018-06-19 15:55:18 · 145 阅读 · 0 评论 -
linux 和 windows 下用ffmpeg 操作usb摄像头
windows :列设备 ffmpeg -list_devices true -f dshow -i dummy编码为H.264,保存为本地文件 ffmpeg -f dshow -i video="Integrated Camera" -vcodec libx264 mycamera.mkv播放 ffplay -f dshow -i video="Integrated Camera"linux...原创 2018-06-21 20:46:35 · 6407 阅读 · 3 评论 -
std::string startwith endwith split 方法
bool endWith(std::string &str, std::string &tail) { return str.compare(str.size() - tail.size(), tail.size(), tail) == 0;}bool startWith(std::string &str, std::string &head) { ret...原创 2018-05-07 09:57:23 · 9563 阅读 · 0 评论 -
C++ 回调
C++11支持的lambda表达式和function类,可以替代一切回调原创 2018-04-27 09:33:26 · 147 阅读 · 0 评论