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.

154 lines
5.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. An OSC address.
  23. This address always starts with a forward slash and has a format similar
  24. to an URL, with several address parts separated by slashes.
  25. Only a subset of ASCII characters are allowed in OSC addresses; see
  26. OpenSoundControl 1.0 specification for details.
  27. OSC addresses can be used to register ListenerWithOSCAddress objects to an
  28. OSCReceiver if you wish them to only listen to certain messages with
  29. matching OSC address patterns.
  30. @see OSCReceiver, OSCAddressPattern, OSCMessage
  31. @tags{OSC}
  32. */
  33. class JUCE_API OSCAddress
  34. {
  35. public:
  36. //==============================================================================
  37. /** Constructs a new OSCAddress from a String.
  38. @throw OSCFormatError if the string is not a valid OSC address.
  39. */
  40. OSCAddress (const String& address);
  41. /** Constructs a new OSCAddress from a C string.
  42. @throw OSCFormatError of the string is not a valid OSC address.
  43. */
  44. OSCAddress (const char* address);
  45. /** Compares two OSCAddress objects.
  46. @returns true if they contain the same address, false otherwise.
  47. */
  48. bool operator== (const OSCAddress& other) const noexcept;
  49. /** Compares two OSCAddress objects.
  50. @returns false if they contain the same address, true otherwise.
  51. */
  52. bool operator!= (const OSCAddress& other) const noexcept;
  53. /** Converts the OSCAddress to a String.
  54. Note: Trailing slashes are always removed automatically.
  55. @returns a String object that represents the OSC address.
  56. */
  57. String toString() const noexcept;
  58. private:
  59. //==============================================================================
  60. StringArray oscSymbols;
  61. String asString;
  62. friend class OSCAddressPattern;
  63. };
  64. //==============================================================================
  65. /**
  66. An OSC address pattern.
  67. Extends an OSC address by additionally allowing the following wildcards:
  68. ?, *, [], {}
  69. OSC messages always have an OSC address pattern to specify the destination(s)
  70. of the message.
  71. @see OSCMessage, OSCAddress, OSCMessageListener
  72. @tags{OSC}
  73. */
  74. class JUCE_API OSCAddressPattern
  75. {
  76. public:
  77. //==============================================================================
  78. /** Constructs a new OSCAddressPattern from a String.
  79. @throw OSCFormatError if the string is not a valid OSC address pattern.
  80. */
  81. OSCAddressPattern (const String& address);
  82. /** Constructs a new OSCAddressPattern from a C string.
  83. @throw OSCFormatError of the string is not a valid OSC address pattern.
  84. */
  85. OSCAddressPattern (const char* address);
  86. /** Compares two OSCAddressPattern objects.
  87. @returns true if they contain the same address pattern, false otherwise.
  88. */
  89. bool operator== (const OSCAddressPattern& other) const noexcept;
  90. /** Compares two OSCAddressPattern objects.
  91. @returns false if they contain the same address pattern, true otherwise.
  92. */
  93. bool operator!= (const OSCAddressPattern& other) const noexcept;
  94. /** Checks if the OSCAddressPattern matches an OSC address with the wildcard
  95. rules defined by the OpenSoundControl 1.0 specification.
  96. @returns true if the OSCAddressPattern matches the given OSC address,
  97. false otherwise.
  98. */
  99. bool matches (const OSCAddress& address) const noexcept;
  100. /** Checks whether the OSCAddressPattern contains any of the allowed OSC
  101. address pattern wildcards: ?, *, [], {}
  102. @returns true if the OSCAddressPattern contains OSC wildcards, false otherwise.
  103. */
  104. bool containsWildcards() const noexcept { return wasInitialisedWithWildcards; }
  105. /** Converts the OSCAddressPattern to a String.
  106. Note: Trailing slashes are always removed automatically.
  107. @returns a String object that represents the OSC address pattern.
  108. */
  109. String toString() const noexcept;
  110. private:
  111. //==============================================================================
  112. StringArray oscSymbols;
  113. String asString;
  114. bool wasInitialisedWithWildcards;
  115. };
  116. } // namespace juce