码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • boost 压缩与解压缩流


    boost 压缩与解压缩流(zip、zip2、gzip、lzma、zstd压缩方式)

    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    #include 
    #include 
    
    #include 
    #include 
    int main()
    {
    	try
    	{
    		// boost::iostreams::zlib_compressor() zip压缩方式
    		// boost::iostreams::zip2_compressor() zip2压缩方式
    		// boost::iostreams::gzip_compressor()  gzip压缩方式
    		// boost::iostreams::lzma_compressor()  lzma压缩方式
    		// boost::iostreams::zstd_compressor()  zstd压缩方式
    	
    		// 压缩数据流
    		{
    			boost::iostreams::filtering_ostream out;
    			out.push(boost::iostreams::zlib_compressor());
    			//out.push(ss_comp);	//压缩到字符流中
    			out.push(boost::iostreams::file_sink("test.txt"));		//压缩到文件中
    			out.write("hello", sizeof("hello") - 1);
    			out.write("hellohello", sizeof("hellohello") - 1);
    			out.write("hellohello", sizeof("hellohello") - 1);
    			out.write("hellohello", sizeof("hellohello" - 1));
    			out.write("this is a test", sizeof("this is a test") - 1);
    			out.write("hellohello", sizeof("hellohello") - 1);
    
    			std::cout << "compressor data end" << std::endl;
    		}
    
    		// 解压缩数据流
    		{
    			boost::iostreams::filtering_istream in;
    			in.push(boost::iostreams::zlib_decompressor());
    			//in.push(ss_comp);		//从字符流中解压
    			in.push(boost::iostreams::file_source("test.txt"));		//从文件中解压
    			char databuf[1024]{ 0 };
    			in.read(databuf, sizeof(databuf));
    
    			std::cout << "decompressor data:" << databuf << ", len=" << in.gcount() << std::endl;
    		}
    	}
    	catch (std::exception& e)
    	{
    		std::cout << "exception:" << e.what() << std::endl;
    	}
    	catch (...)
    	{
    		std::cout << "unknown exception." << std::endl;
    	}
    	system("pause");
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
  • 相关阅读:
    springboot毕设项目打印助手平台21swx(java+VUE+Mybatis+Maven+Mysql)
    Springboot考研教室在线预约系统0q143计算机毕业设计-课程设计-期末作业-毕设程序代做
    听说这是大学四年最好的安排
    代码随想录打卡第四十四天|● 01 二维背包问题 ●一维背包问题-滚动数组 ● 416. 分割等和子集
    Linux基础命令行操作
    resultmap
    ikun必学!python 画一个简单的只因
    【golang】mysql默认排序无法实现 使用golang实现对时间字符串字段的排序
    合规运营必备资质——ICP申请指南
    SPSS教程:手把手教你绘制簇状条形图
  • 原文地址:https://blog.csdn.net/qiufeng_xinqing/article/details/136690143
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号