diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-11-22 19:17:24 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-09 19:10:12 -0300 |
commit | c79374b5a72959f541fdeb95d7e6b57396ed6b15 (patch) | |
tree | 2db3e8c84abe073d35e4ed38eec3993afe3df6a2 | |
parent | 7a6b3c64d4b424c09928bfd593ca4aa0738b1e02 (diff) |
Added the 'remove' attribute to the 'modify-field' type system tag.
Also created a static convenience function to process the 'remove'
attribute content and set the error message if needed.
-rw-r--r-- | typesystem.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/typesystem.cpp b/typesystem.cpp index ead70daa5..7beb42f79 100644 --- a/typesystem.cpp +++ b/typesystem.cpp @@ -329,6 +329,22 @@ bool Handler::convertBoolean(const QString &_value, const QString &attributeName } } +static bool convertRemovalAttribute(const QString& removalAttribute, Modification& mod, QString& errorMsg) +{ + QString remove = removalAttribute.toLower(); + if (!remove.isEmpty()) { + if (remove == QLatin1String("all")) { + mod.removal = TypeSystem::All; + } else if (remove == QLatin1String("target")) { + mod.removal = TypeSystem::TargetLangAndNativeCode; + } else { + errorMsg = QString::fromLatin1("Bad removal type '%1'").arg(remove); + return false; + } + } + return true; +} + bool Handler::startElement(const QString &, const QString &n, const QString &, const QXmlAttributes &atts) { @@ -800,6 +816,7 @@ bool Handler::startElement(const QString &, const QString &n, attributes["name"] = QString(); attributes["write"] = "true"; attributes["read"] = "true"; + attributes["remove"] = QString(); break; case StackElement::Access: attributes["modifier"] = QString(); @@ -1219,6 +1236,9 @@ bool Handler::startElement(const QString &, const QString &n, fm.name = name; fm.modifiers = 0; + if (!convertRemovalAttribute(attributes["remove"], fm, m_error)) + return false; + QString read = attributes["read"]; QString write = attributes["write"]; @@ -1305,18 +1325,8 @@ bool Handler::startElement(const QString &, const QString &n, if (convertBoolean(attributes["deprecated"], "deprecated", false)) mod.modifiers |= Modification::Deprecated; - - QString remove = attributes["remove"].toLower(); - if (!remove.isEmpty()) { - if (remove == QLatin1String("all")) - mod.removal = TypeSystem::All; - else if (remove == QLatin1String("target")) - mod.removal = TypeSystem::TargetLangAndNativeCode; - else { - m_error = QString::fromLatin1("Bad removal type '%1'").arg(remove); - return false; - } - } + if (!convertRemovalAttribute(attributes["remove"], mod, m_error)) + return false; QString rename = attributes["rename"]; if (!rename.isEmpty()) { |