Files
checker_host/base/base.cpp

34 lines
547 B
C++
Raw Normal View History

2023-11-21 20:28:23 +08:00
#include "base/base.h"
#include "QList"
// 字符串转化为数字列表
2023-11-27 14:31:00 +08:00
template <typename T>
QList<T> str_to_nums(mystring str, char c)
{
QStringList snums = str.split(c);
QList<T> nums;
for (int i = 0; i < snums.size(); i++)
nums.append(T(snums[i].toInt(nullptr, 10)));
return nums;
2023-11-21 20:28:23 +08:00
}
// 字符串转化为数组
2023-11-27 14:31:00 +08:00
myarray str_to_data(mystring str, char c)
{
QStringList snums = str.split(c);
myarray d;
for (int i = 0; i < snums.size(); i++)
{
d.append(uint8_t(snums[i].toInt(nullptr, 10)));
}
return d;
2023-11-21 20:28:23 +08:00
}