26enum VariantStreamMarkers
29 varMarker_BoolTrue = 2,
30 varMarker_BoolFalse = 3,
36 varMarker_Undefined = 9
56 bool isUndefined =
false;
60 bool isDouble =
false;
61 bool isString =
false;
62 bool isObject =
false;
64 bool isBinary =
false;
65 bool isMethod =
false;
66 bool isComparable =
false;
68 int (*toInt) (
const ValueUnion&) = defaultToInt;
69 int64 (*toInt64) (
const ValueUnion&) = defaultToInt64;
70 double (*toDouble) (
const ValueUnion&) = defaultToDouble;
71 String (*toString) (
const ValueUnion&) = defaultToString;
72 bool (*toBool) (
const ValueUnion&) = defaultToBool;
74 Array<var>* (*toArray) (
const ValueUnion&) = defaultToArray;
75 MemoryBlock* (*toBinary) (
const ValueUnion&) = defaultToBinary;
76 var (*clone) (
const var&) = defaultClone;
77 void (*cleanUp) (ValueUnion&) = defaultCleanUp;
78 void (*createCopy) (ValueUnion&,
const ValueUnion&) = defaultCreateCopy;
80 bool (*equals) (
const ValueUnion&,
const ValueUnion&,
const VariantType&) =
nullptr;
84 static int defaultToInt (
const ValueUnion&) {
return 0; }
85 static int64 defaultToInt64 (
const ValueUnion&) {
return 0; }
86 static double defaultToDouble (
const ValueUnion&) {
return 0; }
87 static String defaultToString (
const ValueUnion&) {
return {}; }
88 static bool defaultToBool (
const ValueUnion&) {
return false; }
89 static ReferenceCountedObject* defaultToObject (
const ValueUnion&) {
return nullptr; }
90 static Array<var>* defaultToArray (
const ValueUnion&) {
return nullptr; }
91 static MemoryBlock* defaultToBinary (
const ValueUnion&) {
return nullptr; }
93 static void defaultCleanUp (ValueUnion&) {}
94 static void defaultCreateCopy (ValueUnion& dest,
const ValueUnion& source) { dest = source; }
97 static bool voidEquals (
const ValueUnion&,
const ValueUnion&,
const VariantType&
otherType)
noexcept
102 static void voidWriteToStream (
const ValueUnion&, OutputStream& output)
104 output.writeCompressedInt (0);
107 constexpr explicit VariantType (VoidTag) noexcept
111 writeToStream (voidWriteToStream) {}
114 static String undefinedToString (
const ValueUnion&) {
return "undefined"; }
116 static bool undefinedEquals (
const ValueUnion&,
const ValueUnion&,
const VariantType&
otherType)
noexcept
121 static void undefinedWriteToStream (
const ValueUnion&, OutputStream& output)
123 output.writeCompressedInt (1);
124 output.writeByte (varMarker_Undefined);
127 constexpr explicit VariantType (UndefinedTag) noexcept
128 : isUndefined (
true),
129 toString (undefinedToString),
130 equals (undefinedEquals),
131 writeToStream (undefinedWriteToStream) {}
134 static int intToInt (
const ValueUnion& data)
noexcept {
return data.intValue; }
135 static int64 intToInt64 (
const ValueUnion& data)
noexcept {
return (
int64)
data.intValue; }
136 static double intToDouble (
const ValueUnion& data)
noexcept {
return (
double)
data.intValue; }
137 static String intToString (
const ValueUnion& data) {
return String (
data.intValue); }
138 static bool intToBool (
const ValueUnion& data)
noexcept {
return data.intValue != 0; }
140 static bool intEquals (
const ValueUnion& data,
const ValueUnion&
otherData,
const VariantType&
otherType)
noexcept
148 static void intWriteToStream (
const ValueUnion& data, OutputStream& output)
150 output.writeCompressedInt (5);
151 output.writeByte (varMarker_Int);
152 output.writeInt (
data.intValue);
155 constexpr explicit VariantType (IntTag) noexcept
159 toInt64 (intToInt64),
160 toDouble (intToDouble),
161 toString (intToString),
164 writeToStream (intWriteToStream) {}
167 static int int64ToInt (
const ValueUnion& data)
noexcept {
return (
int)
data.int64Value; }
168 static int64 int64ToInt64 (
const ValueUnion& data)
noexcept {
return data.int64Value; }
169 static double int64ToDouble (
const ValueUnion& data)
noexcept {
return (
double)
data.int64Value; }
170 static String int64ToString (
const ValueUnion& data) {
return String (
data.int64Value); }
171 static bool int64ToBool (
const ValueUnion& data)
noexcept {
return data.int64Value != 0; }
173 static bool int64Equals (
const ValueUnion& data,
const ValueUnion&
otherData,
const VariantType&
otherType)
noexcept
181 static void int64WriteToStream (
const ValueUnion& data, OutputStream& output)
183 output.writeCompressedInt (9);
184 output.writeByte (varMarker_Int64);
185 output.writeInt64 (
data.int64Value);
188 constexpr explicit VariantType (Int64Tag) noexcept
192 toInt64 (int64ToInt64),
193 toDouble (int64ToDouble),
194 toString (int64ToString),
195 toBool (int64ToBool),
196 equals (int64Equals),
197 writeToStream (int64WriteToStream) {}
200 static int doubleToInt (
const ValueUnion& data)
noexcept {
return (
int)
data.doubleValue; }
201 static int64 doubleToInt64 (
const ValueUnion& data)
noexcept {
return (
int64)
data.doubleValue; }
202 static double doubleToDouble (
const ValueUnion& data)
noexcept {
return data.doubleValue; }
203 static String doubleToString (
const ValueUnion& data) {
return serialiseDouble (
data.doubleValue); }
204 static bool doubleToBool (
const ValueUnion& data)
noexcept {
return !
exactlyEqual (
data.doubleValue, 0.0); }
206 static bool doubleEquals (
const ValueUnion& data,
const ValueUnion&
otherData,
const VariantType&
otherType)
noexcept
211 static void doubleWriteToStream (
const ValueUnion& data, OutputStream& output)
213 output.writeCompressedInt (9);
214 output.writeByte (varMarker_Double);
215 output.writeDouble (
data.doubleValue);
218 constexpr explicit VariantType (DoubleTag) noexcept
222 toInt64 (doubleToInt64),
223 toDouble (doubleToDouble),
224 toString (doubleToString),
225 toBool (doubleToBool),
226 equals (doubleEquals),
227 writeToStream (doubleWriteToStream) {}
230 static int boolToInt (
const ValueUnion& data)
noexcept {
return data.boolValue ? 1 : 0; }
231 static int64 boolToInt64 (
const ValueUnion& data)
noexcept {
return data.boolValue ? 1 : 0; }
232 static double boolToDouble (
const ValueUnion& data)
noexcept {
return data.boolValue ? 1.0 : 0.0; }
234 static bool boolToBool (
const ValueUnion& data)
noexcept {
return data.boolValue; }
236 static bool boolEquals (
const ValueUnion& data,
const ValueUnion&
otherData,
const VariantType&
otherType)
noexcept
241 static void boolWriteToStream (
const ValueUnion& data, OutputStream& output)
243 output.writeCompressedInt (1);
244 output.writeByte (
data.boolValue ? (
char) varMarker_BoolTrue : (
char) varMarker_BoolFalse);
247 constexpr explicit VariantType (BoolTag) noexcept
251 toInt64 (boolToInt64),
252 toDouble (boolToDouble),
253 toString (boolToString),
256 writeToStream (boolWriteToStream) {}
262 static int stringToInt (
const ValueUnion& data)
noexcept {
return getString (data)->
getIntValue(); }
263 static int64 stringToInt64 (
const ValueUnion& data)
noexcept {
return getString (data)->
getLargeIntValue(); }
264 static double stringToDouble (
const ValueUnion& data)
noexcept {
return getString (data)->
getDoubleValue(); }
265 static String stringToString (
const ValueUnion& data) {
return *getString (data); }
266 static bool stringToBool (
const ValueUnion& data)
noexcept
273 static void stringCleanUp (ValueUnion& data)
noexcept { getString (data)-> ~String(); }
274 static void stringCreateCopy (ValueUnion& dest,
const ValueUnion& source) {
new (dest.stringValue) String (*getString (source)); }
276 static bool stringEquals (
const ValueUnion& data,
const ValueUnion&
otherData,
const VariantType&
otherType)
noexcept
281 static void stringWriteToStream (
const ValueUnion& data, OutputStream& output)
283 auto* s = getString (data);
284 const size_t len = s->getNumBytesAsUTF8() + 1;
285 HeapBlock<char> temp (len);
286 s->copyToUTF8 (temp, len);
287 output.writeCompressedInt ((
int) (len + 1));
288 output.writeByte (varMarker_String);
289 output.write (temp, len);
292 constexpr explicit VariantType (StringTag) noexcept
296 toInt64 (stringToInt64),
297 toDouble (stringToDouble),
298 toString (stringToString),
299 toBool (stringToBool),
300 cleanUp (stringCleanUp),
301 createCopy (stringCreateCopy),
302 equals (stringEquals),
303 writeToStream (stringWriteToStream) {}
306 static String objectToString (
const ValueUnion& data)
311 static bool objectToBool (
const ValueUnion& data)
noexcept {
return data.objectValue !=
nullptr; }
312 static ReferenceCountedObject* objectToObject (
const ValueUnion& data)
noexcept {
return data.objectValue; }
316 if (
auto* d =
original.getDynamicObject())
317 return d->clone().release();
323 static void objectCleanUp (ValueUnion& data)
noexcept {
if (
data.objectValue !=
nullptr)
data.objectValue->decReferenceCount(); }
325 static void objectCreateCopy (ValueUnion& dest,
const ValueUnion& source)
327 dest.objectValue = source.objectValue;
328 if (dest.objectValue !=
nullptr)
329 dest.objectValue->incReferenceCount();
332 static bool objectEquals (
const ValueUnion& data,
const ValueUnion&
otherData,
const VariantType&
otherType)
noexcept
337 static void objectWriteToStream (
const ValueUnion&, OutputStream& output)
340 output.writeCompressedInt (0);
343 constexpr explicit VariantType (ObjectTag) noexcept
345 toString (objectToString),
346 toBool (objectToBool),
347 toObject (objectToObject),
349 cleanUp (objectCleanUp),
350 createCopy (objectCreateCopy),
351 equals (objectEquals),
352 writeToStream (objectWriteToStream) {}
355 static String arrayToString (
const ValueUnion&) {
return "[Array]"; }
356 static ReferenceCountedObject* arrayToObject (
const ValueUnion&)
noexcept {
return nullptr; }
358 static Array<var>* arrayToArray (
const ValueUnion& data)
noexcept
360 if (
auto* a =
dynamic_cast<RefCountedArray*
> (
data.objectValue))
366 static bool arrayEquals (
const ValueUnion& data,
const ValueUnion&
otherData,
const VariantType&
otherType)
noexcept
377 if (
auto* array = arrayToArray (
original.value))
379 arrayCopy.ensureStorageAllocated (array->size());
381 for (
auto& i : *array)
388 static void arrayWriteToStream (
const ValueUnion& data, OutputStream& output)
390 if (
auto* array = arrayToArray (data))
392 MemoryOutputStream buffer (512);
393 buffer.writeCompressedInt (array->size());
395 for (
auto& i : *array)
396 i.writeToStream (buffer);
398 output.writeCompressedInt (1 + (
int) buffer.getDataSize());
399 output.writeByte (varMarker_Array);
414 toString (arrayToString),
415 toBool (objectToBool),
416 toObject (arrayToObject),
417 toArray (arrayToArray),
419 cleanUp (objectCleanUp),
420 createCopy (objectCreateCopy),
421 equals (arrayEquals),
422 writeToStream (arrayWriteToStream) {}
425 static void binaryCleanUp (ValueUnion& data)
noexcept {
delete data.binaryValue; }
426 static void binaryCreateCopy (ValueUnion& dest,
const ValueUnion& source) { dest.binaryValue =
new MemoryBlock (*source.binaryValue); }
428 static String binaryToString (
const ValueUnion& data) {
return data.binaryValue->toBase64Encoding(); }
429 static MemoryBlock* binaryToBinary (
const ValueUnion& data)
noexcept {
return data.binaryValue; }
431 static bool binaryEquals (
const ValueUnion& data,
const ValueUnion&
otherData,
const VariantType&
otherType)
noexcept
437 static void binaryWriteToStream (
const ValueUnion& data, OutputStream& output)
439 output.writeCompressedInt (1 + (
int)
data.binaryValue->getSize());
440 output.writeByte (varMarker_Binary);
441 output << *
data.binaryValue;
444 constexpr explicit VariantType (BinaryTag) noexcept
446 toString (binaryToString),
447 toBinary (binaryToBinary),
448 cleanUp (binaryCleanUp),
449 createCopy (binaryCreateCopy),
450 equals (binaryEquals),
451 writeToStream (binaryWriteToStream) {}
454 static void methodCleanUp (ValueUnion& data)
noexcept {
if (
data.methodValue !=
nullptr )
delete data.methodValue; }
455 static void methodCreateCopy (ValueUnion& dest,
const ValueUnion& source) { dest.methodValue =
new NativeFunction (*source.methodValue); }
457 static String methodToString (
const ValueUnion&) {
return "Method"; }
458 static bool methodToBool (
const ValueUnion& data)
noexcept {
return data.methodValue !=
nullptr; }
460 static bool methodEquals (
const ValueUnion& data,
const ValueUnion&
otherData,
const VariantType&
otherType)
noexcept
465 static void methodWriteToStream (
const ValueUnion&, OutputStream& output)
468 output.writeCompressedInt (0);
471 constexpr explicit VariantType (MethodTag) noexcept
473 toString (methodToString),
474 toBool (methodToBool),
475 cleanUp (methodCleanUp),
476 createCopy (methodCreateCopy),
477 equals (methodEquals),
478 writeToStream (methodWriteToStream) {}
498var::var (
const VariantType& t) noexcept : type (&t) {}
507var::var (
const int v) noexcept : type (&Instance::attributesInt) { value.intValue = v; }
508var::var (
const int64 v) noexcept : type (&Instance::attributesInt64) { value.int64Value = v; }
509var::var (
const bool v) noexcept : type (&Instance::attributesBool) { value.boolValue = v; }
510var::var (
const double v) noexcept : type (&Instance::attributesDouble) { value.doubleValue = v; }
511var::var (NativeFunction m) noexcept : type (&Instance::attributesMethod) { value.methodValue =
new NativeFunction (m); }
512var::var (
const Array<var>& v) : type (&Instance::attributesArray) { value.objectValue =
new VariantType::RefCountedArray (v); }
513var::var (
const String& v) : type (&Instance::attributesString) {
new (value.stringValue) String (v); }
514var::var (
const char*
const v) : type (&Instance::attributesString) {
new (value.stringValue) String (v); }
515var::var (
const wchar_t*
const v) : type (&Instance::attributesString) {
new (value.stringValue) String (v); }
516var::var (
const void* v,
size_t sz) : type (&Instance::attributesBinary) { value.binaryValue =
new MemoryBlock (v,
sz); }
517var::var (
const MemoryBlock& v) : type (&Instance::attributesBinary) { value.binaryValue =
new MemoryBlock (v); }
519var::var (
const StringArray& v) : type (&Instance::attributesArray)
522 strings.ensureStorageAllocated (v.size());
525 strings.add (
var (i));
527 value.objectValue =
new VariantType::RefCountedArray (strings);
530var::var (ReferenceCountedObject*
const object) : type (&Instance::attributesObject)
532 value.objectValue = object;
534 if (
object !=
nullptr)
535 object->incReferenceCount();
541bool var::isVoid()
const noexcept {
return type->isVoid; }
542bool var::isUndefined()
const noexcept {
return type->isUndefined; }
543bool var::isInt()
const noexcept {
return type->isInt; }
544bool var::isInt64()
const noexcept {
return type->isInt64; }
545bool var::isBool()
const noexcept {
return type->isBool; }
546bool var::isDouble()
const noexcept {
return type->isDouble; }
547bool var::isString()
const noexcept {
return type->isString; }
548bool var::isObject()
const noexcept {
return type->isObject; }
549bool var::isArray()
const noexcept {
return type->isArray; }
550bool var::isBinaryData()
const noexcept {
return type->isBinary; }
551bool var::isMethod()
const noexcept {
return type->isMethod; }
553var::operator
int()
const noexcept {
return type->toInt (value); }
554var::operator
int64()
const noexcept {
return type->toInt64 (value); }
555var::operator
bool()
const noexcept {
return type->toBool (value); }
556var::operator
float()
const noexcept {
return (
float) type->toDouble (value); }
557var::operator
double()
const noexcept {
return type->toDouble (value); }
558String var::toString()
const {
return type->toString (value); }
559var::operator String()
const {
return type->toString (value); }
560ReferenceCountedObject* var::getObject()
const noexcept {
return type->toObject (value); }
566void var::swapWith (var&
other)
noexcept
572var& var::operator= (
const var& v) { type->cleanUp (value); type = v.type; type->createCopy (value, v.value);
return *
this; }
573var& var::operator= (
const int v) { type->cleanUp (value); type = &Instance::attributesInt; value.intValue = v;
return *
this; }
574var& var::operator= (
const int64 v) { type->cleanUp (value); type = &Instance::attributesInt64; value.int64Value = v;
return *
this; }
575var& var::operator= (
const bool v) { type->cleanUp (value); type = &Instance::attributesBool; value.boolValue = v;
return *
this; }
576var& var::operator= (
const double v) { type->cleanUp (value); type = &Instance::attributesDouble; value.doubleValue = v;
return *
this; }
577var& var::operator= (
const char*
const v) { type->cleanUp (value); type = &Instance::attributesString;
new (value.stringValue) String (v);
return *
this; }
578var& var::operator= (
const wchar_t*
const v) { type->cleanUp (value); type = &Instance::attributesString;
new (value.stringValue) String (v);
return *
this; }
579var& var::operator= (
const String& v) { type->cleanUp (value); type = &Instance::attributesString;
new (value.stringValue) String (v);
return *
this; }
580var& var::operator= (
const MemoryBlock& v) { type->cleanUp (value); type = &Instance::attributesBinary; value.binaryValue =
new MemoryBlock (v);
return *
this; }
581var& var::operator= (
const Array<var>& v) {
var v2 (v); swapWith (v2);
return *
this; }
582var& var::operator= (ReferenceCountedObject* v) {
var v2 (v); swapWith (v2);
return *
this; }
583var& var::operator= (NativeFunction v) {
var v2 (v); swapWith (v2);
return *
this; }
589 other.type = &Instance::attributesVoid;
592var& var::operator= (var&&
other)
noexcept
598var::var (String&& v) : type (&Instance::attributesString)
600 new (value.stringValue) String (std::move (v));
603var::var (MemoryBlock&& v) : type (&Instance::attributesBinary)
605 value.binaryValue =
new MemoryBlock (std::move (v));
610 value.objectValue =
new VariantType::RefCountedArray (std::move (v));
613var& var::operator= (String&& v)
615 type->cleanUp (value);
616 type = &Instance::attributesString;
617 new (value.stringValue) String (std::move (v));
624 return type->equals (value,
other.value, *
other.type);
629 return hasSameTypeAs (
other) && equals (
other);
634 return type ==
other.type;
637bool canCompare (
const var& v1,
const var& v2)
639 return v1.type->isComparable && v2.type->isComparable;
642static int compare (
const var& v1,
const var& v2)
644 if (v1.isString() && v2.isString())
645 return v1.toString().compare (v2.toString());
647 auto diff =
static_cast<double> (v1) -
static_cast<double> (v2);
651bool operator== (
const var& v1,
const var& v2) {
return v1.
equals (v2); }
652bool operator!= (
const var& v1,
const var& v2) {
return ! v1.
equals (v2); }
653bool operator< (
const var& v1,
const var& v2) {
return canCompare (v1, v2) && compare (v1, v2) < 0; }
654bool operator> (
const var& v1,
const var& v2) {
return canCompare (v1, v2) && compare (v1, v2) > 0; }
655bool operator<= (
const var& v1,
const var& v2) {
return canCompare (v1, v2) && compare (v1, v2) <= 0; }
656bool operator>= (
const var& v1,
const var& v2) {
return canCompare (v1, v2) && compare (v1, v2) >= 0; }
658bool operator== (
const var& v1,
const String& v2) {
return v1.toString() == v2; }
659bool operator!= (
const var& v1,
const String& v2) {
return v1.toString() != v2; }
660bool operator== (
const var& v1,
const char* v2) {
return v1.toString() == v2; }
661bool operator!= (
const var& v1,
const char* v2) {
return v1.toString() != v2; }
666 return type->clone (*
this);
672 if (
auto*
o = getDynamicObject())
675 return getNullVarRef();
685 if (
auto*
o = getDynamicObject())
693 if (
auto*
o = getDynamicObject())
701 return isMethod() && (value.methodValue !=
nullptr) ? *value.methodValue :
nullptr;
706 if (
auto*
o = getDynamicObject())
714 return invoke (method,
nullptr, 0);
725 return invoke (method, args, 2);
731 return invoke (method, args, 3);
737 return invoke (method, args, 4);
743 return invoke (method, args, 5);
750 return array->size();
793 convertToArray()->add (n);
799 array->remove (index);
804 convertToArray()->insert (index, n);
815 return array->indexOf (n);
823 type->writeToStream (value, output);
834 case varMarker_Int:
return var (input.
readInt());
836 case varMarker_BoolTrue:
return var (
true);
837 case varMarker_BoolFalse:
return var (
false);
840 case varMarker_String:
844 return var (
mo.toUTF8());
847 case varMarker_Binary:
860 case varMarker_Array:
879var::NativeFunctionArgs::NativeFunctionArgs (
const var& t,
const var* args,
int numArgs) noexcept
880 : thisObject (t), arguments (args), numArguments (
numArgs)
885#if JUCE_ALLOW_STATIC_NULL_VARIABLES
887JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE (
"-Wdeprecated-declarations")
888JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4996)
892JUCE_END_IGNORE_WARNINGS_GCC_LIKE
893JUCE_END_IGNORE_WARNINGS_MSVC
Holds a resizable array of primitive or copy-by-value objects.
void add(const ElementType &newElement)
Appends a new element at the end of the array.
Represents a dynamically implemented object.
Represents a string identifier, designed for accessing properties by name.
A class to hold a resizable block of raw data.
Writes data to an internal memory buffer, which grows as required.
int64 writeFromInputStream(InputStream &, int64 maxNumBytesToWrite) override
Reads data from an input stream and writes it to this stream.
The base class for streams that write data to some kind of destination.
A base class which provides methods for reference-counting.
void incReferenceCount() noexcept
Increments the object's reference count.
bool equalsIgnoreCase(const String &other) const noexcept
Case-insensitive comparison with another string.
String trim() const
Returns a copy of this string with any whitespace characters removed from the start and end.
double getDoubleValue() const noexcept
Parses this string as a floating point number.
static String toHexString(IntegerType number)
Returns a string representing this numeric value in hexadecimal.
static String charToString(juce_wchar character)
Creates a string from a single character.
int64 getLargeIntValue() const noexcept
Reads the value of the string as a decimal number (up to 64 bits in size).
int getIntValue() const noexcept
Reads the value of the string as a decimal number (up to 32 bits in size).
A variant class, that can be used to hold a range of primitive values.
static var undefined() noexcept
Returns a var object that can be used where you need the javascript "undefined" value.
void insert(int index, const var &value)
Inserts an element to the var, converting it to an array if it isn't already one.
int size() const
If the var is an array, this returns the number of elements.
var invoke(const Identifier &method, const var *arguments, int numArguments) const
Invokes a named method call with a list of arguments.
void writeToStream(OutputStream &output) const
Writes a binary representation of this value to a stream.
var() noexcept
Creates a void variant.
~var() noexcept
Destructor.
Array< var > * getArray() const noexcept
If this variant holds an array, this provides access to it.
int indexOf(const var &value) const
If the var is an array, this searches it for the first occurrence of the specified value,...
const var & operator[](int arrayIndex) const
If the var is an array, this can be used to return one of its elements.
NativeFunction getNativeFunction() const
If this object is a method, this returns the function pointer.
bool hasProperty(const Identifier &propertyName) const noexcept
Returns true if this variant is an object and if it has the given property.
static var readFromStream(InputStream &input)
Reads back a stored binary representation of a value.
void append(const var &valueToAppend)
Appends an element to the var, converting it to an array if it isn't already one.
bool equals(const var &other) const noexcept
Returns true if this var has the same value as the one supplied.
bool equalsWithSameType(const var &other) const noexcept
Returns true if this var has the same value and type as the one supplied.
void resize(int numArrayElementsWanted)
Treating the var as an array, this resizes it to contain the specified number of elements.
var getProperty(const Identifier &propertyName, const var &defaultReturnValue) const
If this variant is an object, this returns one of its properties, or a default fallback value if the ...
void remove(int index)
If the var is an array, this removes one of its elements.
var call(const Identifier &method) const
Invokes a named method call with no arguments.
bool hasSameTypeAs(const var &other) const noexcept
Returns true if this var has the same type as the one supplied.
var clone() const noexcept
Returns a deep copy of this object.
MemoryBlock * getBinaryData() const noexcept
If this variant holds a memory block, this provides access to it.
bool operator>(const var &v1, const var &v2)
Compares the values of two var objects, using the var::equals() comparison.
int pointer_sized_int
A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it.
bool operator<=(const var &v1, const var &v2)
Compares the values of two var objects, using the var::equals() comparison.
wchar_t juce_wchar
A platform-independent 32-bit unicode character type.
constexpr bool exactlyEqual(Type a, Type b)
Equivalent to operator==, but suppresses float-equality warnings.
bool operator>=(const var &v1, const var &v2)
Compares the values of two var objects, using the var::equals() comparison.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.
long long int64
A platform-independent 64-bit integer type.
This structure is passed to a NativeFunction callback, and contains invocation details about the func...