diff options
Diffstat (limited to 'sources/shiboken6/ApiExtractor/parser/enumvalue.cpp')
| -rw-r--r-- | sources/shiboken6/ApiExtractor/parser/enumvalue.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sources/shiboken6/ApiExtractor/parser/enumvalue.cpp b/sources/shiboken6/ApiExtractor/parser/enumvalue.cpp index 27e3b2e61..09c34cb91 100644 --- a/sources/shiboken6/ApiExtractor/parser/enumvalue.cpp +++ b/sources/shiboken6/ApiExtractor/parser/enumvalue.cpp @@ -7,12 +7,34 @@ #include <QtCore/QString> #include <QtCore/QTextStream> +using namespace Qt::StringLiterals; + QString EnumValue::toString() const { return m_type == EnumValue::Signed ? QString::number(m_value) : QString::number(m_unsignedValue); } +QString EnumValue::toHex(int fieldWidth) const +{ + QString result; + QTextStream str(&result); + // Note: Qt goofes up formatting of negative padded hex numbers, it ends up + // with "0x00-1". Write '-' before. + if (isNegative()) + str << '-'; + str << "0x" << Qt::hex; + if (fieldWidth) { + str.setFieldWidth(fieldWidth); + str.setPadChar(u'0'); + } + if (m_type == EnumValue::Signed) + str << qAbs(m_value); + else + str << m_unsignedValue; + return result; +} + void EnumValue::setValue(qint64 v) { m_value = v; |
