cstlcompilerfor.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. Copyright 2017 Herik Lima de Castro and Marcelo Medeiros Eler
  3. Distributed under MIT license, or public domain if desired and
  4. recognized in your jurisdiction.
  5. See file LICENSE for detail.
  6. */
  7. #include "cstlcompilerfor.h"
  8. #include "constants.h"
  9. CWF_BEGIN_NAMESPACE
  10. CSTLCompilerFor::CSTLCompilerFor(const QXmlStreamAttributes &attr)
  11. {
  12. for (int i = 0; i < attr.size(); ++i) {
  13. QString name(attr[i].name().toString().toLower());
  14. QString value(attr[i].value().toString());
  15. if (name != CSTL::TAG::PROPERTY::FOR::ITEMS && name != CSTL::TAG::PROPERTY::VAR
  16. && name != CSTL::TAG::PROPERTY::FOR::FROM && name != CSTL::TAG::PROPERTY::FOR::TO
  17. && name != CSTL::TAG::PROPERTY::FOR::INCREMENT) {
  18. attributes.insert(CSTL::TAG::PROPERTY::ERROR,
  19. "***ERROR FOR TAG - FOR TAG DOESN'T PERMITS AN ATTRIBUTE CALLED "
  20. + name + "***");
  21. return;
  22. }
  23. attributes.insert(name, value);
  24. }
  25. if (!attributes.contains(CSTL::TAG::PROPERTY::FOR::ITEMS)
  26. || !attributes.contains(CSTL::TAG::PROPERTY::VAR)) {
  27. bool from, to, increment;
  28. attributes[CSTL::TAG::PROPERTY::FOR::FROM].toInt(&from);
  29. attributes[CSTL::TAG::PROPERTY::FOR::TO].toInt(&to);
  30. attributes[CSTL::TAG::PROPERTY::FOR::INCREMENT].toInt(&increment);
  31. if (!(from && to && increment) || !attributes.contains(CSTL::TAG::PROPERTY::VAR)) {
  32. attributes.insert(CSTL::TAG::PROPERTY::ERROR,
  33. "***ERROR FOR TAG - USE THE CORRECT ATTRIBUTES (FROM, TO, INCREMENT, "
  34. "VAR OR ITEMS, VAR)***");
  35. }
  36. }
  37. }
  38. CWF_END_NAMESPACE