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.

151 lines
5.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_OSCADDRESS_H_INCLUDED
  18. #define JUCE_OSCADDRESS_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. An OSC address.
  22. This address always starts with a forward slash and has a format similar
  23. to an URL, with several address parts separated by slashes.
  24. Only a subset of ASCII characters are allowed in OSC addresses; see
  25. OpenSoundControl 1.0 specification for details.
  26. OSC addresses can be used to register OSCMessageListener objects to an
  27. OSCReceiver if you wish them to only listen to certain messages with
  28. matching OSC address patterns.
  29. @seeOSCMessageListener, OSCAddressPattern, OSCMessage
  30. */
  31. class JUCE_API OSCAddress
  32. {
  33. public:
  34. //==========================================================================
  35. /** Constructs a new OSCAddress from a String.
  36. @throw OSCFormatError if the string is not a valid OSC address.
  37. */
  38. OSCAddress (const String& address);
  39. /** Constructs a new OSCAddress from a C string.
  40. @throw OSCFormatError of the string is not a valid OSC address.
  41. */
  42. OSCAddress (const char* address);
  43. /** Compares two OSCAddress objects.
  44. @returns true if they contain the same address, false otherwise.
  45. */
  46. bool operator== (const OSCAddress& other) const noexcept;
  47. /** Compares two OSCAddress objects.
  48. @returns false if they contain the same address, true otherwise.
  49. */
  50. bool operator!= (const OSCAddress& other) const noexcept;
  51. /** Converts the OSCAddress to a String.
  52. Note: trailing slashes are always removed automatically.
  53. @returns a String object that represents the OSC address.
  54. */
  55. String toString() const noexcept;
  56. private:
  57. //==============================================================================
  58. StringArray oscSymbols;
  59. String asString;
  60. friend class OSCAddressPattern;
  61. };
  62. //==============================================================================
  63. /**
  64. An OSC address pattern.
  65. Extends an OSC address by additionally allowing the following wildcards:
  66. ?, *, [], {}
  67. OSC messages always have an OSC address pattern to specify the destination(s)
  68. of the message.
  69. @see OSCMessage, OSCAddress, OSCMessageListener
  70. */
  71. class JUCE_API OSCAddressPattern
  72. {
  73. public:
  74. //==========================================================================
  75. /** Constructs a new OSCAddressPattern from a String.
  76. @throw OSCFormatError if the string is not a valid OSC address pattern.
  77. */
  78. OSCAddressPattern (const String& address);
  79. /** Constructs a new OSCAddressPattern from a C string.
  80. @throw OSCFormatError of the string is not a valid OSC address pattern.
  81. */
  82. OSCAddressPattern (const char* address);
  83. /** Compares two OSCAddressPattern objects.
  84. @returns true if they contain the same address pattern, false otherwise.
  85. */
  86. bool operator== (const OSCAddressPattern& other) const noexcept;
  87. /** Compares two OSCAddressPattern objects.
  88. @returns false if they contain the same address pattern, true otherwise.
  89. */
  90. bool operator!= (const OSCAddressPattern& other) const noexcept;
  91. /** Checks if the OSCAddressPattern matches an OSC address with the wildcard
  92. rules defined by the OpenSoundControl 1.0 specification.
  93. @returns true if the OSCAddressPattern matches the given OSC address,
  94. false otherwise.
  95. */
  96. bool matches (const OSCAddress& address) const noexcept;
  97. /** Checks whether the OSCAddressPattern contains any of the allowed OSC
  98. address patttern wildcards: ?, *, [], {}
  99. @returns true if the OSCAddressPattern contains OSC wildcards, false otherwise.
  100. */
  101. bool containsWildcards() const noexcept { return wasInitialisedWithWildcards; }
  102. /** Converts the OSCAddressPattern to a String.
  103. Note: trailing slashes are always removed automatically.
  104. @returns a String object that represents the OSC address pattern.
  105. */
  106. String toString() const noexcept;
  107. private:
  108. //==========================================================================
  109. StringArray oscSymbols;
  110. String asString;
  111. bool wasInitialisedWithWildcards;
  112. };
  113. #endif // JUCE_OSCADDRESS_H_INCLUDED