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

终端 数据表格

//
// Created by HongDaYu on 17 十月 2024.
//#ifndef HDYSDK_UTIL_H
#define HDYSDK_UTIL_H#include <cstdint>
#include <string>
#include <list>
#include <iomanip>
#include <memory>class dataGrid {
private:std::list<const char*> _table;int32_t col = 0;size_t width = 15;char split_char = '-';
public:explicit dataGrid(size_t w,int32_t col,char s='-'):width(w),split_char(s),col(col){}dataGrid &operator<<(const char*);const std::list<const char *> &getList(){return _table;}std::shared_ptr<char> table();
};#endif//HDYSDK_UTIL_H#include "util.h"
#include <list>
#include <iostream>
#include <cstring>
#include <strstream>dataGrid &dataGrid::operator<<(const char *row) {this->_table.push_back(row);return *this;
}std::shared_ptr<char> dataGrid::table() {size_t len = 0;size_t counts = 1;int32_t index = 0;for(auto it : _table){len+=strlen(it);counts++;}std::shared_ptr<char> grid(new char[len+width*counts*2]);std::ostrstream buffer(grid.get(),static_cast<int>(len+width*counts*2));for(auto it : _table){buffer << std::setw(static_cast<int>(width)) << std::left << it;if(((index+1)%col) == 0){if((index+1) == col)buffer << std::endl << std::setfill(split_char) << std::setw(static_cast<int>(width) * col) << "" << std::setfill(' ') << std::endl;elsebuffer << std::endl;}index++;}return grid;
}int main() {dataGrid buffer(15,2);buffer << "hello" << "world" << "very" << "good";std::cout << buffer.table();return 0;
}

在这里插入图片描述

一般只有开发人员在debug的时候,在调用一个库有点累赘

http://www.lryc.cn/news/462265.html

相关文章:

  • 2.4.ReactOS系统运行级别降低IRQL级别KfLowerIrql 函数
  • 数字后端实现静态时序分析STA Timing Signoff之min period violation
  • phpstorm+phpstudy 配置xdebug(无需开启浏览器扩展)
  • AI赋能安全运营 | 赛宁网安深度参与四川省网络安全沙龙
  • R语言中,.RData 和 .rds 的区别
  • python实现录屏功能
  • 酷克数据出席2024金融业数据库技术大会
  • find_library、pkg_check_modules、pkg_search_module的区别
  • 多jdk版本环境下,jenkins系统设置需指定JAVA_HOME环境变量
  • Java mybatis day1015
  • 音乐播放器项目专栏介绍​
  • 如何修改SpringBoot内置容器默认上下文
  • R语言详解predict函数
  • QT 实现随机码验证
  • 集合框架12:Set集合概述、Set接口使用
  • 如何打开荣耀手机的调试模式?
  • Meta新模型Dualformer:融合快慢思维,推理能力媲美人脑
  • CDGA|数据治理:如何让传统行业实现数据智能
  • Spring源码5.2.9 编译踩坑
  • 【前端】如何制作一个自己的网页(5)
  • Unity实战案例全解析 类宝可梦回合制的初级案例 源码分析(加了注释和流程图)
  • AI绘图大模型 Stable Diffusion 使用详解
  • es索引库操作和使用RestHignLevelClient客户端操作es
  • 安卓数据共享
  • Gin框架操作指南02:JSON渲染
  • 【随手记】MySQL单表访问方法
  • 机器学习:情感分析的原理、应用场景及优缺点介绍
  • 基于SSM的医院药品管理系统
  • 特征融合篇 | YOLOv10 引入动态上采样模块 | 超过了其他上采样器
  • 【Linux系列】写入文本到文件