| @@ -38,7 +38,7 @@ | |||||
| ranges of values. It's quite a specialised class, mostly useful for things | ranges of values. It's quite a specialised class, mostly useful for things | ||||
| like keeping the set of selected rows in a listbox. | like keeping the set of selected rows in a listbox. | ||||
| The type used as a template paramter must be an integer type, such as int, short, | |||||
| The type used as a template parameter must be an integer type, such as int, short, | |||||
| int64, etc. | int64, etc. | ||||
| */ | */ | ||||
| template <class Type> | template <class Type> | ||||
| @@ -489,6 +489,11 @@ bool var::equalsWithSameType (const var& other) const noexcept | |||||
| return type == other.type && equals (other); | return type == other.type && equals (other); | ||||
| } | } | ||||
| bool var::hasSameTypeAs (const var& other) const noexcept | |||||
| { | |||||
| return type == other.type; | |||||
| } | |||||
| bool operator== (const var& v1, const var& v2) noexcept { return v1.equals (v2); } | bool operator== (const var& v1, const var& v2) noexcept { return v1.equals (v2); } | ||||
| bool operator!= (const var& v1, const var& v2) noexcept { return ! v1.equals (v2); } | bool operator!= (const var& v1, const var& v2) noexcept { return ! v1.equals (v2); } | ||||
| bool operator== (const var& v1, const String& v2) { return v1.toString() == v2; } | bool operator== (const var& v1, const String& v2) { return v1.toString() == v2; } | ||||
| @@ -149,6 +149,9 @@ public: | |||||
| */ | */ | ||||
| bool equalsWithSameType (const var& other) const noexcept; | bool equalsWithSameType (const var& other) const noexcept; | ||||
| /** Returns true if this var has the same type as the one supplied. */ | |||||
| bool hasSameTypeAs (const var& other) const noexcept; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** If the var is an array, this returns the number of elements. | /** If the var is an array, this returns the number of elements. | ||||
| If the var isn't actually an array, this will return 0. | If the var isn't actually an array, this will return 0. | ||||
| @@ -157,6 +157,12 @@ int BigInteger::toInteger() const noexcept | |||||
| return negative ? -n : n; | return negative ? -n : n; | ||||
| } | } | ||||
| int64 BigInteger::toInt64() const noexcept | |||||
| { | |||||
| const int64 n = (((int64) (values[1] & 0x7fffffff)) << 32) | values[0]; | |||||
| return negative ? -n : n; | |||||
| } | |||||
| BigInteger BigInteger::getBitRange (int startBit, int numBits) const | BigInteger BigInteger::getBitRange (int startBit, int numBits) const | ||||
| { | { | ||||
| BigInteger r; | BigInteger r; | ||||
| @@ -94,11 +94,16 @@ public: | |||||
| /** Returns true if the value is 1. */ | /** Returns true if the value is 1. */ | ||||
| bool isOne() const noexcept; | bool isOne() const noexcept; | ||||
| /** Attempts to get the lowest bits of the value as an integer. | |||||
| /** Attempts to get the lowest 32 bits of the value as an integer. | |||||
| If the value is bigger than the integer limits, this will return only the lower bits. | If the value is bigger than the integer limits, this will return only the lower bits. | ||||
| */ | */ | ||||
| int toInteger() const noexcept; | int toInteger() const noexcept; | ||||
| /** Attempts to get the lowest 64 bits of the value as an integer. | |||||
| If the value is bigger than the integer limits, this will return only the lower bits. | |||||
| */ | |||||
| int64 toInt64() const noexcept; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Resets the value to 0. */ | /** Resets the value to 0. */ | ||||
| void clear(); | void clear(); | ||||
| @@ -81,6 +81,11 @@ int Random::nextInt (const int maxValue) noexcept | |||||
| return (int) ((((unsigned int) nextInt()) * (uint64) maxValue) >> 32); | return (int) ((((unsigned int) nextInt()) * (uint64) maxValue) >> 32); | ||||
| } | } | ||||
| int Random::nextInt (Range<int> range) noexcept | |||||
| { | |||||
| return range.getStart() + nextInt (range.getLength()); | |||||
| } | |||||
| int64 Random::nextInt64() noexcept | int64 Random::nextInt64() noexcept | ||||
| { | { | ||||
| return (((int64) nextInt()) << 32) | (int64) (uint64) (uint32) nextInt(); | return (((int64) nextInt()) << 32) | (int64) (uint64) (uint32) nextInt(); | ||||
| @@ -69,6 +69,11 @@ public: | |||||
| */ | */ | ||||
| int nextInt (int maxValue) noexcept; | int nextInt (int maxValue) noexcept; | ||||
| /** Returns the next random number, limited to a given range. | |||||
| @returns a random integer between the range start (inclusive) and its end (exclusive). | |||||
| */ | |||||
| int nextInt (Range<int> range) noexcept; | |||||
| /** Returns the next 64-bit random number. | /** Returns the next 64-bit random number. | ||||
| @returns a random integer from the full range 0x8000000000000000 to 0x7fffffffffffffff | @returns a random integer from the full range 0x8000000000000000 to 0x7fffffffffffffff | ||||
| */ | */ | ||||
| @@ -230,7 +230,7 @@ public: | |||||
| /** Attempts to open a stream that can read from this URL. | /** Attempts to open a stream that can read from this URL. | ||||
| @param usePostCommand if true, it will try to do use a http 'POST' to pass | @param usePostCommand if true, it will try to do use a http 'POST' to pass | ||||
| the paramters, otherwise it'll encode them into the | |||||
| the parameters, otherwise it'll encode them into the | |||||
| URL and do a 'GET'. | URL and do a 'GET'. | ||||
| @param progressCallback if this is non-zero, it lets you supply a callback function | @param progressCallback if this is non-zero, it lets you supply a callback function | ||||
| to keep track of the operation's progress. This can be useful | to keep track of the operation's progress. This can be useful | ||||
| @@ -78,7 +78,7 @@ public: | |||||
| bool setPosition (int64) override; | bool setPosition (int64) override; | ||||
| bool write (const void*, size_t) override; | bool write (const void*, size_t) override; | ||||
| /** These are preset values that can be used for the constructor's windowBits paramter. | |||||
| /** These are preset values that can be used for the constructor's windowBits parameter. | |||||
| For more info about this, see the zlib documentation for its windowBits parameter. | For more info about this, see the zlib documentation for its windowBits parameter. | ||||
| */ | */ | ||||
| enum WindowBitsValues | enum WindowBitsValues | ||||
| @@ -32,7 +32,7 @@ | |||||
| An iOS-specific class that can create and embed an UIView inside itself. | An iOS-specific class that can create and embed an UIView inside itself. | ||||
| To use it, create one of these, put it in place and make sure it's visible in a | To use it, create one of these, put it in place and make sure it's visible in a | ||||
| window, then use setView() to assign an NSView to it. The view will then be | |||||
| window, then use setView() to assign a UIView to it. The view will then be | |||||
| moved and resized to follow the movements of this component. | moved and resized to follow the movements of this component. | ||||
| Of course, since the view is a native object, it'll obliterate any | Of course, since the view is a native object, it'll obliterate any | ||||