mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Merge cb79e18b65 into 457cf9ecef
This commit is contained in:
commit
ae4c320cbf
8 changed files with 64 additions and 16 deletions
|
|
@ -35,13 +35,24 @@
|
||||||
namespace juce
|
namespace juce
|
||||||
{
|
{
|
||||||
|
|
||||||
OSCArgument::OSCArgument (int32 v) : type (OSCTypes::int32), intValue (v) {}
|
OSCArgument::OSCArgument() : type(OSCTypes::I) {}
|
||||||
OSCArgument::OSCArgument (float v) : type (OSCTypes::float32), floatValue (v) {}
|
OSCArgument::OSCArgument(bool v) : type (v?OSCTypes::T:OSCTypes::F) {}
|
||||||
OSCArgument::OSCArgument (const String& s) : type (OSCTypes::string), stringValue (s) {}
|
OSCArgument::OSCArgument (int32 v) : type (OSCTypes::int32), intValue (v) {}
|
||||||
OSCArgument::OSCArgument (MemoryBlock b) : type (OSCTypes::blob), blob (std::move (b)) {}
|
OSCArgument::OSCArgument (float v) : type (OSCTypes::float32), floatValue (v) {}
|
||||||
OSCArgument::OSCArgument (OSCColour c) : type (OSCTypes::colour), intValue ((int32) c.toInt32()) {}
|
OSCArgument::OSCArgument (const String& s) : type (OSCTypes::string), stringValue (s) {}
|
||||||
|
OSCArgument::OSCArgument (MemoryBlock b) : type (OSCTypes::blob), blob (std::move (b)) {}
|
||||||
|
OSCArgument::OSCArgument (OSCColour c) : type (OSCTypes::colour), intValue ((int32) c.toInt32()) {}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
bool OSCArgument::getBool() const noexcept
|
||||||
|
{
|
||||||
|
if (isTorF())
|
||||||
|
return type == OSCTypes::T;
|
||||||
|
|
||||||
|
jassertfalse; // you must check the type of an argument before attempting to get its value!
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
String OSCArgument::getString() const noexcept
|
String OSCArgument::getString() const noexcept
|
||||||
{
|
{
|
||||||
if (isString())
|
if (isString())
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,12 @@ namespace juce
|
||||||
class JUCE_API OSCArgument
|
class JUCE_API OSCArgument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/** Constructs an OSCArgument with type I (for Impulse). */
|
||||||
|
OSCArgument();
|
||||||
|
|
||||||
|
/** Constructs an OSCArgument with type boolean T or F depending on the value. */
|
||||||
|
OSCArgument(bool trueOrFalse);
|
||||||
|
|
||||||
/** Constructs an OSCArgument with type int32 and a given value. */
|
/** Constructs an OSCArgument with type int32 and a given value. */
|
||||||
OSCArgument (int32 value);
|
OSCArgument (int32 value);
|
||||||
|
|
||||||
|
|
@ -74,6 +80,12 @@ public:
|
||||||
*/
|
*/
|
||||||
OSCType getType() const noexcept { return type; }
|
OSCType getType() const noexcept { return type; }
|
||||||
|
|
||||||
|
/** Returns whether the type of the OSCArgument is T or F. */
|
||||||
|
bool isImpulse() const noexcept { return type == OSCTypes::I; }
|
||||||
|
|
||||||
|
/** Returns whether the type of the OSCArgument is T or F. */
|
||||||
|
bool isTorF() const noexcept { return type == OSCTypes::T || type == OSCTypes::F; }
|
||||||
|
|
||||||
/** Returns whether the type of the OSCArgument is int32. */
|
/** Returns whether the type of the OSCArgument is int32. */
|
||||||
bool isInt32() const noexcept { return type == OSCTypes::int32; }
|
bool isInt32() const noexcept { return type == OSCTypes::int32; }
|
||||||
|
|
||||||
|
|
@ -89,6 +101,11 @@ public:
|
||||||
/** Returns whether the type of the OSCArgument is colour. */
|
/** Returns whether the type of the OSCArgument is colour. */
|
||||||
bool isColour() const noexcept { return type == OSCTypes::colour; }
|
bool isColour() const noexcept { return type == OSCTypes::colour; }
|
||||||
|
|
||||||
|
/** Returns the value of the OSCArgument as an int32.
|
||||||
|
If the type of the OSCArgument is not int32, the behaviour is undefined.
|
||||||
|
*/
|
||||||
|
bool getBool() const noexcept;
|
||||||
|
|
||||||
/** Returns the value of the OSCArgument as an int32.
|
/** Returns the value of the OSCArgument as an int32.
|
||||||
If the type of the OSCArgument is not int32, the behaviour is undefined.
|
If the type of the OSCArgument is not int32, the behaviour is undefined.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ void OSCMessage::clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
void OSCMessage::addBool(bool value) { arguments.add(OSCArgument(value)); }
|
||||||
void OSCMessage::addInt32 (int32 value) { arguments.add (OSCArgument (value)); }
|
void OSCMessage::addInt32 (int32 value) { arguments.add (OSCArgument (value)); }
|
||||||
void OSCMessage::addFloat32 (float value) { arguments.add (OSCArgument (value)); }
|
void OSCMessage::addFloat32 (float value) { arguments.add (OSCArgument (value)); }
|
||||||
void OSCMessage::addString (const String& value) { arguments.add (OSCArgument (value)); }
|
void OSCMessage::addString (const String& value) { arguments.add (OSCArgument (value)); }
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,11 @@ public:
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
/** Creates a new OSCArgument of type T or F depending on the given value,
|
||||||
|
and adds it to the OSCMessage object.
|
||||||
|
*/
|
||||||
|
void addBool(bool value);
|
||||||
|
|
||||||
/** Creates a new OSCArgument of type int32 with the given value,
|
/** Creates a new OSCArgument of type int32 with the given value,
|
||||||
and adds it to the OSCMessage object.
|
and adds it to the OSCMessage object.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -183,17 +183,19 @@ namespace
|
||||||
return typeList;
|
return typeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
OSCArgument readArgument (OSCType type)
|
OSCArgument readArgument(OSCType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case OSCTypes::int32: return OSCArgument (readInt32());
|
case OSCTypes::I: return OSCArgument();
|
||||||
case OSCTypes::float32: return OSCArgument (readFloat32());
|
case OSCTypes::T: return OSCArgument(true);
|
||||||
case OSCTypes::string: return OSCArgument (readString());
|
case OSCTypes::F: return OSCArgument(false);
|
||||||
case OSCTypes::blob: return OSCArgument (readBlob());
|
case OSCTypes::int32: return OSCArgument(readInt32());
|
||||||
case OSCTypes::colour: return OSCArgument (readColour());
|
case OSCTypes::float32: return OSCArgument(readFloat32());
|
||||||
|
case OSCTypes::string: return OSCArgument(readString());
|
||||||
|
case OSCTypes::blob: return OSCArgument(readBlob());
|
||||||
|
case OSCTypes::colour: return OSCArgument(readColour());
|
||||||
default:
|
default:
|
||||||
// You supplied an invalid OSCType when calling readArgument! This should never happen.
|
// You supplied an invalid OSCType when calling readArgument! This should never happen.
|
||||||
jassertfalse;
|
jassertfalse;
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,9 @@ namespace
|
||||||
{
|
{
|
||||||
switch (arg.getType())
|
switch (arg.getType())
|
||||||
{
|
{
|
||||||
|
case OSCTypes::T: return true;
|
||||||
|
case OSCTypes::F: return true;
|
||||||
|
case OSCTypes::I: return true;
|
||||||
case OSCTypes::int32: return writeInt32 (arg.getInt32());
|
case OSCTypes::int32: return writeInt32 (arg.getInt32());
|
||||||
case OSCTypes::float32: return writeFloat32 (arg.getFloat32());
|
case OSCTypes::float32: return writeFloat32 (arg.getFloat32());
|
||||||
case OSCTypes::string: return writeString (arg.getString());
|
case OSCTypes::string: return writeString (arg.getString());
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@
|
||||||
namespace juce
|
namespace juce
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const OSCType OSCTypes::T = 'T';
|
||||||
|
const OSCType OSCTypes::F = 'F';
|
||||||
|
const OSCType OSCTypes::I = 'I';
|
||||||
const OSCType OSCTypes::int32 = 'i';
|
const OSCType OSCTypes::int32 = 'i';
|
||||||
const OSCType OSCTypes::float32 = 'f';
|
const OSCType OSCTypes::float32 = 'f';
|
||||||
const OSCType OSCTypes::string = 's';
|
const OSCType OSCTypes::string = 's';
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,9 @@ using OSCTypeList = Array<OSCType>;
|
||||||
class JUCE_API OSCTypes
|
class JUCE_API OSCTypes
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static const OSCType T;
|
||||||
|
static const OSCType F;
|
||||||
|
static const OSCType I;
|
||||||
static const OSCType int32;
|
static const OSCType int32;
|
||||||
static const OSCType float32;
|
static const OSCType float32;
|
||||||
static const OSCType string;
|
static const OSCType string;
|
||||||
|
|
@ -63,7 +66,10 @@ public:
|
||||||
|
|
||||||
static bool isSupportedType (OSCType type) noexcept
|
static bool isSupportedType (OSCType type) noexcept
|
||||||
{
|
{
|
||||||
return type == OSCTypes::int32
|
return type == OSCTypes::T
|
||||||
|
|| type == OSCTypes::F
|
||||||
|
|| type == OSCTypes::I
|
||||||
|
|| type == OSCTypes::int32
|
||||||
|| type == OSCTypes::float32
|
|| type == OSCTypes::float32
|
||||||
|| type == OSCTypes::string
|
|| type == OSCTypes::string
|
||||||
|| type == OSCTypes::blob
|
|| type == OSCTypes::blob
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue