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.

82 lines
2.7KB

  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 "Identifier.h"
  21. #include "StringPool.h"
  22. namespace water {
  23. Identifier::Identifier() noexcept {}
  24. Identifier::~Identifier() noexcept {}
  25. Identifier::Identifier (const Identifier& other) noexcept : name (other.name) {}
  26. #if WATER_COMPILER_SUPPORTS_MOVE_SEMANTICS
  27. Identifier::Identifier (Identifier&& other) noexcept : name (static_cast<String&&> (other.name)) {}
  28. Identifier& Identifier::operator= (Identifier&& other) noexcept
  29. {
  30. name = static_cast<String&&> (other.name);
  31. return *this;
  32. }
  33. #endif
  34. Identifier& Identifier::operator= (const Identifier& other) noexcept
  35. {
  36. name = other.name;
  37. return *this;
  38. }
  39. Identifier::Identifier (const String& nm)
  40. : name (StringPool::getGlobalPool().getPooledString (nm))
  41. {
  42. // An Identifier cannot be created from an empty string!
  43. jassert (nm.isNotEmpty());
  44. }
  45. Identifier::Identifier (const char* nm)
  46. : name (StringPool::getGlobalPool().getPooledString (nm))
  47. {
  48. // An Identifier cannot be created from an empty string!
  49. jassert (nm != nullptr && nm[0] != 0);
  50. }
  51. Identifier::Identifier (String::CharPointerType start, String::CharPointerType end)
  52. : name (StringPool::getGlobalPool().getPooledString (start, end))
  53. {
  54. // An Identifier cannot be created from an empty string!
  55. jassert (start < end);
  56. }
  57. Identifier Identifier::null;
  58. bool Identifier::isValidIdentifier (const String& possibleIdentifier) noexcept
  59. {
  60. return possibleIdentifier.isNotEmpty()
  61. && possibleIdentifier.containsOnly ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-:#@$%");
  62. }
  63. }