7#ifndef DA_STRING_CAST_D_H
8#define DA_STRING_CAST_D_H(type, value) DAUTILS_API type fromQString(const QString& str, type defaultValue = value);
10#ifndef DA_STRING_CAST_H
11#define DA_STRING_CAST_H(type) DAUTILS_API type fromQString(const QString& str, const type& defaultValue = type());
19DAUTILS_API QString
makeUniqueString(
const QSet< QString >& stringSet,
const QString& str,
const QString& split =
"_");
27DAUTILS_API std::wstring stringToSystemWString(
const std::string& str);
28DAUTILS_API
int getSystemCodePage();
30DAUTILS_API std::string convertToUtf8(
const std::string& str,
unsigned int codePage);
34DA_STRING_CAST_D_H(
short, 0)
35DA_STRING_CAST_D_H(
unsigned short, 0)
36DA_STRING_CAST_D_H(
int, 0)
37DA_STRING_CAST_D_H(
unsigned int, 0)
38DA_STRING_CAST_D_H(
long, 0)
39DA_STRING_CAST_D_H(
unsigned long, 0)
40DA_STRING_CAST_D_H(
long long, 0)
41DA_STRING_CAST_D_H(
unsigned long long, 0)
42DA_STRING_CAST_D_H(
float, 0.0f)
43DA_STRING_CAST_D_H(
double, 0.0)
44DA_STRING_CAST_H(std::
string)
45DA_STRING_CAST_H(std::u16string)
46DA_STRING_CAST_H(std::u32string)
47DA_STRING_CAST_H(std::wstring)
72template< typename Ite >
76 for (Ite i = begin; i != end; ++i) {
80 res.append(QString(
"%1").arg(*i));
113template<
typename T,
typename FpStrCastTo >
114std::vector< T >
stringToVector(
const QString& str, FpStrCastTo fp,
const QString& split =
";")
116 std::vector< T > res;
117 const QStringList splitlist = str.split(split);
118 for (
const auto& s : splitlist) {
119 res.emplace_back(fp(s));
序列化类都是带异常的,使用中需要处理异常
Definition AppMainWindow.cpp:44
std::vector< T > stringToVector(const QString &str, FpStrCastTo fp, const QString &split=";")
将字符串按照指定的分隔符分割,并将分割后的字符串转换为指定类型的元素存储在vector中。
Definition DAStringUtil.h:114
QString makeUniqueString(const QSet< QString > &stringSet, const QString &str, const QString &split)
生成一个唯一的字符串
Definition DAStringUtil.cpp:41
QString vectorToString(Ite begin, Ite end, const QString &split=";")
将容器中的元素转换为字符串,并使用指定的分隔符连接。
Definition DAStringUtil.h:73
std::wstring qstringToSystemWString(const QString &qstr)
QString转换为系统编码的wstring
Definition DAStringUtil.cpp:85