cstlcompilerimport.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 "cstlcompilerimport.h"
  8. #include "constants.h"
  9. #include "filemanager.h"
  10. CWF_BEGIN_NAMESPACE
  11. CSTLCompilerImport::CSTLCompilerImport(const QXmlStreamAttributes &attr, QString path)
  12. {
  13. int size = attr.size();
  14. if (size == 0) {
  15. attributes.insert(CSTL::TAG::PROPERTY::ERROR,
  16. "***ERROR IMPORT TAG - IMPORT TAG NEEDS THE URL ATTRIBUTE***");
  17. } else if (size == 1) {
  18. QString name(attr[0].name().toString().toLower());
  19. QString value(attr[0].value().toString());
  20. if (name != CSTL::TAG::PROPERTY::IMPORT::URL) {
  21. attributes.insert(CSTL::TAG::PROPERTY::ERROR,
  22. "***ERROR IMPORT TAG - IMPORT TAG NEEDS THE URL ATTRIBUTE***");
  23. } else {
  24. CWF::FileManager::removeLastBar(path);
  25. path += value;
  26. QFile::FileError fileError;
  27. attributes.insert(CSTL::TAG::PROPERTY::IMPORT::URL,
  28. CWF::FileManager::readAll(path, fileError));
  29. }
  30. } else {
  31. attributes.insert(CSTL::TAG::PROPERTY::ERROR,
  32. "***ERROR IMPORT TAG - IMPORT TAG ONLY NEEDS THE URL ATTRIBUTE***");
  33. }
  34. }
  35. CWF_END_NAMESPACE