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.

112 lines
3.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. //==============================================================================
  21. /**
  22. An OSC argument.
  23. An OSC argument is a value of one of the following types: int32, float32, string,
  24. or blob (raw binary data).
  25. OSCMessage objects are essentially arrays of OSCArgument objects.
  26. */
  27. class JUCE_API OSCArgument
  28. {
  29. public:
  30. /** Constructs an OSCArgument with type int32 and a given value. */
  31. OSCArgument (int32 value) noexcept;
  32. /** Constructs an OSCArgument with type float32 and a given value. */
  33. OSCArgument (float value) noexcept;
  34. /** Constructs an OSCArgument with type string and a given value */
  35. OSCArgument (const String& value) noexcept;
  36. /** Constructs an OSCArgument with type blob and copies dataSize bytes
  37. from the memory pointed to by data into the blob.
  38. The data owned by the blob will be released when the OSCArgument object
  39. gets destructed.
  40. */
  41. OSCArgument (const MemoryBlock& blob);
  42. /** Returns the type of the OSCArgument as an OSCType.
  43. OSCType is a char type, and its value will be the OSC type tag of the type.
  44. */
  45. OSCType getType() const noexcept { return type; }
  46. /** Returns whether the type of the OSCArgument is int32. */
  47. bool isInt32() const noexcept { return type == OSCTypes::int32; }
  48. /** Returns whether the type of the OSCArgument is int32. */
  49. bool isFloat32() const noexcept { return type == OSCTypes::float32; }
  50. /** Returns whether the type of the OSCArgument is int32. */
  51. bool isString() const noexcept { return type == OSCTypes::string; }
  52. /** Returns whether the type of the OSCArgument is int32. */
  53. bool isBlob() const noexcept { return type == OSCTypes::blob; }
  54. /** Returns the value of the OSCArgument as an int32.
  55. If the type of the OSCArgument is not int32, the behaviour is undefined.
  56. */
  57. int32 getInt32() const noexcept;
  58. /** Returns the value of the OSCArgument as a float32.
  59. If the type of the OSCArgument is not float32, the behaviour is undefined.
  60. */
  61. float getFloat32() const noexcept;
  62. /** Returns the value of the OSCArgument as a string.
  63. If the type of the OSCArgument is not string, the behaviour is undefined.
  64. */
  65. String getString() const noexcept;
  66. /** Returns the binary data contained in the blob and owned by the OSCArgument,
  67. as a reference to a Juce MemoryBlock object.
  68. If the type of the OSCArgument is not blob, the behaviour is undefined.
  69. */
  70. const MemoryBlock& getBlob() const noexcept;
  71. private:
  72. //==============================================================================
  73. OSCType type;
  74. union
  75. {
  76. int32 intValue;
  77. float floatValue;
  78. };
  79. String stringValue;
  80. MemoryBlock blob;
  81. };