ActionOutput.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <ActionOutput.h>
  9. #include <QWidget>
  10. namespace AZ
  11. {
  12. ActionOutput::ActionOutput()
  13. : m_errorCount(0)
  14. , m_warningCount(0)
  15. {
  16. }
  17. void ActionOutput::AddError(const AZStd::string& error)
  18. {
  19. AddError(error, "");
  20. }
  21. void ActionOutput::AddError(const AZStd::string& error, const AZStd::string& details)
  22. {
  23. m_errorToDetails[error].push_back(details);
  24. ++m_errorCount;
  25. }
  26. bool ActionOutput::HasAnyErrors() const
  27. {
  28. return m_errorCount > 0;
  29. }
  30. AZStd::string ActionOutput::BuildErrorMessage() const
  31. {
  32. return BuildMessage(m_errorToDetails);
  33. }
  34. void ActionOutput::AddWarning(const AZStd::string& warning)
  35. {
  36. AddWarning(warning, "");
  37. }
  38. void ActionOutput::AddWarning(const AZStd::string& warning, const AZStd::string& details)
  39. {
  40. m_warningToDetails[warning].push_back(details);
  41. ++m_warningCount;
  42. }
  43. bool ActionOutput::HasAnyWarnings() const
  44. {
  45. return m_warningCount > 0;
  46. }
  47. AZStd::string ActionOutput::BuildWarningMessage() const
  48. {
  49. return BuildMessage(m_warningToDetails);
  50. }
  51. AZStd::string ActionOutput::BuildMessage(const IssueToDetails& issues) const
  52. {
  53. AZStd::string message;
  54. for (const auto& it : issues)
  55. {
  56. message += it.first;
  57. message += ":\n";
  58. const DetailList& details = it.second;
  59. for (size_t i = 0; i < details.size(); ++i)
  60. {
  61. message += " ";
  62. message += details[i];
  63. message += "\n";
  64. }
  65. message += "\n";
  66. }
  67. return message;
  68. }
  69. }