The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. Result::Result (const String& message) noexcept
  19. : errorMessage (message)
  20. {
  21. }
  22. Result::Result (const Result& other)
  23. : errorMessage (other.errorMessage)
  24. {
  25. }
  26. Result& Result::operator= (const Result& other)
  27. {
  28. errorMessage = other.errorMessage;
  29. return *this;
  30. }
  31. #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
  32. Result::Result (Result&& other) noexcept
  33. : errorMessage (static_cast <String&&> (other.errorMessage))
  34. {
  35. }
  36. Result& Result::operator= (Result&& other) noexcept
  37. {
  38. errorMessage = static_cast <String&&> (other.errorMessage);
  39. return *this;
  40. }
  41. #endif
  42. bool Result::operator== (const Result& other) const noexcept
  43. {
  44. return errorMessage == other.errorMessage;
  45. }
  46. bool Result::operator!= (const Result& other) const noexcept
  47. {
  48. return errorMessage != other.errorMessage;
  49. }
  50. Result Result::ok() noexcept
  51. {
  52. return Result (String::empty);
  53. }
  54. Result Result::fail (const String& errorMessage) noexcept
  55. {
  56. return Result (errorMessage.isEmpty() ? "Unknown Error" : errorMessage);
  57. }
  58. const String& Result::getErrorMessage() const noexcept
  59. {
  60. return errorMessage;
  61. }
  62. bool Result::wasOk() const noexcept { return errorMessage.isEmpty(); }
  63. Result::operator bool() const noexcept { return errorMessage.isEmpty(); }
  64. bool Result::failed() const noexcept { return errorMessage.isNotEmpty(); }
  65. bool Result::operator!() const noexcept { return errorMessage.isNotEmpty(); }