Audio plugin host https://kx.studio/carla
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.

Result.cpp 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. ==============================================================================
  3. This file is part of the Water library.
  4. Copyright (c) 2016 ROLI Ltd.
  5. Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
  6. Permission is granted to use this software under the terms of the ISC license
  7. http://www.isc.org/downloads/software-support-policy/isc-license/
  8. Permission to use, copy, modify, and/or distribute this software for any
  9. purpose with or without fee is hereby granted, provided that the above
  10. copyright notice and this permission notice appear in all copies.
  11. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  12. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  13. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  14. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  15. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  17. OF THIS SOFTWARE.
  18. ==============================================================================
  19. */
  20. #include "Result.h"
  21. namespace water {
  22. Result::Result() noexcept {}
  23. Result::Result (const String& message) noexcept
  24. : errorMessage (message)
  25. {
  26. }
  27. Result::Result (const Result& other)
  28. : errorMessage (other.errorMessage)
  29. {
  30. }
  31. Result& Result::operator= (const Result& other)
  32. {
  33. errorMessage = other.errorMessage;
  34. return *this;
  35. }
  36. #if WATER_COMPILER_SUPPORTS_MOVE_SEMANTICS
  37. Result::Result (Result&& other) noexcept
  38. : errorMessage (static_cast<String&&> (other.errorMessage))
  39. {
  40. }
  41. Result& Result::operator= (Result&& other) noexcept
  42. {
  43. errorMessage = static_cast<String&&> (other.errorMessage);
  44. return *this;
  45. }
  46. #endif
  47. bool Result::operator== (const Result& other) const noexcept
  48. {
  49. return errorMessage == other.errorMessage;
  50. }
  51. bool Result::operator!= (const Result& other) const noexcept
  52. {
  53. return errorMessage != other.errorMessage;
  54. }
  55. Result Result::fail (const String& errorMessage) noexcept
  56. {
  57. return Result (errorMessage.isEmpty() ? "Unknown Error" : errorMessage);
  58. }
  59. const String& Result::getErrorMessage() const noexcept
  60. {
  61. return errorMessage;
  62. }
  63. bool Result::wasOk() const noexcept { return errorMessage.isEmpty(); }
  64. Result::operator bool() const noexcept { return errorMessage.isEmpty(); }
  65. bool Result::failed() const noexcept { return errorMessage.isNotEmpty(); }
  66. bool Result::operator!() const noexcept { return errorMessage.isNotEmpty(); }
  67. }