diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-11 12:14:50 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-11 12:14:50 (GMT) |
commit | 61f8c6f4d6af1a2e73c918b43da8f25871b254b7 (patch) | |
tree | 39e472b03d3d6c642ad6723851717609ce017c3c /src/declarative/qml/qmlparser.cpp | |
parent | edadc4df70324d3c4a875795d0032e129206f44b (diff) | |
download | Qt-61f8c6f4d6af1a2e73c918b43da8f25871b254b7.zip Qt-61f8c6f4d6af1a2e73c918b43da8f25871b254b7.tar.gz Qt-61f8c6f4d6af1a2e73c918b43da8f25871b254b7.tar.bz2 |
Remove some XML'isms from the parser/compiler interface
Diffstat (limited to 'src/declarative/qml/qmlparser.cpp')
-rw-r--r-- | src/declarative/qml/qmlparser.cpp | 92 |
1 files changed, 90 insertions, 2 deletions
diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp index 2bd41e2..bafdb02 100644 --- a/src/declarative/qml/qmlparser.cpp +++ b/src/declarative/qml/qmlparser.cpp @@ -233,14 +233,102 @@ void QmlParser::Value::dump(int indent) const case Value::Id: type = "Id"; break; - }; + } + + QByteArray primType; + switch(this->value.type()) { + default: + case Variant::Invalid: + primType = "Invalid"; + break; + case Variant::Boolean: + primType = "Boolean"; + break; + case Variant::Number: + primType = "Number"; + break; + case Variant::String: + primType = "String"; + break; + case Variant::Script: + primType = "Script"; + break; + } QByteArray ba(indent * 4, ' '); if (object) { qWarning() << ba.constData() << "Value (" << type << "):"; object->dump(indent + 1); } else { - qWarning() << ba.constData() << "Value (" << type << "):" << primitive; + qWarning() << ba.constData() << "Value (" << type << "):" << primType.constData() << primitive(); + } +} + +QmlParser::Variant::Variant() +: t(Invalid) {} + +QmlParser::Variant::Variant(const Variant &o) +: t(o.t), d(o.d), s(o.s) +{ +} + +QmlParser::Variant::Variant(bool v) +: t(Boolean), b(v) +{ +} + +QmlParser::Variant::Variant(double v) +: t(Number), d(v) +{ +} + +QmlParser::Variant::Variant(const QString &v, Type type) +: t(type), s(v) +{ + Q_ASSERT(type == String || type == Script); +} + +QmlParser::Variant &QmlParser::Variant::operator=(const Variant &o) +{ + t = o.t; + d = o.d; + s = o.s; + return *this; +} + +QmlParser::Variant::Type QmlParser::Variant::type() const +{ + return t; +} + +bool QmlParser::Variant::asBoolean() const +{ + return b; +} + +QString QmlParser::Variant::asString() const +{ + return s; +} + +double QmlParser::Variant::asNumber() const +{ + return d; +} + +QString QmlParser::Variant::asScript() const +{ + switch(type()) { + default: + case Invalid: + return QString(); + case Boolean: + return b?QLatin1String("true"):QLatin1String("false"); + case Number: + return QString::number(d); + case String: + case Script: + return s; } } |