36BASE_EXPORT QString
toQString(
const float & v,
int width=0,
char format=
'g',
int precision=-1,
char fill=
' ');
37BASE_EXPORT QString
toQString(
const double &v,
int width=0,
char format=
'g',
int precision=-1,
char fill=
' ');
39BASE_EXPORT QString
toQString(
const QVariant &v,
int width=0,
char fill=
' ',
char format=
'g',
int precision=-1);
49QString toQStringT(
const T &t,
int width=0,
char fill=
' ',[[maybe_unused]]
char format=
'g',
50 [[maybe_unused]]
int precision=-1) {
54inline QString toQStringT(
const float &t,
int width,
char fill,
char format,
int precision) {
55 return toQString(t,width,format,precision,fill);
58inline QString toQStringT(
const double &t,
int width,
char fill,
char format,
int precision) {
59 return toQString(t,width,format,precision,fill);
62inline QString toQStringT(
const QVariant &t,
int width,
char fill,
char format,
int precision) {
63 return toQString(t,width,fill,format,precision);
66inline QString toQStringT(
const bool &b,
int width,
char fill,[[maybe_unused]]
char format,
67 [[maybe_unused]]
int precision) {
74template <
class T>
inline QString
toQString(
const Vector2<T> &v,
int width=0,
char fmt=
'g',
int prec=-1,
char fill=
' ') {
76 int w = (std::abs(width) - 3) / 2;
78 s = s.arg(toQStringT(v.
x(),w,fill,fmt,prec));
79 s = s.arg(toQStringT(v.
y(),w,fill,fmt,prec));
85template <
class T>
inline QString
toQString(
const Vector3<T> &v,
int width=0,
char fmt=
'g',
int prec=-1,
char fill=
' ') {
86 QString s(
"(%1,%2,%3)");
87 int w = (std::abs(width) - 4) / 3;
89 s = s.arg(toQStringT(v.
x(),w,fill,fmt,prec));
90 s = s.arg(toQStringT(v.
y(),w,fill,fmt,prec));
91 s = s.arg(toQStringT(v.
z(),w,fill,fmt,prec));
98template <
class T>
inline QString
toQString(
const AVector2<T> &v,
int width=0,
char fmt=
'g',
int prec=-1,
char fill=
' ') {
100 int w = (std::abs(width) - 3) / 2;
102 s = s.arg(toQStringT(v.
z(),w,fill,fmt,prec));
108template <
class T>
inline QString
toQString(
const AVector3<T> &v,
int width=0,
char fmt=
'g',
int prec=-1,
char fill=
' ') {
109 QString s(
"(%1,%2,%3)");
110 int w = (std::abs(width) - 4) / 3;
112 s = s.arg(toQStringT(v.
x(),w,fill,fmt,prec));
113 s = s.arg(toQStringT(v.
y(),w,fill,fmt,prec));
114 s = s.arg(toQStringT(v.
z(),w,fill,fmt,prec));
124inline string tostring(
const QString &s) {
return s.toStdString(); }
125inline StringList toStringList(
const QStringList &sl);
126inline QStringList toQStringList(
const StringList &sl);
127inline StringList fromQStringList(
const QStringList &sl);
128inline Buffer toBuffer(
const QByteArray &ba);
133BASE_EXPORT QString
readWord(QDataStream &ds,qint64 maxlen=0,
const QString &separators=
" \t\r\n");
135BASE_EXPORT QString enquoteString(
const QString &s,QChar quote=
'"');
153BASE_EXPORT bool isBool(
const QString &in,
bool *b=0,
const QString &out=
"on,off,true,false,yes,no");
157BASE_EXPORT bool toBool(
const QString &in,
bool *ok=0,
const QString &out=
"on,off,true,false,yes,no");
165inline QString
toQString(
const std::wstring &in) {
return QString::fromStdWString(in); }
167inline QString
toQString(
const string &in) {
return QString::fromStdString(in); }
190 bool operator()(
const QString &left,
const QString &right)
const {
191 return left.compare(right,Qt::CaseInsensitive) < 0;
196 bool operator()(
const QString &left,
const QString &right)
const {
197 return QString::localeAwareCompare(left,right) < 0;
202 bool operator()(
const QString &left,
const QString &right)
const {
203 return left.compare(right,Qt::CaseInsensitive) == 0;
208 uint operator()(
const QString &in)
const {
211 auto *p = in.constData();
212 for (
int i = 0; i<len; ++i) {
213 h = 31 * h + p[i].toUpper().unicode();
220template <
typename T>
using QStringMap = std::map<QString, T, QStringCILess2>;
222template <
typename T>
using QStringHashMap = std::unordered_map<QString, T, QStringCIHash2, QStringCIEqual2>;
224using QStringSet = std::set<QString,QStringCILess2>;
226using QStringHashSet = std::unordered_set<QString, QStringCIHash2, QStringCIEqual2>;
228inline StringList toStringList(
const QStringList &qsl) {
231 sl.push_back(s.toStdString());
235inline QStringList toQStringList(
const StringList &sl) {
238 qsl.push_back(QString::fromStdString(s));
242inline StringList fromQStringList(
const QStringList &qsl) {
245 sl.push_back(qs.toStdString());
249inline Buffer toBuffer(
const QByteArray &ba) {
250 Buffer buf; buf.reserve(ba.size());
251 buf.insert(buf.end(),ba.begin(), ba.end());
257struct fmt::formatter<QString> :
public fmt::formatter<string> {
258 template <
typename ParseContext>
259 constexpr auto parse(ParseContext &ctx) {
return fmt::formatter<string>::parse(ctx); }
261 template <
typename FormatContext>
262 auto format(QString
const &val, FormatContext &ctx) {
263 return fmt::formatter<string>::format(val.toStdString(), ctx);
QString helper functions, plus some additions.
Combines base interface with Qt – allows Qt to interact with other Base types transparently.
2D Angular vector class.
Definition avect.h:43
const T & z() const
Member access - returns the z component of the 2D angular vector.
Definition avect.h:70
3D Angular vector class.
Definition avect.h:176
Definition basestring.h:159
Definition basestring.h:89
A symmetric 2nd order tensor.
Definition symtensor.h:22
2D vector utility class.
Definition vect.h:34
constexpr const T & x() const
X component access.
Definition vect.h:58
constexpr const T & y() const
Y component access.
Definition vect.h:60
3D vector utility class.
Definition vect.h:163
constexpr const T & y() const
The y-component of the vector.
Definition vect.h:186
constexpr const T & x() const
The x-component of the vector.
Definition vect.h:184
constexpr const T & z() const
The z-component of the vector.
Definition vect.h:188
BASE_EXPORT QString toQString(const QString &s, int width=0, char fill=' ')
Converts from a base type to a QString, using the width and fill character specified.
Definition baseqstring.cpp:5
BASE_EXPORT QString readWord(QDataStream &ds, qint64 maxlen=0, const QString &separators=" \t\r\n")
Reads a single whitespace delimited word from the QDataStream (since QTextStream is bugged),...
Definition baseqstring.cpp:338
BASE_EXPORT bool isLong(const QString &in, qint64 *l=0)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition baseqstring.cpp:257
BASE_EXPORT bool isUInt(const QString &in, uint *u=0)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition baseqstring.cpp:250
BASE_EXPORT bool isDouble(const QString &in, double *d=0)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition baseqstring.cpp:271
BASE_EXPORT bool isInt(const QString &in, int *i=0)
Definition baseqstring.cpp:243
BASE_EXPORT bool isBool(const QString &in, bool *b=0, const QString &out="on,off,true,false,yes,no")
Definition baseqstring.cpp:229
BASE_EXPORT bool toBool(const QString &in, bool *ok=0, const QString &out="on,off,true,false,yes,no")
Definition baseqstring.cpp:278
#define BASE_EXPORT
Definition basedef.h:24
BASE_EXPORT QString readLine(QDataStream &ds, qint64 maxlen=0)
Reads a single QString line from a QDataStream (since QTextStream is bugged), uses '\n' as an end-of-...
Definition baseqstring.cpp:326
BASE_EXPORT bool isULong(const QString &in, quint64 *ul=0)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition baseqstring.cpp:264
BASE_EXPORT QString toBytes(const quint64 &ul)
Converts number ul into a memory size string.
Definition baseqstring.h:200
Definition baseqstring.h:206
Definition baseqstring.h:188
Definition baseqstring.h:194