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.

90 lines
2.7KB

  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. BEGIN_JUCE_NAMESPACE
  19. //==============================================================================
  20. Result::Result (const String& message) noexcept
  21. : errorMessage (message)
  22. {
  23. }
  24. Result::Result (const Result& other)
  25. : errorMessage (other.errorMessage)
  26. {
  27. }
  28. Result& Result::operator= (const Result& other)
  29. {
  30. errorMessage = other.errorMessage;
  31. return *this;
  32. }
  33. #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
  34. Result::Result (Result&& other) noexcept
  35. : errorMessage (static_cast <String&&> (other.errorMessage))
  36. {
  37. }
  38. Result& Result::operator= (Result&& other) noexcept
  39. {
  40. errorMessage = static_cast <String&&> (other.errorMessage);
  41. return *this;
  42. }
  43. #endif
  44. bool Result::operator== (const Result& other) const noexcept
  45. {
  46. return errorMessage == other.errorMessage;
  47. }
  48. bool Result::operator!= (const Result& other) const noexcept
  49. {
  50. return errorMessage != other.errorMessage;
  51. }
  52. Result Result::ok() noexcept
  53. {
  54. return Result (String::empty);
  55. }
  56. Result Result::fail (const String& errorMessage) noexcept
  57. {
  58. return Result (errorMessage.isEmpty() ? "Unknown Error" : errorMessage);
  59. }
  60. const String& Result::getErrorMessage() const noexcept
  61. {
  62. return errorMessage;
  63. }
  64. bool Result::wasOk() const noexcept { return errorMessage.isEmpty(); }
  65. Result::operator bool() const noexcept { return errorMessage.isEmpty(); }
  66. bool Result::failed() const noexcept { return errorMessage.isNotEmpty(); }
  67. bool Result::operator!() const noexcept { return errorMessage.isNotEmpty(); }
  68. END_JUCE_NAMESPACE