| @@ -176,7 +176,7 @@ private: | |||
| if (CharacterFunctions::compareUpTo (CharPointer_ASCII (token), t, len) == 0) | |||
| { | |||
| String::CharPointerType end = t + len; | |||
| auto end = t + len; | |||
| if (end.isEmpty() || end.isWhitespace()) | |||
| { | |||
| @@ -279,7 +279,7 @@ private: | |||
| for (int lineNum = 0; lineNum < lines.size(); ++lineNum) | |||
| { | |||
| String::CharPointerType l = lines[lineNum].getCharPointer().findEndOfWhitespace(); | |||
| auto l = lines[lineNum].getCharPointer().findEndOfWhitespace(); | |||
| if (matchToken (l, "v")) { mesh.vertices.add (parseVertex (l)); continue; } | |||
| if (matchToken (l, "vn")) { mesh.normals.add (parseVertex (l)); continue; } | |||
| @@ -341,7 +341,7 @@ private: | |||
| for (int i = 0; i < lines.size(); ++i) | |||
| { | |||
| String::CharPointerType l (lines[i].getCharPointer().findEndOfWhitespace()); | |||
| auto l = lines[i].getCharPointer().findEndOfWhitespace(); | |||
| if (matchToken (l, "newmtl")) { materials.add (material); material.name = String (l).trim(); continue; } | |||
| @@ -176,7 +176,7 @@ private: | |||
| if (CharacterFunctions::compareUpTo (CharPointer_ASCII (token), t, len) == 0) | |||
| { | |||
| String::CharPointerType end = t + len; | |||
| auto end = t + len; | |||
| if (end.isEmpty() || end.isWhitespace()) | |||
| { | |||
| @@ -279,7 +279,7 @@ private: | |||
| for (int lineNum = 0; lineNum < lines.size(); ++lineNum) | |||
| { | |||
| String::CharPointerType l = lines[lineNum].getCharPointer().findEndOfWhitespace(); | |||
| auto l = lines[lineNum].getCharPointer().findEndOfWhitespace(); | |||
| if (matchToken (l, "v")) { mesh.vertices.add (parseVertex (l)); continue; } | |||
| if (matchToken (l, "vn")) { mesh.normals.add (parseVertex (l)); continue; } | |||
| @@ -341,7 +341,7 @@ private: | |||
| for (int i = 0; i < lines.size(); ++i) | |||
| { | |||
| String::CharPointerType l (lines[i].getCharPointer().findEndOfWhitespace()); | |||
| auto l = lines[i].getCharPointer().findEndOfWhitespace(); | |||
| if (matchToken (l, "newmtl")) { materials.add (material); material.name = String (l).trim(); continue; } | |||
| @@ -476,7 +476,7 @@ struct ClassDatabase | |||
| void add (const Class& c, const String::CharPointerType& localName) | |||
| { | |||
| const String::CharPointerType nextDoubleColon (CharacterFunctions::find (localName, CharPointer_ASCII ("::"))); | |||
| auto nextDoubleColon = CharacterFunctions::find (localName, CharPointer_ASCII ("::")); | |||
| if (nextDoubleColon.isEmpty()) | |||
| merge (c); | |||
| @@ -159,12 +159,12 @@ namespace CodeHelpers | |||
| StringArray lines; | |||
| { | |||
| String::CharPointerType t (text.getCharPointer()); | |||
| auto t = text.getCharPointer(); | |||
| bool finished = t.isEmpty(); | |||
| while (! finished) | |||
| { | |||
| for (String::CharPointerType startOfLine (t);;) | |||
| for (auto startOfLine = t;;) | |||
| { | |||
| switch (t.getAndAdvance()) | |||
| { | |||
| @@ -437,7 +437,7 @@ namespace CodeHelpers | |||
| String getLeadingWhitespace (String line) | |||
| { | |||
| line = line.removeCharacters ("\r\n"); | |||
| const String::CharPointerType endOfLeadingWS (line.getCharPointer().findEndOfWhitespace()); | |||
| auto endOfLeadingWS = line.getCharPointer().findEndOfWhitespace(); | |||
| return String (line.getCharPointer(), endOfLeadingWS); | |||
| } | |||
| @@ -81,7 +81,7 @@ void setValueIfVoid (Value value, const var& defaultValue) | |||
| StringPairArray parsePreprocessorDefs (const String& text) | |||
| { | |||
| StringPairArray result; | |||
| String::CharPointerType s (text.getCharPointer()); | |||
| auto s = text.getCharPointer(); | |||
| while (! s.isEmpty()) | |||
| { | |||
| @@ -136,8 +136,9 @@ String createGCCPreprocessorFlags (const StringPairArray& defs) | |||
| for (int i = 0; i < defs.size(); ++i) | |||
| { | |||
| String def (defs.getAllKeys()[i]); | |||
| const String value (defs.getAllValues()[i]); | |||
| auto def = defs.getAllKeys()[i]; | |||
| auto value = defs.getAllValues()[i]; | |||
| if (value.isNotEmpty()) | |||
| def << "=" << value; | |||
| @@ -38,9 +38,8 @@ struct TranslationHelpers | |||
| static void scanFileForTranslations (StringArray& strings, const File& file) | |||
| { | |||
| const String content (file.loadFileAsString()); | |||
| String::CharPointerType p (content.getCharPointer()); | |||
| auto content = file.loadFileAsString(); | |||
| auto p = content.getCharPointer(); | |||
| for (;;) | |||
| { | |||
| @@ -69,11 +68,11 @@ struct TranslationHelpers | |||
| if (p.getAndAdvance() == '"') | |||
| { | |||
| String::CharPointerType start (p); | |||
| auto start = p; | |||
| for (;;) | |||
| { | |||
| juce_wchar c = *p; | |||
| auto c = *p; | |||
| if (c == '"') | |||
| { | |||
| @@ -101,7 +100,7 @@ struct TranslationHelpers | |||
| static juce_wchar readEscapedChar (String::CharPointerType& p) | |||
| { | |||
| juce_wchar c = *p; | |||
| auto c = *p; | |||
| switch (c) | |||
| { | |||
| @@ -193,8 +193,8 @@ private: | |||
| private: | |||
| String::CharPointerType p; | |||
| static bool isIdentifierStart (const juce_wchar c) noexcept { return CharacterFunctions::isLetter (c) || c == '_'; } | |||
| static bool isIdentifierBody (const juce_wchar c) noexcept { return CharacterFunctions::isLetterOrDigit (c) || c == '_'; } | |||
| static bool isIdentifierStart (juce_wchar c) noexcept { return CharacterFunctions::isLetter (c) || c == '_'; } | |||
| static bool isIdentifierBody (juce_wchar c) noexcept { return CharacterFunctions::isLetterOrDigit (c) || c == '_'; } | |||
| TokenType matchNextToken() | |||
| { | |||
| @@ -245,7 +245,7 @@ private: | |||
| if (*p == '/') | |||
| { | |||
| const juce_wchar c2 = p[1]; | |||
| auto c2 = p[1]; | |||
| if (c2 == '/') { p = CharacterFunctions::find (p, (juce_wchar) '\n'); continue; } | |||
| @@ -111,7 +111,7 @@ public: | |||
| */ | |||
| LinkedListPointer& getLast() noexcept | |||
| { | |||
| LinkedListPointer* l = this; | |||
| auto* l = this; | |||
| while (l->item != nullptr) | |||
| l = &(l->item->nextListItem); | |||
| @@ -127,7 +127,7 @@ public: | |||
| { | |||
| int total = 0; | |||
| for (ObjectType* i = item; i != nullptr; i = i->nextListItem) | |||
| for (auto* i = item; i != nullptr; i = i->nextListItem) | |||
| ++total; | |||
| return total; | |||
| @@ -139,7 +139,7 @@ public: | |||
| */ | |||
| LinkedListPointer& operator[] (int index) noexcept | |||
| { | |||
| LinkedListPointer* l = this; | |||
| auto* l = this; | |||
| while (--index >= 0 && l->item != nullptr) | |||
| l = &(l->item->nextListItem); | |||
| @@ -153,7 +153,7 @@ public: | |||
| */ | |||
| const LinkedListPointer& operator[] (int index) const noexcept | |||
| { | |||
| const LinkedListPointer* l = this; | |||
| auto* l = this; | |||
| while (--index >= 0 && l->item != nullptr) | |||
| l = &(l->item->nextListItem); | |||
| @@ -164,7 +164,7 @@ public: | |||
| /** Returns true if the list contains the given item. */ | |||
| bool contains (const ObjectType* const itemToLookFor) const noexcept | |||
| { | |||
| for (ObjectType* i = item; i != nullptr; i = i->nextListItem) | |||
| for (auto* i = item; i != nullptr; i = i->nextListItem) | |||
| if (itemToLookFor == i) | |||
| return true; | |||
| @@ -190,7 +190,7 @@ public: | |||
| void insertAtIndex (int index, ObjectType* newItem) | |||
| { | |||
| jassert (newItem != nullptr); | |||
| LinkedListPointer* l = this; | |||
| auto* l = this; | |||
| while (index != 0 && l->item != nullptr) | |||
| { | |||
| @@ -209,7 +209,7 @@ public: | |||
| jassert (newItem != nullptr); | |||
| jassert (newItem->nextListItem == nullptr); | |||
| ObjectType* const oldItem = item; | |||
| auto oldItem = item; | |||
| item = newItem; | |||
| item->nextListItem = oldItem->nextListItem.item; | |||
| oldItem->nextListItem.item = nullptr; | |||
| @@ -233,9 +233,9 @@ public: | |||
| */ | |||
| void addCopyOfList (const LinkedListPointer& other) | |||
| { | |||
| LinkedListPointer* insertPoint = this; | |||
| auto* insertPoint = this; | |||
| for (ObjectType* i = other.item; i != nullptr; i = i->nextListItem) | |||
| for (auto* i = other.item; i != nullptr; i = i->nextListItem) | |||
| { | |||
| insertPoint->insertNext (new ObjectType (*i)); | |||
| insertPoint = &(insertPoint->item->nextListItem); | |||
| @@ -248,7 +248,7 @@ public: | |||
| */ | |||
| ObjectType* removeNext() noexcept | |||
| { | |||
| ObjectType* const oldItem = item; | |||
| auto oldItem = item; | |||
| if (oldItem != nullptr) | |||
| { | |||
| @@ -264,7 +264,7 @@ public: | |||
| */ | |||
| void remove (ObjectType* const itemToRemove) | |||
| { | |||
| if (LinkedListPointer* const l = findPointerTo (itemToRemove)) | |||
| if (auto* l = findPointerTo (itemToRemove)) | |||
| l->removeNext(); | |||
| } | |||
| @@ -275,7 +275,7 @@ public: | |||
| { | |||
| while (item != nullptr) | |||
| { | |||
| ObjectType* const oldItem = item; | |||
| auto oldItem = item; | |||
| item = oldItem->nextListItem; | |||
| delete oldItem; | |||
| } | |||
| @@ -287,7 +287,7 @@ public: | |||
| */ | |||
| LinkedListPointer* findPointerTo (ObjectType* const itemToLookFor) noexcept | |||
| { | |||
| LinkedListPointer* l = this; | |||
| auto* l = this; | |||
| while (l->item != nullptr) | |||
| { | |||
| @@ -308,7 +308,7 @@ public: | |||
| { | |||
| jassert (destArray != nullptr); | |||
| for (ObjectType* i = item; i != nullptr; i = i->nextListItem) | |||
| for (auto* i = item; i != nullptr; i = i->nextListItem) | |||
| *destArray++ = i; | |||
| } | |||
| @@ -52,9 +52,7 @@ int findHighestSetBit (uint32 n) noexcept | |||
| //============================================================================== | |||
| BigInteger::BigInteger() | |||
| : allocatedSize (numPreallocatedInts), | |||
| highestBit (-1), | |||
| negative (false) | |||
| : allocatedSize (numPreallocatedInts) | |||
| { | |||
| for (int i = 0; i < numPreallocatedInts; ++i) | |||
| preallocated[i] = 0; | |||
| @@ -75,8 +73,7 @@ BigInteger::BigInteger (const int32 value) | |||
| BigInteger::BigInteger (const uint32 value) | |||
| : allocatedSize (numPreallocatedInts), | |||
| highestBit (31), | |||
| negative (false) | |||
| highestBit (31) | |||
| { | |||
| preallocated[0] = value; | |||
| @@ -153,7 +150,7 @@ BigInteger& BigInteger::operator= (const BigInteger& other) | |||
| if (this != &other) | |||
| { | |||
| highestBit = other.getHighestBit(); | |||
| const size_t newAllocatedSize = (size_t) jmax ((size_t) numPreallocatedInts, sizeNeededToHold (highestBit)); | |||
| auto newAllocatedSize = (size_t) jmax ((size_t) numPreallocatedInts, sizeNeededToHold (highestBit)); | |||
| if (newAllocatedSize <= numPreallocatedInts) | |||
| heapAllocation.free(); | |||
| @@ -181,7 +178,7 @@ uint32* BigInteger::ensureSize (const size_t numVals) | |||
| { | |||
| if (numVals > allocatedSize) | |||
| { | |||
| size_t oldSize = allocatedSize; | |||
| auto oldSize = allocatedSize; | |||
| allocatedSize = ((numVals + 2) * 3) / 2; | |||
| if (heapAllocation == nullptr) | |||
| @@ -193,7 +190,7 @@ uint32* BigInteger::ensureSize (const size_t numVals) | |||
| { | |||
| heapAllocation.realloc (allocatedSize); | |||
| for (uint32* values = getValues(); oldSize < allocatedSize; ++oldSize) | |||
| for (auto* values = getValues(); oldSize < allocatedSize; ++oldSize) | |||
| values[oldSize] = 0; | |||
| } | |||
| } | |||
| @@ -210,14 +207,14 @@ bool BigInteger::operator[] (const int bit) const noexcept | |||
| int BigInteger::toInteger() const noexcept | |||
| { | |||
| const int n = (int) (getValues()[0] & 0x7fffffff); | |||
| auto n = (int) (getValues()[0] & 0x7fffffff); | |||
| return negative ? -n : n; | |||
| } | |||
| int64 BigInteger::toInt64() const noexcept | |||
| { | |||
| const uint32* values = getValues(); | |||
| const int64 n = (((int64) (values[1] & 0x7fffffff)) << 32) | values[0]; | |||
| auto* values = getValues(); | |||
| auto n = (((int64) (values[1] & 0x7fffffff)) << 32) | values[0]; | |||
| return negative ? -n : n; | |||
| } | |||
| @@ -225,7 +222,7 @@ BigInteger BigInteger::getBitRange (int startBit, int numBits) const | |||
| { | |||
| BigInteger r; | |||
| numBits = jmin (numBits, getHighestBit() + 1 - startBit); | |||
| uint32* const destValues = r.ensureSize (sizeNeededToHold (numBits)); | |||
| auto* destValues = r.ensureSize (sizeNeededToHold (numBits)); | |||
| r.highestBit = numBits; | |||
| for (int i = 0; numBits > 0;) | |||
| @@ -252,12 +249,12 @@ uint32 BigInteger::getBitRangeAsInt (const int startBit, int numBits) const noex | |||
| if (numBits <= 0) | |||
| return 0; | |||
| const size_t pos = bitToIndex (startBit); | |||
| const int offset = startBit & 31; | |||
| const int endSpace = 32 - numBits; | |||
| const uint32* values = getValues(); | |||
| auto pos = bitToIndex (startBit); | |||
| auto offset = startBit & 31; | |||
| auto endSpace = 32 - numBits; | |||
| auto* values = getValues(); | |||
| uint32 n = ((uint32) values [pos]) >> offset; | |||
| auto n = ((uint32) values [pos]) >> offset; | |||
| if (offset > endSpace) | |||
| n |= ((uint32) values [pos + 1]) << (32 - offset); | |||
| @@ -372,7 +369,7 @@ void BigInteger::negate() noexcept | |||
| int BigInteger::countNumberOfSetBits() const noexcept | |||
| { | |||
| int total = 0; | |||
| const uint32* values = getValues(); | |||
| auto* values = getValues(); | |||
| for (int i = (int) sizeNeededToHold (highestBit); --i >= 0;) | |||
| total += countNumberOfBits (values[i]); | |||
| @@ -382,7 +379,7 @@ int BigInteger::countNumberOfSetBits() const noexcept | |||
| int BigInteger::getHighestBit() const noexcept | |||
| { | |||
| const uint32* values = getValues(); | |||
| auto* values = getValues(); | |||
| for (int i = (int) bitToIndex (highestBit); i >= 0; --i) | |||
| if (uint32 n = values[i]) | |||
| @@ -393,7 +390,7 @@ int BigInteger::getHighestBit() const noexcept | |||
| int BigInteger::findNextSetBit (int i) const noexcept | |||
| { | |||
| const uint32* values = getValues(); | |||
| auto* values = getValues(); | |||
| for (; i <= highestBit; ++i) | |||
| if ((values [bitToIndex (i)] & bitToMask (i)) != 0) | |||
| @@ -404,7 +401,7 @@ int BigInteger::findNextSetBit (int i) const noexcept | |||
| int BigInteger::findNextClearBit (int i) const noexcept | |||
| { | |||
| const uint32* values = getValues(); | |||
| auto* values = getValues(); | |||
| for (; i <= highestBit; ++i) | |||
| if ((values [bitToIndex (i)] & bitToMask (i)) == 0) | |||
| @@ -426,7 +423,7 @@ BigInteger& BigInteger::operator+= (const BigInteger& other) | |||
| { | |||
| if (compareAbsolute (other) < 0) | |||
| { | |||
| BigInteger temp (*this); | |||
| auto temp = *this; | |||
| temp.negate(); | |||
| *this = other; | |||
| *this -= temp; | |||
| @@ -442,9 +439,9 @@ BigInteger& BigInteger::operator+= (const BigInteger& other) | |||
| { | |||
| highestBit = jmax (highestBit, other.highestBit) + 1; | |||
| const size_t numInts = sizeNeededToHold (highestBit); | |||
| uint32* const values = ensureSize (numInts); | |||
| const uint32* const otherValues = other.getValues(); | |||
| auto numInts = sizeNeededToHold (highestBit); | |||
| auto* values = ensureSize (numInts); | |||
| auto* otherValues = other.getValues(); | |||
| int64 remainder = 0; | |||
| for (size_t i = 0; i < numInts; ++i) | |||
| @@ -486,18 +483,18 @@ BigInteger& BigInteger::operator-= (const BigInteger& other) | |||
| if (compareAbsolute (other) < 0) | |||
| { | |||
| BigInteger temp (other); | |||
| auto temp = other; | |||
| swapWith (temp); | |||
| *this -= temp; | |||
| negate(); | |||
| return *this; | |||
| } | |||
| const size_t numInts = sizeNeededToHold (getHighestBit()); | |||
| const size_t maxOtherInts = sizeNeededToHold (other.getHighestBit()); | |||
| auto numInts = sizeNeededToHold (getHighestBit()); | |||
| auto maxOtherInts = sizeNeededToHold (other.getHighestBit()); | |||
| jassert (numInts >= maxOtherInts); | |||
| uint32* const values = getValues(); | |||
| const uint32* const otherValues = other.getValues(); | |||
| auto* values = getValues(); | |||
| auto* otherValues = other.getValues(); | |||
| int64 amountToSubtract = 0; | |||
| for (size_t i = 0; i < numInts; ++i) | |||
| @@ -527,24 +524,24 @@ BigInteger& BigInteger::operator*= (const BigInteger& other) | |||
| if (this == &other) | |||
| return operator*= (BigInteger (other)); | |||
| int n = getHighestBit(); | |||
| int t = other.getHighestBit(); | |||
| auto n = getHighestBit(); | |||
| auto t = other.getHighestBit(); | |||
| const bool wasNegative = isNegative(); | |||
| auto wasNegative = isNegative(); | |||
| setNegative (false); | |||
| BigInteger total; | |||
| total.highestBit = n + t + 1; | |||
| uint32* const totalValues = total.ensureSize (sizeNeededToHold (total.highestBit) + 1); | |||
| auto* totalValues = total.ensureSize (sizeNeededToHold (total.highestBit) + 1); | |||
| n >>= 5; | |||
| t >>= 5; | |||
| BigInteger m (other); | |||
| auto m = other; | |||
| m.setNegative (false); | |||
| const uint32* const mValues = m.getValues(); | |||
| const uint32* const values = getValues(); | |||
| auto* mValues = m.getValues(); | |||
| auto* values = getValues(); | |||
| for (int i = 0; i <= t; ++i) | |||
| { | |||
| @@ -552,7 +549,7 @@ BigInteger& BigInteger::operator*= (const BigInteger& other) | |||
| for (int j = 0; j <= n; ++j) | |||
| { | |||
| uint64 uv = (uint64) totalValues[i + j] + (uint64) values[j] * (uint64) mValues[i] + (uint64) c; | |||
| auto uv = (uint64) totalValues[i + j] + (uint64) values[j] * (uint64) mValues[i] + (uint64) c; | |||
| totalValues[i + j] = (uint32) uv; | |||
| c = uv >> 32; | |||
| } | |||
| @@ -574,8 +571,8 @@ void BigInteger::divideBy (const BigInteger& divisor, BigInteger& remainder) | |||
| jassert (this != &remainder); // (can't handle passing itself in to get the remainder) | |||
| const int divHB = divisor.getHighestBit(); | |||
| const int ourHB = getHighestBit(); | |||
| auto divHB = divisor.getHighestBit(); | |||
| auto ourHB = getHighestBit(); | |||
| if (divHB < 0 || ourHB < 0) | |||
| { | |||
| @@ -585,7 +582,7 @@ void BigInteger::divideBy (const BigInteger& divisor, BigInteger& remainder) | |||
| } | |||
| else | |||
| { | |||
| const bool wasNegative = isNegative(); | |||
| auto wasNegative = isNegative(); | |||
| swapWith (remainder); | |||
| remainder.setNegative (false); | |||
| @@ -594,7 +591,7 @@ void BigInteger::divideBy (const BigInteger& divisor, BigInteger& remainder) | |||
| BigInteger temp (divisor); | |||
| temp.setNegative (false); | |||
| int leftShift = ourHB - divHB; | |||
| auto leftShift = ourHB - divHB; | |||
| temp <<= leftShift; | |||
| while (leftShift >= 0) | |||
| @@ -631,10 +628,10 @@ BigInteger& BigInteger::operator|= (const BigInteger& other) | |||
| if (other.highestBit >= 0) | |||
| { | |||
| uint32* const values = ensureSize (sizeNeededToHold (other.highestBit)); | |||
| const uint32* const otherValues = other.getValues(); | |||
| auto* values = ensureSize (sizeNeededToHold (other.highestBit)); | |||
| auto* otherValues = other.getValues(); | |||
| int n = (int) bitToIndex (other.highestBit) + 1; | |||
| auto n = (int) bitToIndex (other.highestBit) + 1; | |||
| while (--n >= 0) | |||
| values[n] |= otherValues[n]; | |||
| @@ -656,10 +653,10 @@ BigInteger& BigInteger::operator&= (const BigInteger& other) | |||
| // this operation doesn't take into account negative values.. | |||
| jassert (isNegative() == other.isNegative()); | |||
| uint32* const values = getValues(); | |||
| const uint32* const otherValues = other.getValues(); | |||
| auto* values = getValues(); | |||
| auto* otherValues = other.getValues(); | |||
| int n = (int) allocatedSize; | |||
| auto n = (int) allocatedSize; | |||
| while (n > (int) other.allocatedSize) | |||
| values[--n] = 0; | |||
| @@ -687,10 +684,10 @@ BigInteger& BigInteger::operator^= (const BigInteger& other) | |||
| if (other.highestBit >= 0) | |||
| { | |||
| uint32* const values = ensureSize (sizeNeededToHold (other.highestBit)); | |||
| const uint32* const otherValues = other.getValues(); | |||
| auto* values = ensureSize (sizeNeededToHold (other.highestBit)); | |||
| auto* otherValues = other.getValues(); | |||
| int n = (int) bitToIndex (other.highestBit) + 1; | |||
| auto n = (int) bitToIndex (other.highestBit) + 1; | |||
| while (--n >= 0) | |||
| values[n] ^= otherValues[n]; | |||
| @@ -714,31 +711,31 @@ BigInteger& BigInteger::operator%= (const BigInteger& divisor) | |||
| BigInteger& BigInteger::operator++() { return operator+= (1); } | |||
| BigInteger& BigInteger::operator--() { return operator-= (1); } | |||
| BigInteger BigInteger::operator++ (int) { const BigInteger old (*this); operator+= (1); return old; } | |||
| BigInteger BigInteger::operator-- (int) { const BigInteger old (*this); operator-= (1); return old; } | |||
| BigInteger BigInteger::operator-() const { BigInteger b (*this); b.negate(); return b; } | |||
| BigInteger BigInteger::operator+ (const BigInteger& other) const { BigInteger b (*this); return b += other; } | |||
| BigInteger BigInteger::operator- (const BigInteger& other) const { BigInteger b (*this); return b -= other; } | |||
| BigInteger BigInteger::operator* (const BigInteger& other) const { BigInteger b (*this); return b *= other; } | |||
| BigInteger BigInteger::operator/ (const BigInteger& other) const { BigInteger b (*this); return b /= other; } | |||
| BigInteger BigInteger::operator| (const BigInteger& other) const { BigInteger b (*this); return b |= other; } | |||
| BigInteger BigInteger::operator& (const BigInteger& other) const { BigInteger b (*this); return b &= other; } | |||
| BigInteger BigInteger::operator^ (const BigInteger& other) const { BigInteger b (*this); return b ^= other; } | |||
| BigInteger BigInteger::operator% (const BigInteger& other) const { BigInteger b (*this); return b %= other; } | |||
| BigInteger BigInteger::operator<< (const int numBits) const { BigInteger b (*this); return b <<= numBits; } | |||
| BigInteger BigInteger::operator>> (const int numBits) const { BigInteger b (*this); return b >>= numBits; } | |||
| BigInteger BigInteger::operator++ (int) { const auto old (*this); operator+= (1); return old; } | |||
| BigInteger BigInteger::operator-- (int) { const auto old (*this); operator-= (1); return old; } | |||
| BigInteger BigInteger::operator-() const { auto b (*this); b.negate(); return b; } | |||
| BigInteger BigInteger::operator+ (const BigInteger& other) const { auto b (*this); return b += other; } | |||
| BigInteger BigInteger::operator- (const BigInteger& other) const { auto b (*this); return b -= other; } | |||
| BigInteger BigInteger::operator* (const BigInteger& other) const { auto b (*this); return b *= other; } | |||
| BigInteger BigInteger::operator/ (const BigInteger& other) const { auto b (*this); return b /= other; } | |||
| BigInteger BigInteger::operator| (const BigInteger& other) const { auto b (*this); return b |= other; } | |||
| BigInteger BigInteger::operator& (const BigInteger& other) const { auto b (*this); return b &= other; } | |||
| BigInteger BigInteger::operator^ (const BigInteger& other) const { auto b (*this); return b ^= other; } | |||
| BigInteger BigInteger::operator% (const BigInteger& other) const { auto b (*this); return b %= other; } | |||
| BigInteger BigInteger::operator<< (const int numBits) const { auto b (*this); return b <<= numBits; } | |||
| BigInteger BigInteger::operator>> (const int numBits) const { auto b (*this); return b >>= numBits; } | |||
| BigInteger& BigInteger::operator<<= (const int numBits) { shiftBits (numBits, 0); return *this; } | |||
| BigInteger& BigInteger::operator>>= (const int numBits) { shiftBits (-numBits, 0); return *this; } | |||
| //============================================================================== | |||
| int BigInteger::compare (const BigInteger& other) const noexcept | |||
| { | |||
| const bool isNeg = isNegative(); | |||
| auto isNeg = isNegative(); | |||
| if (isNeg == other.isNegative()) | |||
| { | |||
| const int absComp = compareAbsolute (other); | |||
| auto absComp = compareAbsolute (other); | |||
| return isNeg ? -absComp : absComp; | |||
| } | |||
| @@ -747,14 +744,14 @@ int BigInteger::compare (const BigInteger& other) const noexcept | |||
| int BigInteger::compareAbsolute (const BigInteger& other) const noexcept | |||
| { | |||
| const int h1 = getHighestBit(); | |||
| const int h2 = other.getHighestBit(); | |||
| auto h1 = getHighestBit(); | |||
| auto h2 = other.getHighestBit(); | |||
| if (h1 > h2) return 1; | |||
| if (h1 < h2) return -1; | |||
| const uint32* const values = getValues(); | |||
| const uint32* const otherValues = other.getValues(); | |||
| auto* values = getValues(); | |||
| auto* otherValues = other.getValues(); | |||
| for (int i = (int) bitToIndex (h1); i >= 0; --i) | |||
| if (values[i] != otherValues[i]) | |||
| @@ -783,10 +780,9 @@ void BigInteger::shiftLeft (int bits, const int startBit) | |||
| } | |||
| else | |||
| { | |||
| uint32* const values = ensureSize (sizeNeededToHold (highestBit + bits)); | |||
| const size_t wordsToMove = bitToIndex (bits); | |||
| size_t numOriginalInts = bitToIndex (highestBit); | |||
| auto* values = ensureSize (sizeNeededToHold (highestBit + bits)); | |||
| auto wordsToMove = bitToIndex (bits); | |||
| auto numOriginalInts = bitToIndex (highestBit); | |||
| highestBit += bits; | |||
| if (wordsToMove > 0) | |||
| @@ -802,7 +798,7 @@ void BigInteger::shiftLeft (int bits, const int startBit) | |||
| if (bits != 0) | |||
| { | |||
| const int invBits = 32 - bits; | |||
| auto invBits = 32 - bits; | |||
| for (size_t i = bitToIndex (highestBit); i > wordsToMove; --i) | |||
| values[i] = (values[i] << bits) | (values[i - 1] >> invBits); | |||
| @@ -831,18 +827,17 @@ void BigInteger::shiftRight (int bits, const int startBit) | |||
| } | |||
| else | |||
| { | |||
| const size_t wordsToMove = bitToIndex (bits); | |||
| size_t top = 1 + bitToIndex (highestBit) - wordsToMove; | |||
| auto wordsToMove = bitToIndex (bits); | |||
| auto top = 1 + bitToIndex (highestBit) - wordsToMove; | |||
| highestBit -= bits; | |||
| uint32* const values = getValues(); | |||
| auto* values = getValues(); | |||
| if (wordsToMove > 0) | |||
| { | |||
| size_t i; | |||
| for (i = 0; i < top; ++i) | |||
| for (size_t i = 0; i < top; ++i) | |||
| values[i] = values[i + wordsToMove]; | |||
| for (i = 0; i < wordsToMove; ++i) | |||
| for (size_t i = 0; i < wordsToMove; ++i) | |||
| values[top + i] = 0; | |||
| bits &= 31; | |||
| @@ -850,7 +845,7 @@ void BigInteger::shiftRight (int bits, const int startBit) | |||
| if (bits != 0) | |||
| { | |||
| const int invBits = 32 - bits; | |||
| auto invBits = 32 - bits; | |||
| --top; | |||
| for (size_t i = 0; i < top; ++i) | |||
| @@ -891,7 +886,7 @@ static BigInteger simpleGCD (BigInteger* m, BigInteger* n) | |||
| BigInteger BigInteger::findGreatestCommonDivisor (BigInteger n) const | |||
| { | |||
| BigInteger m (*this); | |||
| auto m = *this; | |||
| while (! n.isZero()) | |||
| { | |||
| @@ -911,14 +906,13 @@ BigInteger BigInteger::findGreatestCommonDivisor (BigInteger n) const | |||
| void BigInteger::exponentModulo (const BigInteger& exponent, const BigInteger& modulus) | |||
| { | |||
| *this %= modulus; | |||
| BigInteger exp (exponent); | |||
| auto exp = exponent; | |||
| exp %= modulus; | |||
| if (modulus.getHighestBit() <= 32 || modulus % 2 == 0) | |||
| { | |||
| BigInteger a (*this); | |||
| const int n = exp.getHighestBit(); | |||
| auto a = *this; | |||
| auto n = exp.getHighestBit(); | |||
| for (int i = n; --i >= 0;) | |||
| { | |||
| @@ -933,7 +927,7 @@ void BigInteger::exponentModulo (const BigInteger& exponent, const BigInteger& m | |||
| } | |||
| else | |||
| { | |||
| const int Rfactor = modulus.getHighestBit() + 1; | |||
| auto Rfactor = modulus.getHighestBit() + 1; | |||
| BigInteger R (1); | |||
| R.shiftLeft (Rfactor, 0); | |||
| @@ -957,9 +951,9 @@ void BigInteger::exponentModulo (const BigInteger& exponent, const BigInteger& m | |||
| } | |||
| else | |||
| { | |||
| BigInteger am (((*this) * R) % modulus); | |||
| BigInteger xm (am); | |||
| BigInteger um (R % modulus); | |||
| auto am = (*this * R) % modulus; | |||
| auto xm = am; | |||
| auto um = R % modulus; | |||
| for (int i = exp.getHighestBit(); --i >= 0;) | |||
| { | |||
| @@ -979,8 +973,7 @@ void BigInteger::montgomeryMultiplication (const BigInteger& other, const BigInt | |||
| const BigInteger& modulusp, const int k) | |||
| { | |||
| *this *= other; | |||
| BigInteger t (*this); | |||
| auto t = *this; | |||
| setRange (k, highestBit - k + 1, false); | |||
| *this *= modulusp; | |||
| @@ -1000,7 +993,6 @@ void BigInteger::extendedEuclidean (const BigInteger& a, const BigInteger& b, | |||
| BigInteger& x, BigInteger& y) | |||
| { | |||
| BigInteger p(a), q(b), gcd(1); | |||
| Array<BigInteger> tempValues; | |||
| while (! q.isZero()) | |||
| @@ -1016,7 +1008,7 @@ void BigInteger::extendedEuclidean (const BigInteger& a, const BigInteger& b, | |||
| for (int i = 1; i < tempValues.size(); ++i) | |||
| { | |||
| const BigInteger& v = tempValues.getReference (tempValues.size() - i - 1); | |||
| auto& v = tempValues.getReference (tempValues.size() - i - 1); | |||
| if ((i & 1) != 0) | |||
| x += y * v; | |||
| @@ -1054,8 +1046,8 @@ void BigInteger::inverseModulo (const BigInteger& modulus) | |||
| return; | |||
| } | |||
| BigInteger a1 (modulus), a2 (*this); | |||
| BigInteger b1 (modulus), b2 (1); | |||
| BigInteger a1 (modulus), a2 (*this), | |||
| b1 (modulus), b2 (1); | |||
| while (! a2.isOne()) | |||
| { | |||
| @@ -1064,7 +1056,7 @@ void BigInteger::inverseModulo (const BigInteger& modulus) | |||
| temp1 = a2; | |||
| temp1 *= multiplier; | |||
| BigInteger temp2 (a1); | |||
| auto temp2 = a1; | |||
| temp2 -= temp1; | |||
| a1 = a2; | |||
| a2 = temp2; | |||
| @@ -1093,17 +1085,16 @@ OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const BigInteger& | |||
| String BigInteger::toString (const int base, const int minimumNumCharacters) const | |||
| { | |||
| String s; | |||
| BigInteger v (*this); | |||
| auto v = *this; | |||
| if (base == 2 || base == 8 || base == 16) | |||
| { | |||
| const int bits = (base == 2) ? 1 : (base == 8 ? 3 : 4); | |||
| auto bits = (base == 2) ? 1 : (base == 8 ? 3 : 4); | |||
| static const char hexDigits[] = "0123456789abcdef"; | |||
| for (;;) | |||
| { | |||
| const uint32 remainder = v.getBitRangeAsInt (0, bits); | |||
| auto remainder = v.getBitRangeAsInt (0, bits); | |||
| v >>= bits; | |||
| if (remainder == 0 && v.isZero()) | |||
| @@ -1141,18 +1132,18 @@ String BigInteger::toString (const int base, const int minimumNumCharacters) con | |||
| void BigInteger::parseString (StringRef text, const int base) | |||
| { | |||
| clear(); | |||
| String::CharPointerType t (text.text.findEndOfWhitespace()); | |||
| auto t = text.text.findEndOfWhitespace(); | |||
| setNegative (*t == (juce_wchar) '-'); | |||
| if (base == 2 || base == 8 || base == 16) | |||
| { | |||
| const int bits = (base == 2) ? 1 : (base == 8 ? 3 : 4); | |||
| auto bits = (base == 2) ? 1 : (base == 8 ? 3 : 4); | |||
| for (;;) | |||
| { | |||
| const juce_wchar c = t.getAndAdvance(); | |||
| const int digit = CharacterFunctions::getHexDigitValue (c); | |||
| auto c = t.getAndAdvance(); | |||
| auto digit = CharacterFunctions::getHexDigitValue (c); | |||
| if (((uint32) digit) < (uint32) base) | |||
| { | |||
| @@ -1171,7 +1162,7 @@ void BigInteger::parseString (StringRef text, const int base) | |||
| for (;;) | |||
| { | |||
| const juce_wchar c = t.getAndAdvance(); | |||
| auto c = t.getAndAdvance(); | |||
| if (c >= '0' && c <= '9') | |||
| { | |||
| @@ -1188,9 +1179,9 @@ void BigInteger::parseString (StringRef text, const int base) | |||
| MemoryBlock BigInteger::toMemoryBlock() const | |||
| { | |||
| const int numBytes = (getHighestBit() + 8) >> 3; | |||
| auto numBytes = (getHighestBit() + 8) >> 3; | |||
| MemoryBlock mb ((size_t) numBytes); | |||
| const uint32* const values = getValues(); | |||
| auto* values = getValues(); | |||
| for (int i = 0; i < numBytes; ++i) | |||
| mb[i] = (char) ((values[i / 4] >> ((i & 3) * 8)) & 0xff); | |||
| @@ -1200,9 +1191,9 @@ MemoryBlock BigInteger::toMemoryBlock() const | |||
| void BigInteger::loadFromMemoryBlock (const MemoryBlock& data) | |||
| { | |||
| const size_t numBytes = data.getSize(); | |||
| const size_t numInts = 1 + (numBytes / sizeof (uint32)); | |||
| uint32* const values = ensureSize (numInts); | |||
| auto numBytes = data.getSize(); | |||
| auto numInts = 1 + (numBytes / sizeof (uint32)); | |||
| auto* values = ensureSize (numInts); | |||
| for (int i = 0; i < (int) numInts - 1; ++i) | |||
| values[i] = (uint32) ByteOrder::littleEndianInt (addBytesToPointer (data.getData(), sizeof (uint32) * (size_t) i)); | |||
| @@ -323,8 +323,8 @@ private: | |||
| HeapBlock<uint32> heapAllocation; | |||
| uint32 preallocated[numPreallocatedInts]; | |||
| size_t allocatedSize; | |||
| int highestBit; | |||
| bool negative; | |||
| int highestBit = -1; | |||
| bool negative = false; | |||
| uint32* getValues() const noexcept; | |||
| uint32* ensureSize (size_t); | |||
| @@ -626,10 +626,10 @@ struct Expression::Helpers | |||
| class SymbolCheckVisitor : public Term::SymbolVisitor | |||
| { | |||
| public: | |||
| SymbolCheckVisitor (const Symbol& symbol_) : wasFound (false), symbol (symbol_) {} | |||
| SymbolCheckVisitor (const Symbol& s) : symbol (s) {} | |||
| void useSymbol (const Symbol& s) { wasFound = wasFound || s == symbol; } | |||
| bool wasFound; | |||
| bool wasFound = false; | |||
| private: | |||
| const Symbol& symbol; | |||
| @@ -725,7 +725,7 @@ struct Expression::Helpers | |||
| bool readIdentifier (String& identifier) noexcept | |||
| { | |||
| text = text.findEndOfWhitespace(); | |||
| String::CharPointerType t (text); | |||
| auto t = text; | |||
| int numChars = 0; | |||
| if (t.isLetter() || *t == '_') | |||
| @@ -753,9 +753,9 @@ struct Expression::Helpers | |||
| Term* readNumber() noexcept | |||
| { | |||
| text = text.findEndOfWhitespace(); | |||
| String::CharPointerType t (text); | |||
| auto t = text; | |||
| bool isResolutionTarget = (*t == '@'); | |||
| const bool isResolutionTarget = (*t == '@'); | |||
| if (isResolutionTarget) | |||
| { | |||
| ++t; | |||
| @@ -968,7 +968,7 @@ Expression& Expression::operator= (Expression&& other) noexcept | |||
| Expression::Expression (const String& stringToParse, String& parseError) | |||
| { | |||
| String::CharPointerType text (stringToParse.getCharPointer()); | |||
| auto text = stringToParse.getCharPointer(); | |||
| Helpers::Parser parser (text); | |||
| term = parser.readUpToComma(); | |||
| parseError = parser.error; | |||
| @@ -26,24 +26,24 @@ namespace juce | |||
| bool Base64::convertToBase64 (OutputStream& base64Result, const void* sourceData, size_t sourceDataSize) | |||
| { | |||
| static const char lookup[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |||
| const uint8* source = static_cast<const uint8*> (sourceData); | |||
| auto* source = static_cast<const uint8*> (sourceData); | |||
| while (sourceDataSize > 0) | |||
| { | |||
| char frame[4]; | |||
| const uint8 byte0 = *source++; | |||
| auto byte0 = *source++; | |||
| frame[0] = lookup [(byte0 & 0xfcu) >> 2]; | |||
| uint32 bits = (byte0 & 0x03u) << 4; | |||
| if (sourceDataSize > 1) | |||
| { | |||
| const uint8 byte1 = *source++; | |||
| auto byte1 = *source++; | |||
| frame[1] = lookup[bits | ((byte1 & 0xf0u) >> 4)]; | |||
| bits = (byte1 & 0x0fu) << 2; | |||
| if (sourceDataSize > 2) | |||
| { | |||
| const uint8 byte2 = *source++; | |||
| auto byte2 = *source++; | |||
| frame[2] = lookup[bits | ((byte2 & 0xc0u) >> 6)]; | |||
| frame[3] = lookup[byte2 & 0x3fu]; | |||
| sourceDataSize -= 3; | |||
| @@ -72,13 +72,13 @@ bool Base64::convertToBase64 (OutputStream& base64Result, const void* sourceData | |||
| bool Base64::convertFromBase64 (OutputStream& binaryOutput, StringRef base64TextInput) | |||
| { | |||
| for (String::CharPointerType s = base64TextInput.text; ! s.isEmpty();) | |||
| for (auto s = base64TextInput.text; ! s.isEmpty();) | |||
| { | |||
| uint8 data[4]; | |||
| for (int i = 0; i < 4; ++i) | |||
| { | |||
| uint32 c = (uint32) s.getAndAdvance(); | |||
| auto c = (uint32) s.getAndAdvance(); | |||
| if (c >= 'A' && c <= 'Z') c -= 'A'; | |||
| else if (c >= 'a' && c <= 'z') c -= 'a' - 26; | |||
| @@ -143,15 +143,15 @@ public: | |||
| { | |||
| beginTest ("Base64"); | |||
| Random r = getRandom(); | |||
| auto r = getRandom(); | |||
| for (int i = 1000; --i >= 0;) | |||
| { | |||
| const MemoryBlock original (createRandomData (r)); | |||
| String asBase64 (Base64::toBase64 (original.getData(), original.getSize())); | |||
| auto original = createRandomData (r); | |||
| auto asBase64 = Base64::toBase64 (original.getData(), original.getSize()); | |||
| MemoryOutputStream out; | |||
| expect (Base64::convertFromBase64 (out, asBase64)); | |||
| MemoryBlock result = out.getMemoryBlock(); | |||
| auto result = out.getMemoryBlock(); | |||
| expect (result == original); | |||
| } | |||
| } | |||
| @@ -450,7 +450,7 @@ public: | |||
| template <typename DestCharPointerType, typename SrcCharPointerType> | |||
| static void copyAll (DestCharPointerType& dest, SrcCharPointerType src) noexcept | |||
| { | |||
| while (juce_wchar c = src.getAndAdvance()) | |||
| while (auto c = src.getAndAdvance()) | |||
| dest.write (c); | |||
| dest.writeNull(); | |||
| @@ -94,11 +94,11 @@ namespace | |||
| static int findCloseQuote (const String& text, int startPos) | |||
| { | |||
| juce_wchar lastChar = 0; | |||
| String::CharPointerType t (text.getCharPointer() + startPos); | |||
| auto t = text.getCharPointer() + startPos; | |||
| for (;;) | |||
| { | |||
| const juce_wchar c = t.getAndAdvance(); | |||
| auto c = t.getAndAdvance(); | |||
| if (c == 0 || (c == '"' && lastChar != '\\')) | |||
| break; | |||
| @@ -127,22 +127,20 @@ void LocalisedStrings::loadFromText (const String& fileContents, bool ignoreCase | |||
| StringArray lines; | |||
| lines.addLines (fileContents); | |||
| for (int i = 0; i < lines.size(); ++i) | |||
| for (auto& l : lines) | |||
| { | |||
| String line (lines[i].trim()); | |||
| auto line = l.trim(); | |||
| if (line.startsWithChar ('"')) | |||
| { | |||
| int closeQuote = findCloseQuote (line, 1); | |||
| const String originalText (unescapeString (line.substring (1, closeQuote))); | |||
| auto closeQuote = findCloseQuote (line, 1); | |||
| auto originalText = unescapeString (line.substring (1, closeQuote)); | |||
| if (originalText.isNotEmpty()) | |||
| { | |||
| const int openingQuote = findCloseQuote (line, closeQuote + 1); | |||
| auto openingQuote = findCloseQuote (line, closeQuote + 1); | |||
| closeQuote = findCloseQuote (line, openingQuote + 1); | |||
| const String newText (unescapeString (line.substring (openingQuote + 1, closeQuote))); | |||
| auto newText = unescapeString (line.substring (openingQuote + 1, closeQuote)); | |||
| if (newText.isNotEmpty()) | |||
| translations.set (originalText, newText); | |||
| @@ -199,7 +197,7 @@ JUCE_API String translate (const String& text, const String& resultIfNotFound) | |||
| { | |||
| const SpinLock::ScopedLockType sl (currentMappingsLock); | |||
| if (const LocalisedStrings* const mappings = LocalisedStrings::getCurrentMappings()) | |||
| if (auto* mappings = LocalisedStrings::getCurrentMappings()) | |||
| return mappings->translate (text, resultIfNotFound); | |||
| return resultIfNotFound; | |||
| @@ -33,7 +33,7 @@ struct TextDiffHelpers | |||
| StringRegion (const String& s) noexcept | |||
| : text (s.getCharPointer()), start (0), length (s.length()) {} | |||
| StringRegion (const String::CharPointerType t, int s, int len) noexcept | |||
| StringRegion (String::CharPointerType t, int s, int len) noexcept | |||
| : text (t), start (s), length (len) {} | |||
| void incrementStart() noexcept { ++text; ++start; --length; } | |||
| @@ -42,7 +42,7 @@ struct TextDiffHelpers | |||
| int start, length; | |||
| }; | |||
| static void addInsertion (TextDiff& td, const String::CharPointerType text, int index, int length) | |||
| static void addInsertion (TextDiff& td, String::CharPointerType text, int index, int length) | |||
| { | |||
| TextDiff::Change c; | |||
| c.insertedText = String (text, (size_t) length); | |||
| @@ -63,8 +63,8 @@ struct TextDiffHelpers | |||
| { | |||
| for (;;) | |||
| { | |||
| const juce_wchar ca = *a.text; | |||
| const juce_wchar cb = *b.text; | |||
| auto ca = *a.text; | |||
| auto cb = *b.text; | |||
| if (ca != cb || ca == 0) | |||
| break; | |||
| @@ -79,8 +79,8 @@ struct TextDiffHelpers | |||
| static void diffRecursively (TextDiff& td, StringRegion a, StringRegion b) | |||
| { | |||
| int indexA = 0, indexB = 0; | |||
| const int len = findLongestCommonSubstring (a.text, a.length, indexA, | |||
| b.text, b.length, indexB); | |||
| auto len = findLongestCommonSubstring (a.text, a.length, indexA, | |||
| b.text, b.length, indexB); | |||
| if (len >= minLengthToMatch) | |||
| { | |||
| @@ -112,11 +112,11 @@ struct TextDiffHelpers | |||
| return findCommonSuffix (a, lenA, indexInA, | |||
| b, lenB, indexInB); | |||
| const size_t scratchSpace = sizeof (int) * (2 + 2 * (size_t) lenB); | |||
| auto scratchSpace = sizeof (int) * (2 + 2 * (size_t) lenB); | |||
| if (scratchSpace < 4096) | |||
| { | |||
| int* scratch = (int*) alloca (scratchSpace); | |||
| auto* scratch = (int*) alloca (scratchSpace); | |||
| return findLongestCommonSubstring (a, lenA, indexInA, b, lenB, indexInB, scratchSpace, scratch); | |||
| } | |||
| @@ -130,16 +130,16 @@ struct TextDiffHelpers | |||
| { | |||
| zeromem (lines, scratchSpace); | |||
| int* l0 = lines; | |||
| int* l1 = l0 + lenB + 1; | |||
| auto* l0 = lines; | |||
| auto* l1 = l0 + lenB + 1; | |||
| int loopsWithoutImprovement = 0; | |||
| int bestLength = 0; | |||
| for (int i = 0; i < lenA; ++i) | |||
| { | |||
| const juce_wchar ca = a.getAndAdvance(); | |||
| String::CharPointerType b2 (b); | |||
| auto ca = a.getAndAdvance(); | |||
| auto b2 = b; | |||
| for (int j = 0; j < lenB; ++j) | |||
| { | |||
| @@ -149,7 +149,7 @@ struct TextDiffHelpers | |||
| } | |||
| else | |||
| { | |||
| const int len = l0[j] + 1; | |||
| auto len = l0[j] + 1; | |||
| l1[j + 1] = len; | |||
| if (len > bestLength) | |||
| @@ -173,8 +173,8 @@ struct TextDiffHelpers | |||
| return bestLength; | |||
| } | |||
| static int findCommonSuffix (String::CharPointerType a, const int lenA, int& indexInA, | |||
| String::CharPointerType b, const int lenB, int& indexInB) noexcept | |||
| static int findCommonSuffix (String::CharPointerType a, int lenA, int& indexInA, | |||
| String::CharPointerType b, int lenB, int& indexInB) noexcept | |||
| { | |||
| int length = 0; | |||
| a += lenA - 1; | |||
| @@ -200,8 +200,8 @@ TextDiff::TextDiff (const String& original, const String& target) | |||
| String TextDiff::appliedTo (String text) const | |||
| { | |||
| for (int i = 0; i < changes.size(); ++i) | |||
| text = changes.getReference(i).appliedTo (text); | |||
| for (auto& c : changes) | |||
| text = c.appliedTo (text); | |||
| return text; | |||
| } | |||
| @@ -249,7 +249,7 @@ public: | |||
| void testDiff (const String& a, const String& b) | |||
| { | |||
| TextDiff diff (a, b); | |||
| const String result (diff.appliedTo (a)); | |||
| auto result = diff.appliedTo (a); | |||
| expectEquals (result, b); | |||
| } | |||
| @@ -257,7 +257,7 @@ public: | |||
| { | |||
| beginTest ("TextDiff"); | |||
| Random r = getRandom(); | |||
| auto r = getRandom(); | |||
| testDiff (String(), String()); | |||
| testDiff ("x", String()); | |||
| @@ -269,7 +269,7 @@ public: | |||
| for (int i = 1000; --i >= 0;) | |||
| { | |||
| String s (createString (r)); | |||
| auto s = createString (r); | |||
| testDiff (s, createString (r)); | |||
| testDiff (s + createString (r), s + createString (r)); | |||
| } | |||
| @@ -28,7 +28,7 @@ namespace TimeHelpers | |||
| static std::tm millisToLocal (int64 millis) noexcept | |||
| { | |||
| #if JUCE_WINDOWS && JUCE_MINGW | |||
| time_t now = (time_t) (millis / 1000); | |||
| auto now = (time_t) (millis / 1000); | |||
| return *localtime (&now); | |||
| #elif JUCE_WINDOWS | |||
| @@ -42,7 +42,7 @@ namespace TimeHelpers | |||
| #else | |||
| std::tm result; | |||
| time_t now = (time_t) (millis / 1000); | |||
| auto now = (time_t) (millis / 1000); | |||
| if (localtime_r (&now, &result) == nullptr) | |||
| zerostruct (result); | |||
| @@ -54,7 +54,7 @@ namespace TimeHelpers | |||
| static std::tm millisToUTC (int64 millis) noexcept | |||
| { | |||
| #if JUCE_WINDOWS && JUCE_MINGW | |||
| time_t now = (time_t) (millis / 1000); | |||
| auto now = (time_t) (millis / 1000); | |||
| return *gmtime (&now); | |||
| #elif JUCE_WINDOWS | |||
| @@ -68,7 +68,7 @@ namespace TimeHelpers | |||
| #else | |||
| std::tm result; | |||
| time_t now = (time_t) (millis / 1000); | |||
| auto now = (time_t) (millis / 1000); | |||
| if (gmtime_r (&now, &result) == nullptr) | |||
| zerostruct (result); | |||
| @@ -79,7 +79,7 @@ namespace TimeHelpers | |||
| static int getUTCOffsetSeconds (const int64 millis) noexcept | |||
| { | |||
| std::tm utc = millisToUTC (millis); | |||
| auto utc = millisToUTC (millis); | |||
| utc.tm_isdst = -1; // Treat this UTC time as local to find the offset | |||
| return (int) ((millis / 1000) - (int64) mktime (&utc)); | |||
| @@ -110,14 +110,14 @@ namespace TimeHelpers | |||
| { | |||
| HeapBlock<StringType::CharType> buffer (bufferSize); | |||
| const size_t numChars = | |||
| #if JUCE_ANDROID | |||
| strftime (buffer, bufferSize - 1, format.toUTF8(), tm); | |||
| #elif JUCE_WINDOWS | |||
| wcsftime (buffer, bufferSize - 1, format.toWideCharPointer(), tm); | |||
| #else | |||
| wcsftime (buffer, bufferSize - 1, format.toUTF32(), tm); | |||
| #endif | |||
| auto numChars = | |||
| #if JUCE_ANDROID | |||
| strftime (buffer, bufferSize - 1, format.toUTF8(), tm); | |||
| #elif JUCE_WINDOWS | |||
| wcsftime (buffer, bufferSize - 1, format.toWideCharPointer(), tm); | |||
| #else | |||
| wcsftime (buffer, bufferSize - 1, format.toUTF32(), tm); | |||
| #endif | |||
| if (numChars > 0 || format.isEmpty()) | |||
| return String (StringType (buffer), | |||
| @@ -189,18 +189,13 @@ Time::Time (const Time& other) noexcept : millisSinceEpoch (other.millisSinceEp | |||
| { | |||
| } | |||
| Time::Time (const int64 ms) noexcept : millisSinceEpoch (ms) | |||
| Time::Time (int64 ms) noexcept : millisSinceEpoch (ms) | |||
| { | |||
| } | |||
| Time::Time (const int year, | |||
| const int month, | |||
| const int day, | |||
| const int hours, | |||
| const int minutes, | |||
| const int seconds, | |||
| const int milliseconds, | |||
| const bool useLocalTime) noexcept | |||
| Time::Time (int year, int month, int day, | |||
| int hours, int minutes, int seconds, int milliseconds, | |||
| bool useLocalTime) noexcept | |||
| { | |||
| std::tm t; | |||
| t.tm_year = year - 1900; | |||
| @@ -250,7 +245,7 @@ uint32 juce_millisecondsSinceStartup() noexcept; | |||
| uint32 Time::getMillisecondCounter() noexcept | |||
| { | |||
| const uint32 now = juce_millisecondsSinceStartup(); | |||
| auto now = juce_millisecondsSinceStartup(); | |||
| if (now < TimeHelpers::lastMSCounterValue) | |||
| { | |||
| @@ -276,16 +271,16 @@ uint32 Time::getApproximateMillisecondCounter() noexcept | |||
| return TimeHelpers::lastMSCounterValue; | |||
| } | |||
| void Time::waitForMillisecondCounter (const uint32 targetTime) noexcept | |||
| void Time::waitForMillisecondCounter (uint32 targetTime) noexcept | |||
| { | |||
| for (;;) | |||
| { | |||
| const uint32 now = getMillisecondCounter(); | |||
| auto now = getMillisecondCounter(); | |||
| if (now >= targetTime) | |||
| break; | |||
| const int toWait = (int) (targetTime - now); | |||
| auto toWait = (int) (targetTime - now); | |||
| if (toWait > 2) | |||
| { | |||
| @@ -332,14 +327,14 @@ String Time::toString (const bool includeDate, | |||
| if (includeTime) | |||
| { | |||
| const int mins = getMinutes(); | |||
| auto mins = getMinutes(); | |||
| result << (use24HourClock ? getHours() : getHoursInAmPmFormat()) | |||
| << (mins < 10 ? ":0" : ":") << mins; | |||
| if (includeSeconds) | |||
| { | |||
| const int secs = getSeconds(); | |||
| auto secs = getSeconds(); | |||
| result << (secs < 10 ? ":0" : ":") << secs; | |||
| } | |||
| @@ -369,7 +364,7 @@ int Time::getMilliseconds() const noexcept { return TimeHelpers::extendedModulo | |||
| int Time::getHoursInAmPmFormat() const noexcept | |||
| { | |||
| const int hours = getHours(); | |||
| auto hours = getHours(); | |||
| if (hours == 0) return 12; | |||
| if (hours <= 12) return hours; | |||
| @@ -408,7 +403,7 @@ String Time::getTimeZone() const noexcept | |||
| #else | |||
| tzset(); | |||
| const char** const zonePtr = (const char**) tzname; | |||
| auto zonePtr = (const char**) tzname; | |||
| zone[0] = zonePtr[0]; | |||
| zone[1] = zonePtr[1]; | |||
| #endif | |||
| @@ -482,17 +477,19 @@ static int parseFixedSizeIntAndSkip (String::CharPointerType& t, int numChars, c | |||
| Time Time::fromISO8601 (StringRef iso) noexcept | |||
| { | |||
| String::CharPointerType t = iso.text; | |||
| auto t = iso.text; | |||
| auto year = parseFixedSizeIntAndSkip (t, 4, '-'); | |||
| const int year = parseFixedSizeIntAndSkip (t, 4, '-'); | |||
| if (year < 0) | |||
| return {}; | |||
| const int month = parseFixedSizeIntAndSkip (t, 2, '-'); | |||
| auto month = parseFixedSizeIntAndSkip (t, 2, '-'); | |||
| if (month < 0) | |||
| return {}; | |||
| const int day = parseFixedSizeIntAndSkip (t, 2, 0); | |||
| auto day = parseFixedSizeIntAndSkip (t, 2, 0); | |||
| if (day < 0) | |||
| return {}; | |||
| @@ -502,14 +499,17 @@ Time Time::fromISO8601 (StringRef iso) noexcept | |||
| { | |||
| ++t; | |||
| hours = parseFixedSizeIntAndSkip (t, 2, ':'); | |||
| if (hours < 0) | |||
| return {}; | |||
| minutes = parseFixedSizeIntAndSkip (t, 2, ':'); | |||
| if (minutes < 0) | |||
| return {}; | |||
| auto seconds = parseFixedSizeIntAndSkip (t, 2, 0); | |||
| if (seconds < 0) | |||
| return {}; | |||
| @@ -517,6 +517,7 @@ Time Time::fromISO8601 (StringRef iso) noexcept | |||
| { | |||
| ++t; | |||
| milliseconds = parseFixedSizeIntAndSkip (t, 3, 0); | |||
| if (milliseconds < 0) | |||
| return {}; | |||
| } | |||
| @@ -524,19 +525,21 @@ Time Time::fromISO8601 (StringRef iso) noexcept | |||
| milliseconds += 1000 * seconds; | |||
| } | |||
| const juce_wchar nextChar = t.getAndAdvance(); | |||
| auto nextChar = t.getAndAdvance(); | |||
| if (nextChar == '-' || nextChar == '+') | |||
| { | |||
| const int offsetHours = parseFixedSizeIntAndSkip (t, 2, ':'); | |||
| auto offsetHours = parseFixedSizeIntAndSkip (t, 2, ':'); | |||
| if (offsetHours < 0) | |||
| return {}; | |||
| const int offsetMinutes = parseFixedSizeIntAndSkip (t, 2, 0); | |||
| auto offsetMinutes = parseFixedSizeIntAndSkip (t, 2, 0); | |||
| if (offsetMinutes < 0) | |||
| return {}; | |||
| const int offsetMs = (offsetHours * 60 + offsetMinutes) * 60 * 1000; | |||
| auto offsetMs = (offsetHours * 60 + offsetMinutes) * 60 * 1000; | |||
| milliseconds += nextChar == '-' ? offsetMs : -offsetMs; // NB: this seems backwards but is correct! | |||
| } | |||
| else if (nextChar != 0 && nextChar != 'Z') | |||
| @@ -212,11 +212,11 @@ namespace XmlOutputFunctions | |||
| static void escapeIllegalXmlChars (OutputStream& outputStream, const String& text, const bool changeNewLines) | |||
| { | |||
| String::CharPointerType t (text.getCharPointer()); | |||
| auto t = text.getCharPointer(); | |||
| for (;;) | |||
| { | |||
| const uint32 character = (uint32) t.getAndAdvance(); | |||
| auto character = (uint32) t.getAndAdvance(); | |||
| if (character == 0) | |||
| break; | |||
| @@ -229,22 +229,22 @@ namespace XmlOutputFunctions | |||
| { | |||
| switch (character) | |||
| { | |||
| case '&': outputStream << "&"; break; | |||
| case '"': outputStream << """; break; | |||
| case '>': outputStream << ">"; break; | |||
| case '<': outputStream << "<"; break; | |||
| case '\n': | |||
| case '\r': | |||
| if (! changeNewLines) | |||
| { | |||
| outputStream << (char) character; | |||
| case '&': outputStream << "&"; break; | |||
| case '"': outputStream << """; break; | |||
| case '>': outputStream << ">"; break; | |||
| case '<': outputStream << "<"; break; | |||
| case '\n': | |||
| case '\r': | |||
| if (! changeNewLines) | |||
| { | |||
| outputStream << (char) character; | |||
| break; | |||
| } | |||
| // Note: deliberate fall-through here! | |||
| default: | |||
| outputStream << "&#" << ((int) character) << ';'; | |||
| break; | |||
| } | |||
| // Note: deliberate fall-through here! | |||
| default: | |||
| outputStream << "&#" << ((int) character) << ';'; | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| @@ -271,10 +271,10 @@ void XmlElement::writeElementAsText (OutputStream& outputStream, | |||
| outputStream << tagName; | |||
| { | |||
| const size_t attIndent = (size_t) (indentationLevel + tagName.length() + 1); | |||
| auto attIndent = (size_t) (indentationLevel + tagName.length() + 1); | |||
| int lineLen = 0; | |||
| for (const XmlAttributeNode* att = attributes; att != nullptr; att = att->nextListItem) | |||
| for (auto* att = attributes.get(); att != nullptr; att = att->nextListItem) | |||
| { | |||
| if (lineLen > lineWrapLength && indentationLevel >= 0) | |||
| { | |||
| @@ -283,7 +283,7 @@ void XmlElement::writeElementAsText (OutputStream& outputStream, | |||
| lineLen = 0; | |||
| } | |||
| const int64 startPos = outputStream.getPosition(); | |||
| auto startPos = outputStream.getPosition(); | |||
| outputStream.writeByte (' '); | |||
| outputStream << att->name; | |||
| outputStream.write ("=\"", 2); | |||
| @@ -293,13 +293,12 @@ void XmlElement::writeElementAsText (OutputStream& outputStream, | |||
| } | |||
| } | |||
| if (firstChildElement != nullptr) | |||
| if (auto* child = firstChildElement.get()) | |||
| { | |||
| outputStream.writeByte ('>'); | |||
| bool lastWasTextNode = false; | |||
| for (XmlElement* child = firstChildElement; child != nullptr; child = child->nextListItem) | |||
| for (; child != nullptr; child = child->nextListItem) | |||
| { | |||
| if (child->isTextElement()) | |||
| { | |||
| @@ -350,12 +349,9 @@ String XmlElement::createDocument (StringRef dtdToUse, | |||
| return mem.toUTF8(); | |||
| } | |||
| void XmlElement::writeToStream (OutputStream& output, | |||
| StringRef dtdToUse, | |||
| const bool allOnOneLine, | |||
| const bool includeXmlHeader, | |||
| StringRef encodingType, | |||
| const int lineWrapLength) const | |||
| void XmlElement::writeToStream (OutputStream& output, StringRef dtdToUse, | |||
| bool allOnOneLine, bool includeXmlHeader, | |||
| StringRef encodingType, int lineWrapLength) const | |||
| { | |||
| using namespace XmlOutputFunctions; | |||
| @@ -385,10 +381,8 @@ void XmlElement::writeToStream (OutputStream& output, | |||
| output << newLine; | |||
| } | |||
| bool XmlElement::writeToFile (const File& file, | |||
| StringRef dtdToUse, | |||
| StringRef encodingType, | |||
| const int lineWrapLength) const | |||
| bool XmlElement::writeToFile (const File& file, StringRef dtdToUse, | |||
| StringRef encodingType, int lineWrapLength) const | |||
| { | |||
| TemporaryFile tempFile (file); | |||
| @@ -399,7 +393,6 @@ bool XmlElement::writeToFile (const File& file, | |||
| return false; | |||
| writeToStream (out, dtdToUse, false, true, encodingType, lineWrapLength); | |||
| out.flush(); // (called explicitly to force an fsync on posix) | |||
| if (out.getStatus().failed()) | |||
| @@ -438,7 +431,7 @@ bool XmlElement::hasTagNameIgnoringNamespace (StringRef possibleTagName) const | |||
| XmlElement* XmlElement::getNextElementWithTagName (StringRef requiredTagName) const | |||
| { | |||
| XmlElement* e = nextListItem; | |||
| auto* e = nextListItem.get(); | |||
| while (e != nullptr && ! e->hasTagName (requiredTagName)) | |||
| e = e->nextListItem; | |||
| @@ -464,7 +457,7 @@ static const String& getEmptyStringRef() noexcept | |||
| const String& XmlElement::getAttributeName (const int index) const noexcept | |||
| { | |||
| if (const XmlAttributeNode* const att = attributes [index]) | |||
| if (auto* att = attributes[index].get()) | |||
| return att->name.toString(); | |||
| return getEmptyStringRef(); | |||
| @@ -472,7 +465,7 @@ const String& XmlElement::getAttributeName (const int index) const noexcept | |||
| const String& XmlElement::getAttributeValue (const int index) const noexcept | |||
| { | |||
| if (const XmlAttributeNode* const att = attributes [index]) | |||
| if (auto* att = attributes[index].get()) | |||
| return att->value; | |||
| return getEmptyStringRef(); | |||
| @@ -480,7 +473,7 @@ const String& XmlElement::getAttributeValue (const int index) const noexcept | |||
| XmlElement::XmlAttributeNode* XmlElement::getAttribute (StringRef attributeName) const noexcept | |||
| { | |||
| for (XmlAttributeNode* att = attributes; att != nullptr; att = att->nextListItem) | |||
| for (auto* att = attributes.get(); att != nullptr; att = att->nextListItem) | |||
| if (att->name == attributeName) | |||
| return att; | |||
| @@ -495,7 +488,7 @@ bool XmlElement::hasAttribute (StringRef attributeName) const noexcept | |||
| //============================================================================== | |||
| const String& XmlElement::getStringAttribute (StringRef attributeName) const noexcept | |||
| { | |||
| if (const XmlAttributeNode* att = getAttribute (attributeName)) | |||
| if (auto* att = getAttribute (attributeName)) | |||
| return att->value; | |||
| return getEmptyStringRef(); | |||
| @@ -503,7 +496,7 @@ const String& XmlElement::getStringAttribute (StringRef attributeName) const noe | |||
| String XmlElement::getStringAttribute (StringRef attributeName, const String& defaultReturnValue) const | |||
| { | |||
| if (const XmlAttributeNode* att = getAttribute (attributeName)) | |||
| if (auto* att = getAttribute (attributeName)) | |||
| return att->value; | |||
| return defaultReturnValue; | |||
| @@ -511,7 +504,7 @@ String XmlElement::getStringAttribute (StringRef attributeName, const String& de | |||
| int XmlElement::getIntAttribute (StringRef attributeName, const int defaultReturnValue) const | |||
| { | |||
| if (const XmlAttributeNode* att = getAttribute (attributeName)) | |||
| if (auto* att = getAttribute (attributeName)) | |||
| return att->value.getIntValue(); | |||
| return defaultReturnValue; | |||
| @@ -519,7 +512,7 @@ int XmlElement::getIntAttribute (StringRef attributeName, const int defaultRetur | |||
| double XmlElement::getDoubleAttribute (StringRef attributeName, const double defaultReturnValue) const | |||
| { | |||
| if (const XmlAttributeNode* att = getAttribute (attributeName)) | |||
| if (auto* att = getAttribute (attributeName)) | |||
| return att->value.getDoubleValue(); | |||
| return defaultReturnValue; | |||
| @@ -527,9 +520,9 @@ double XmlElement::getDoubleAttribute (StringRef attributeName, const double def | |||
| bool XmlElement::getBoolAttribute (StringRef attributeName, const bool defaultReturnValue) const | |||
| { | |||
| if (const XmlAttributeNode* att = getAttribute (attributeName)) | |||
| if (auto* att = getAttribute (attributeName)) | |||
| { | |||
| const juce_wchar firstChar = *(att->value.getCharPointer().findEndOfWhitespace()); | |||
| auto firstChar = *(att->value.getCharPointer().findEndOfWhitespace()); | |||
| return firstChar == '1' | |||
| || firstChar == 't' | |||
| @@ -545,7 +538,7 @@ bool XmlElement::compareAttribute (StringRef attributeName, | |||
| StringRef stringToCompareAgainst, | |||
| const bool ignoreCase) const noexcept | |||
| { | |||
| if (const XmlAttributeNode* att = getAttribute (attributeName)) | |||
| if (auto* att = getAttribute (attributeName)) | |||
| return ignoreCase ? att->value.equalsIgnoreCase (stringToCompareAgainst) | |||
| : att->value == stringToCompareAgainst; | |||
| @@ -561,7 +554,7 @@ void XmlElement::setAttribute (const Identifier& attributeName, const String& va | |||
| } | |||
| else | |||
| { | |||
| for (XmlAttributeNode* att = attributes; ; att = att->nextListItem) | |||
| for (auto* att = attributes.get(); ; att = att->nextListItem) | |||
| { | |||
| if (att->name == attributeName) | |||
| { | |||
| @@ -590,9 +583,7 @@ void XmlElement::setAttribute (const Identifier& attributeName, const double num | |||
| void XmlElement::removeAttribute (const Identifier& attributeName) noexcept | |||
| { | |||
| for (LinkedListPointer<XmlAttributeNode>* att = &attributes; | |||
| att->get() != nullptr; | |||
| att = &(att->get()->nextListItem)) | |||
| for (auto* att = &attributes; att->get() != nullptr; att = &(att->get()->nextListItem)) | |||
| { | |||
| if (att->get()->name == attributeName) | |||
| { | |||
| @@ -622,7 +613,7 @@ XmlElement* XmlElement::getChildByName (StringRef childName) const noexcept | |||
| { | |||
| jassert (! childName.isEmpty()); | |||
| for (XmlElement* child = firstChildElement; child != nullptr; child = child->nextListItem) | |||
| for (auto* child = firstChildElement.get(); child != nullptr; child = child->nextListItem) | |||
| if (child->hasTagName (childName)) | |||
| return child; | |||
| @@ -633,7 +624,7 @@ XmlElement* XmlElement::getChildByAttribute (StringRef attributeName, StringRef | |||
| { | |||
| jassert (! attributeName.isEmpty()); | |||
| for (XmlElement* child = firstChildElement; child != nullptr; child = child->nextListItem) | |||
| for (auto* child = firstChildElement.get(); child != nullptr; child = child->nextListItem) | |||
| if (child->compareAttribute (attributeName, attributeValue)) | |||
| return child; | |||
| @@ -675,7 +666,7 @@ void XmlElement::prependChildElement (XmlElement* newNode) noexcept | |||
| XmlElement* XmlElement::createNewChildElement (StringRef childTagName) | |||
| { | |||
| XmlElement* const newElement = new XmlElement (childTagName); | |||
| auto newElement = new XmlElement (childTagName); | |||
| addChildElement (newElement); | |||
| return newElement; | |||
| } | |||
| @@ -685,7 +676,7 @@ bool XmlElement::replaceChildElement (XmlElement* const currentChildElement, | |||
| { | |||
| if (newNode != nullptr) | |||
| { | |||
| if (LinkedListPointer<XmlElement>* const p = firstChildElement.findPointerTo (currentChildElement)) | |||
| if (auto* p = firstChildElement.findPointerTo (currentChildElement)) | |||
| { | |||
| if (currentChildElement != newNode) | |||
| delete p->replaceNext (newNode); | |||
| @@ -721,7 +712,7 @@ bool XmlElement::isEquivalentTo (const XmlElement* const other, | |||
| { | |||
| int totalAtts = 0; | |||
| for (const XmlAttributeNode* att = attributes; att != nullptr; att = att->nextListItem) | |||
| for (auto* att = attributes.get(); att != nullptr; att = att->nextListItem) | |||
| { | |||
| if (! other->compareAttribute (att->name, att->value)) | |||
| return false; | |||
| @@ -734,8 +725,8 @@ bool XmlElement::isEquivalentTo (const XmlElement* const other, | |||
| } | |||
| else | |||
| { | |||
| const XmlAttributeNode* thisAtt = attributes; | |||
| const XmlAttributeNode* otherAtt = other->attributes; | |||
| auto* thisAtt = attributes.get(); | |||
| auto* otherAtt = other->attributes.get(); | |||
| for (;;) | |||
| { | |||
| @@ -758,8 +749,8 @@ bool XmlElement::isEquivalentTo (const XmlElement* const other, | |||
| } | |||
| } | |||
| const XmlElement* thisChild = firstChildElement; | |||
| const XmlElement* otherChild = other->firstChildElement; | |||
| auto* thisChild = firstChildElement.get(); | |||
| auto* otherChild = other->firstChildElement.get(); | |||
| for (;;) | |||
| { | |||
| @@ -789,9 +780,9 @@ void XmlElement::deleteAllChildElements() noexcept | |||
| void XmlElement::deleteAllChildElementsWithTagName (StringRef name) noexcept | |||
| { | |||
| for (XmlElement* child = firstChildElement; child != nullptr;) | |||
| for (auto* child = firstChildElement.get(); child != nullptr;) | |||
| { | |||
| XmlElement* const nextChild = child->nextListItem; | |||
| auto* nextChild = child->nextListItem.get(); | |||
| if (child->hasTagName (name)) | |||
| removeChildElement (child, true); | |||
| @@ -810,12 +801,12 @@ XmlElement* XmlElement::findParentElementOf (const XmlElement* const elementToLo | |||
| if (this == elementToLookFor || elementToLookFor == nullptr) | |||
| return nullptr; | |||
| for (XmlElement* child = firstChildElement; child != nullptr; child = child->nextListItem) | |||
| for (auto* child = firstChildElement.get(); child != nullptr; child = child->nextListItem) | |||
| { | |||
| if (elementToLookFor == child) | |||
| return this; | |||
| if (XmlElement* const found = child->findParentElementOf (elementToLookFor)) | |||
| if (auto* found = child->findParentElementOf (elementToLookFor)) | |||
| return found; | |||
| } | |||
| @@ -827,9 +818,10 @@ void XmlElement::getChildElementsAsArray (XmlElement** elems) const noexcept | |||
| firstChildElement.copyToArray (elems); | |||
| } | |||
| void XmlElement::reorderChildElements (XmlElement** const elems, const int num) noexcept | |||
| void XmlElement::reorderChildElements (XmlElement** elems, int num) noexcept | |||
| { | |||
| XmlElement* e = firstChildElement = elems[0]; | |||
| auto* e = elems[0]; | |||
| firstChildElement = e; | |||
| for (int i = 1; i < num; ++i) | |||
| { | |||
| @@ -875,7 +867,7 @@ String XmlElement::getAllSubText() const | |||
| MemoryOutputStream mem (1024); | |||
| for (const XmlElement* child = firstChildElement; child != nullptr; child = child->nextListItem) | |||
| for (auto* child = firstChildElement.get(); child != nullptr; child = child->nextListItem) | |||
| mem << child->getAllSubText(); | |||
| return mem.toUTF8(); | |||
| @@ -883,7 +875,7 @@ String XmlElement::getAllSubText() const | |||
| String XmlElement::getChildElementAllSubText (StringRef childTagName, const String& defaultReturnValue) const | |||
| { | |||
| if (const XmlElement* const child = getChildByName (childTagName)) | |||
| if (auto* child = getChildByName (childTagName)) | |||
| return child->getAllSubText(); | |||
| return defaultReturnValue; | |||
| @@ -891,7 +883,7 @@ String XmlElement::getChildElementAllSubText (StringRef childTagName, const Stri | |||
| XmlElement* XmlElement::createTextElement (const String& text) | |||
| { | |||
| XmlElement* const e = new XmlElement ((int) 0); | |||
| auto e = new XmlElement ((int) 0); | |||
| e->setAttribute (juce_xmltextContentAttributeName, text); | |||
| return e; | |||
| } | |||
| @@ -918,9 +910,9 @@ void XmlElement::addTextElement (const String& text) | |||
| void XmlElement::deleteAllTextElements() noexcept | |||
| { | |||
| for (XmlElement* child = firstChildElement; child != nullptr;) | |||
| for (auto* child = firstChildElement.get(); child != nullptr;) | |||
| { | |||
| XmlElement* const next = child->nextListItem; | |||
| auto* next = child->nextListItem.get(); | |||
| if (child->isTextElement()) | |||
| removeChildElement (child, true); | |||
| @@ -229,11 +229,11 @@ MD5::MD5 (CharPointer_UTF8 utf8) noexcept | |||
| MD5 MD5::fromUTF32 (StringRef text) | |||
| { | |||
| MD5Generator generator; | |||
| String::CharPointerType t (text.text); | |||
| auto t = text.text; | |||
| while (! t.isEmpty()) | |||
| { | |||
| uint32 unicodeChar = ByteOrder::swapIfBigEndian ((uint32) t.getAndAdvance()); | |||
| auto unicodeChar = ByteOrder::swapIfBigEndian ((uint32) t.getAndAdvance()); | |||
| generator.processBlock (&unicodeChar, sizeof (unicodeChar)); | |||
| } | |||
| @@ -276,7 +276,7 @@ void MD5::processStream (InputStream& input, int64 numBytesToRead) | |||
| while (numBytesToRead > 0) | |||
| { | |||
| uint8 tempBuffer [512]; | |||
| const int bytesRead = input.read (tempBuffer, (int) jmin (numBytesToRead, (int64) sizeof (tempBuffer))); | |||
| auto bytesRead = input.read (tempBuffer, (int) jmin (numBytesToRead, (int64) sizeof (tempBuffer))); | |||
| if (bytesRead <= 0) | |||
| break; | |||
| @@ -235,7 +235,7 @@ public: | |||
| env->GetFloatArrayRegion (widths, 0, numDone, localWidths); | |||
| env->DeleteLocalRef (widths); | |||
| String::CharPointerType s (text.getCharPointer()); | |||
| auto s = text.getCharPointer(); | |||
| xOffsets.add (0); | |||
| @@ -1265,10 +1265,10 @@ private: | |||
| if (len > 2) | |||
| { | |||
| const float dpi = 96.0f; | |||
| auto dpi = 96.0f; | |||
| const juce_wchar n1 = s [len - 2]; | |||
| const juce_wchar n2 = s [len - 1]; | |||
| auto n1 = s[len - 2]; | |||
| auto n2 = s[len - 1]; | |||
| if (n1 == 'i' && n2 == 'n') n *= dpi; | |||
| else if (n1 == 'm' && n2 == 'm') n *= dpi / 25.4f; | |||
| @@ -1400,7 +1400,7 @@ private: | |||
| } | |||
| //============================================================================== | |||
| static bool isIdentifierChar (const juce_wchar c) | |||
| static bool isIdentifierChar (juce_wchar c) | |||
| { | |||
| return CharacterFunctions::isLetter (c) || c == '-'; | |||
| } | |||
| @@ -1446,7 +1446,7 @@ private: | |||
| static bool parseNextNumber (String::CharPointerType& text, String& value, const bool allowUnits) | |||
| { | |||
| String::CharPointerType s (text); | |||
| auto s = text; | |||
| while (s.isWhitespace() || *s == ',') | |||
| ++s; | |||
| @@ -28,7 +28,6 @@ namespace juce | |||
| { | |||
| KeyPress::KeyPress() noexcept | |||
| : keyCode (0), textCharacter (0) | |||
| { | |||
| } | |||
| @@ -37,14 +36,12 @@ KeyPress::KeyPress (int code, ModifierKeys m, juce_wchar textChar) noexcept | |||
| { | |||
| } | |||
| KeyPress::KeyPress (const int code) noexcept | |||
| : keyCode (code), textCharacter (0) | |||
| KeyPress::KeyPress (const int code) noexcept : keyCode (code) | |||
| { | |||
| } | |||
| KeyPress::KeyPress (const KeyPress& other) noexcept | |||
| : keyCode (other.keyCode), mods (other.mods), | |||
| textCharacter (other.textCharacter) | |||
| : keyCode (other.keyCode), mods (other.mods), textCharacter (other.textCharacter) | |||
| { | |||
| } | |||
| @@ -53,7 +50,6 @@ KeyPress& KeyPress::operator= (const KeyPress& other) noexcept | |||
| keyCode = other.keyCode; | |||
| mods = other.mods; | |||
| textCharacter = other.textCharacter; | |||
| return *this; | |||
| } | |||
| @@ -75,15 +71,8 @@ bool KeyPress::operator== (const KeyPress& other) const noexcept | |||
| == CharacterFunctions::toLowerCase ((juce_wchar) other.keyCode))); | |||
| } | |||
| bool KeyPress::operator!= (const KeyPress& other) const noexcept | |||
| { | |||
| return ! operator== (other); | |||
| } | |||
| bool KeyPress::operator!= (int otherKeyCode) const noexcept | |||
| { | |||
| return ! operator== (otherKeyCode); | |||
| } | |||
| bool KeyPress::operator!= (const KeyPress& other) const noexcept { return ! operator== (other); } | |||
| bool KeyPress::operator!= (int otherKeyCode) const noexcept { return ! operator== (otherKeyCode); } | |||
| bool KeyPress::isCurrentlyDown() const | |||
| { | |||
| @@ -149,7 +138,7 @@ namespace KeyPressHelpers | |||
| { | |||
| if (desc.containsIgnoreCase (numberPadPrefix())) | |||
| { | |||
| const juce_wchar lastChar = desc.trimEnd().getLastCharacter(); | |||
| auto lastChar = desc.trimEnd().getLastCharacter(); | |||
| switch (lastChar) | |||
| { | |||
| @@ -241,9 +230,9 @@ KeyPress KeyPress::createFromDescription (const String& desc) | |||
| if (key == 0) | |||
| { | |||
| // give up and use the hex code.. | |||
| const int hexCode = desc.fromFirstOccurrenceOf ("#", false, false) | |||
| .retainCharacters ("0123456789abcdefABCDEF") | |||
| .getHexValue32(); | |||
| auto hexCode = desc.fromFirstOccurrenceOf ("#", false, false) | |||
| .retainCharacters ("0123456789abcdefABCDEF") | |||
| .getHexValue32(); | |||
| if (hexCode > 0) | |||
| key = hexCode; | |||
| @@ -302,7 +291,7 @@ String KeyPress::getTextDescription() const | |||
| String KeyPress::getTextDescriptionWithIcons() const | |||
| { | |||
| #if JUCE_MAC | |||
| String s (getTextDescription()); | |||
| auto s = getTextDescription(); | |||
| for (int i = 0; i < numElementsInArray (KeyPressHelpers::osxSymbols); ++i) | |||
| s = s.replace (KeyPressHelpers::osxSymbols[i].text, | |||
| @@ -263,9 +263,9 @@ public: | |||
| private: | |||
| //============================================================================== | |||
| int keyCode; | |||
| int keyCode = 0; | |||
| ModifierKeys mods; | |||
| juce_wchar textCharacter; | |||
| juce_wchar textCharacter = 0; | |||
| JUCE_LEAK_DETECTOR (KeyPress) | |||
| }; | |||
| @@ -2654,8 +2654,7 @@ private: | |||
| { | |||
| updateKeyModifiers(); | |||
| juce_wchar textChar = (juce_wchar) key; | |||
| auto textChar = (juce_wchar) key; | |||
| const int virtualScanCode = (flags >> 16) & 0xff; | |||
| if (key >= '0' && key <= '9') | |||
| @@ -110,12 +110,12 @@ struct CppTokeniserFunctions | |||
| static int parseIdentifier (Iterator& source) noexcept | |||
| { | |||
| int tokenLength = 0; | |||
| String::CharPointerType::CharType possibleIdentifier [100]; | |||
| String::CharPointerType::CharType possibleIdentifier[100]; | |||
| String::CharPointerType possible (possibleIdentifier); | |||
| while (isIdentifierBody (source.peekNextChar())) | |||
| { | |||
| const juce_wchar c = source.nextChar(); | |||
| auto c = source.nextChar(); | |||
| if (tokenLength < 20) | |||
| possible.write (c); | |||
| @@ -137,7 +137,8 @@ struct CppTokeniserFunctions | |||
| template <typename Iterator> | |||
| static bool skipNumberSuffix (Iterator& source) | |||
| { | |||
| const juce_wchar c = source.peekNextChar(); | |||
| auto c = source.peekNextChar(); | |||
| if (c == 'l' || c == 'L' || c == 'u' || c == 'U') | |||
| source.skip(); | |||
| @@ -163,11 +164,13 @@ struct CppTokeniserFunctions | |||
| if (source.nextChar() != '0') | |||
| return false; | |||
| juce_wchar c = source.nextChar(); | |||
| auto c = source.nextChar(); | |||
| if (c != 'x' && c != 'X') | |||
| return false; | |||
| int numDigits = 0; | |||
| while (isHexDigit (source.peekNextChar())) | |||
| { | |||
| ++numDigits; | |||
| @@ -257,18 +260,19 @@ struct CppTokeniserFunctions | |||
| if (numDigits == 0) | |||
| return false; | |||
| juce_wchar c = source.peekNextChar(); | |||
| const bool hasExponent = (c == 'e' || c == 'E'); | |||
| auto c = source.peekNextChar(); | |||
| bool hasExponent = (c == 'e' || c == 'E'); | |||
| if (hasExponent) | |||
| { | |||
| source.skip(); | |||
| c = source.peekNextChar(); | |||
| if (c == '+' || c == '-') | |||
| source.skip(); | |||
| int numExpDigits = 0; | |||
| while (isDecimalDigit (source.peekNextChar())) | |||
| { | |||
| source.skip(); | |||
| @@ -280,6 +284,7 @@ struct CppTokeniserFunctions | |||
| } | |||
| c = source.peekNextChar(); | |||
| if (c == 'f' || c == 'F') | |||
| source.skip(); | |||
| else if (! (hasExponent || hasPoint)) | |||
| @@ -311,11 +316,11 @@ struct CppTokeniserFunctions | |||
| template <typename Iterator> | |||
| static void skipQuotedString (Iterator& source) noexcept | |||
| { | |||
| const juce_wchar quote = source.nextChar(); | |||
| auto quote = source.nextChar(); | |||
| for (;;) | |||
| { | |||
| const juce_wchar c = source.nextChar(); | |||
| auto c = source.nextChar(); | |||
| if (c == quote || c == 0) | |||
| break; | |||
| @@ -332,7 +337,7 @@ struct CppTokeniserFunctions | |||
| for (;;) | |||
| { | |||
| const juce_wchar c = source.nextChar(); | |||
| auto c = source.nextChar(); | |||
| if (c == 0 || (c == '/' && lastWasStar)) | |||
| break; | |||
| @@ -348,7 +353,7 @@ struct CppTokeniserFunctions | |||
| for (;;) | |||
| { | |||
| const juce_wchar c = source.peekNextChar(); | |||
| auto c = source.peekNextChar(); | |||
| if (c == '"') | |||
| { | |||
| @@ -360,7 +365,7 @@ struct CppTokeniserFunctions | |||
| { | |||
| Iterator next (source); | |||
| next.skip(); | |||
| const juce_wchar c2 = next.peekNextChar(); | |||
| auto c2 = next.peekNextChar(); | |||
| if (c2 == '/' || c2 == '*') | |||
| return; | |||
| @@ -394,7 +399,7 @@ struct CppTokeniserFunctions | |||
| template <typename Iterator> | |||
| static void skipIfNextCharMatches (Iterator& source, const juce_wchar c1, const juce_wchar c2) noexcept | |||
| { | |||
| const juce_wchar c = source.peekNextChar(); | |||
| auto c = source.peekNextChar(); | |||
| if (c == c1 || c == c2) | |||
| source.skip(); | |||
| @@ -404,8 +409,7 @@ struct CppTokeniserFunctions | |||
| static int readNextToken (Iterator& source) | |||
| { | |||
| source.skipWhitespace(); | |||
| const juce_wchar firstChar = source.peekNextChar(); | |||
| auto firstChar = source.peekNextChar(); | |||
| switch (firstChar) | |||
| { | |||
| @@ -416,7 +420,7 @@ struct CppTokeniserFunctions | |||
| case '5': case '6': case '7': case '8': case '9': | |||
| case '.': | |||
| { | |||
| int result = parseNumber (source); | |||
| auto result = parseNumber (source); | |||
| if (result == CPlusPlusCodeTokeniser::tokenType_error) | |||
| { | |||
| @@ -454,7 +458,7 @@ struct CppTokeniserFunctions | |||
| case '-': | |||
| { | |||
| source.skip(); | |||
| int result = parseNumber (source); | |||
| auto result = parseNumber (source); | |||
| if (result == CPlusPlusCodeTokeniser::tokenType_error) | |||
| { | |||
| @@ -474,7 +478,7 @@ struct CppTokeniserFunctions | |||
| case '/': | |||
| { | |||
| source.skip(); | |||
| juce_wchar nextChar = source.peekNextChar(); | |||
| auto nextChar = source.peekNextChar(); | |||
| if (nextChar == '/') | |||
| { | |||
| @@ -527,8 +531,8 @@ struct CppTokeniserFunctions | |||
| */ | |||
| struct StringIterator | |||
| { | |||
| StringIterator (const String& s) noexcept : t (s.getCharPointer()), numChars (0) {} | |||
| StringIterator (String::CharPointerType s) noexcept : t (s), numChars (0) {} | |||
| StringIterator (const String& s) noexcept : t (s.getCharPointer()) {} | |||
| StringIterator (String::CharPointerType s) noexcept : t (s) {} | |||
| juce_wchar nextChar() noexcept { if (isEOF()) return 0; ++numChars; return t.getAndAdvance(); } | |||
| juce_wchar peekNextChar()noexcept { return *t; } | |||
| @@ -538,7 +542,7 @@ struct CppTokeniserFunctions | |||
| bool isEOF() const noexcept { return t.isEmpty(); } | |||
| String::CharPointerType t; | |||
| int numChars; | |||
| int numChars = 0; | |||
| }; | |||
| //============================================================================== | |||
| @@ -562,7 +566,7 @@ struct CppTokeniserFunctions | |||
| for (int i = 0; i < numBytesToRead || numBytesToRead < 0; ++i) | |||
| { | |||
| const unsigned char c = (unsigned char) utf8[i]; | |||
| auto c = (unsigned char) utf8[i]; | |||
| bool startNewLine = false; | |||
| switch (c) | |||
| @@ -195,8 +195,9 @@ private: | |||
| { | |||
| jassert (index <= line.length()); | |||
| String::CharPointerType t (line.getCharPointer()); | |||
| auto t = line.getCharPointer(); | |||
| int col = 0; | |||
| for (int i = 0; i < index; ++i) | |||
| { | |||
| if (t.getAndAdvance() != '\t') | |||
| @@ -208,8 +209,7 @@ private: | |||
| return col; | |||
| } | |||
| static void addToken (Array<SyntaxToken>& dest, const String& text, | |||
| const int length, const int type) | |||
| static void addToken (Array<SyntaxToken>& dest, const String& text, int length, int type) | |||
| { | |||
| if (length > 1000) | |||
| { | |||
| @@ -79,7 +79,7 @@ struct LuaTokeniserFunctions | |||
| static int parseIdentifier (Iterator& source) noexcept | |||
| { | |||
| int tokenLength = 0; | |||
| String::CharPointerType::CharType possibleIdentifier [100]; | |||
| String::CharPointerType::CharType possibleIdentifier[100]; | |||
| String::CharPointerType possible (possibleIdentifier); | |||
| while (CppTokeniserFunctions::isIdentifierBody (source.peekNextChar())) | |||
| @@ -42,7 +42,7 @@ namespace | |||
| if (pattern == patternEnd) | |||
| return matchTerminator (target, targetEnd); | |||
| const juce_wchar c = pattern.getAndAdvance(); | |||
| auto c = pattern.getAndAdvance(); | |||
| switch (c) | |||
| { | |||
| @@ -105,7 +105,7 @@ namespace | |||
| while (pattern != patternEnd) | |||
| { | |||
| const juce_wchar c = pattern.getAndAdvance(); | |||
| auto c = pattern.getAndAdvance(); | |||
| switch (c) | |||
| { | |||
| @@ -135,9 +135,9 @@ namespace | |||
| if (set.size() == 0) | |||
| return match (pattern, patternEnd, target, targetEnd); | |||
| for (const String* str = set.begin(); str != set.end(); ++str) | |||
| if (str->getCharPointer().compareUpTo (target, str->length()) == 0) | |||
| if (match (pattern, patternEnd, target + str->length(), targetEnd)) | |||
| for (auto& str : set) | |||
| if (str.getCharPointer().compareUpTo (target, str.length()) == 0) | |||
| if (match (pattern, patternEnd, target + str.length(), targetEnd)) | |||
| return true; | |||
| return false; | |||
| @@ -155,7 +155,7 @@ namespace | |||
| while (pattern != patternEnd) | |||
| { | |||
| const juce_wchar c = pattern.getAndAdvance(); | |||
| auto c = pattern.getAndAdvance(); | |||
| switch (c) | |||
| { | |||
| @@ -203,8 +203,8 @@ namespace | |||
| static bool matchCharSetNegated (const Array<juce_wchar>& set, CharPtr pattern, | |||
| CharPtr patternEnd, CharPtr target, CharPtr targetEnd) | |||
| { | |||
| for (juce_wchar* c = set.begin(); c != set.end(); ++c) | |||
| if (*target == *c) | |||
| for (auto c : set) | |||
| if (*target == c) | |||
| return false; | |||
| return match (pattern, patternEnd, target + 1, targetEnd); | |||
| @@ -214,8 +214,8 @@ namespace | |||
| static bool matchCharSetNotNegated (const Array<juce_wchar>& set, CharPtr pattern, | |||
| CharPtr patternEnd, CharPtr target, CharPtr targetEnd) | |||
| { | |||
| for (juce_wchar* c = set.begin(); c != set.end(); ++c) | |||
| if (*target == *c) | |||
| for (auto c : set) | |||
| if (*target == c) | |||
| if (match (pattern, patternEnd, target + 1, targetEnd)) | |||
| return true; | |||
| @@ -229,8 +229,8 @@ namespace | |||
| if (target == targetEnd) | |||
| return false; | |||
| juce_wchar rangeStart = set.getLast(); | |||
| juce_wchar rangeEnd = pattern.getAndAdvance(); | |||
| auto rangeStart = set.getLast(); | |||
| auto rangeEnd = pattern.getAndAdvance(); | |||
| if (rangeEnd == ']') | |||
| { | |||
| @@ -281,9 +281,10 @@ namespace | |||
| static bool containsOnlyAllowedPrintableASCIIChars (const String& string) noexcept | |||
| { | |||
| for (String::CharPointerType charPtr (string.getCharPointer()); ! charPtr.isEmpty();) | |||
| for (auto charPtr = string.getCharPointer(); ! charPtr.isEmpty();) | |||
| { | |||
| juce_wchar c = charPtr.getAndAdvance(); | |||
| auto c = charPtr.getAndAdvance(); | |||
| if (! isPrintableASCIIChar (c) || isDisallowedChar (c)) | |||
| return false; | |||
| } | |||
| @@ -304,8 +305,8 @@ namespace | |||
| oscSymbols.addTokens (address, "/", StringRef()); | |||
| oscSymbols.removeEmptyStrings (false); | |||
| for (String* token = oscSymbols.begin(); token != oscSymbols.end(); ++token) | |||
| if (! containsOnlyAllowedPrintableASCIIChars (*token)) | |||
| for (auto& token : oscSymbols) | |||
| if (! containsOnlyAllowedPrintableASCIIChars (token)) | |||
| throw OSCFormatError ("OSC format error: encountered characters not allowed in address string."); | |||
| return oscSymbols; | |||