23 #include "metaenumvariable_p.h" 24 #include "safestring.h" 26 #include <QtCore/QRegularExpression> 27 #include <QtCore/QStringList> 28 #include <QtCore/QVariant> 52 if (property == QStringLiteral(
"capitalize")) {
60 if (property == QStringLiteral(
"isalnum")) {
64 if (!it->isLetterOrNumber())
70 if (property == QStringLiteral(
"isalpha")) {
82 if (property == QStringLiteral(
"isdigit")) {
92 if (property == QStringLiteral(
"islower")) {
94 return (s ==
object.
get()) ? trueString : falseString;
96 if (property == QStringLiteral(
"isspace")) {
98 return (s.
isEmpty()) ? trueString : falseString;
100 if (property == QStringLiteral(
"istitle")) {
101 const QString s =
object.get();
103 static const auto titleRe = getIsTitleRE();
104 return (titleRe.match(s).hasMatch()) ? falseString : trueString;
106 if (property == QStringLiteral(
"isupper")) {
108 return (s ==
object) ? trueString : falseString;
110 if (property == QStringLiteral(
"lower")) {
113 if (property == QStringLiteral(
"splitlines")) {
117 const auto end = strings.constEnd();
118 for (; it != end; ++it)
122 if (property == QStringLiteral(
"strip")) {
123 return object.get().trimmed();
125 if (property == QStringLiteral(
"swapcase")) {
126 const QString inputString =
object.get();
130 while (it != inputString.
constEnd()) {
133 else if (it->isLower())
141 if (property == QStringLiteral(
"title")) {
142 static const auto titleRe = getTitleRE();
144 const QString s =
object.get();
151 auto it = titleRe.globalMatch(s);
152 while (it.hasNext()) {
153 auto match = it.next();
154 pos = match.capturedStart();
155 output += match.captured().
toUpper();
156 matchedLength = match.capturedLength();
158 match = it.peekNext();
159 nextPos = match.capturedStart();
160 output += s.
mid(pos + matchedLength, nextPos - pos - 1);
162 output += s.
right(s.
length() - (pos + matchedLength));
168 if (property == QStringLiteral(
"upper")) {
176 TypeAccessor<MetaEnumVariable &>::lookUp(
const MetaEnumVariable &
object,
179 if (property == QStringLiteral(
"name"))
181 if (property == QStringLiteral(
"value"))
183 if (property == QStringLiteral(
"key"))
184 return QLatin1String(
object.enumerator.valueToKey(
object.value));
185 if (property == QStringLiteral(
"scope"))
187 if (property == QStringLiteral(
"keyCount"))
188 return object.enumerator.keyCount();
191 const auto listIndex =
property.toInt(&ok);
193 if (listIndex >=
object.enumerator.keyCount())
196 const MetaEnumVariable mev(
object.enumerator,
197 object.enumerator.value(listIndex));
const_iterator constBegin() const const
QString toUpper() const const
The Cutelee namespace holds all public Cutelee API.
QVariant fromValue(T &&value)
qsizetype size() const const
char32_t toUpper(char32_t ucs4)
const_iterator constEnd() const const
bool isEmpty() const const
QString trimmed() const const
A QString wrapper class for containing whether a string is safe or needs to be escaped.
QString right(qsizetype n) const const
QString toLower() const const
QString mid(qsizetype position, qsizetype n) const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
const QChar at(qsizetype position) const const
qsizetype length() const const
void reserve(qsizetype size)
const_iterator constBegin() const const