1 Star 0 Fork 0

遇健/Linux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Util.hpp 858 Bytes
一键复制 编辑 原始数据 按行查看 历史
遇健 提交于 2023-07-28 23:28 +08:00 . json实现序列化和反序列化
#pragma once
#include<iostream>
#include<string>
#include<vector>
using namespace std;
class Util
{
public:
// 输入: const &
// 输出: *
// 输入输出: *
static bool StringSplit(const string &str, const string &sep, vector<string> *result)
{
// 10 + 20
size_t start = 0;
while (start < str.size())
{
auto pos = str.find(sep, start);
if (pos == string::npos)
break;
result->push_back(str.substr(start, pos - start));
// 更新位置
start = pos + sep.size();
}
// 处理最后的字符串
if(start<str.size())
result->push_back(str.substr(start));
return true;
}
static int toInt(const string&s) // 字符串转整数
{
return atoi(s.c_str());
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/yu-jian-Rena/linux.git
git@gitee.com:yu-jian-Rena/linux.git
yu-jian-Rena
linux
Linux
master

搜索帮助