mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-05 03:50:07 +00:00
Minor code clean-ups.
This commit is contained in:
parent
97e9095933
commit
af2137ecaa
11 changed files with 261 additions and 359 deletions
|
|
@ -10986,8 +10986,10 @@ int String::indexOfChar (const int startIndex,
|
|||
if (*t == character)
|
||||
return (int) (t - text);
|
||||
|
||||
if (*t++ == 0)
|
||||
if (*t == 0)
|
||||
return -1;
|
||||
|
||||
++t;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -11120,7 +11122,18 @@ bool String::contains (const juce_wchar* const other) const throw()
|
|||
|
||||
bool String::containsChar (const juce_wchar character) const throw()
|
||||
{
|
||||
return indexOfChar (character) >= 0;
|
||||
const juce_wchar* t = text;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (*t == character)
|
||||
return true;
|
||||
|
||||
if (*t == 0)
|
||||
return false;
|
||||
|
||||
++t;
|
||||
}
|
||||
}
|
||||
|
||||
bool String::containsIgnoreCase (const juce_wchar* const t) const throw()
|
||||
|
|
@ -12653,7 +12666,6 @@ int StringArray::addTokens (const String& text, const String& breakCharacters, c
|
|||
{
|
||||
bool insideQuotes = false;
|
||||
juce_wchar currentQuoteChar = 0;
|
||||
|
||||
int i = 0;
|
||||
int tokenStart = 0;
|
||||
|
||||
|
|
@ -12661,35 +12673,11 @@ int StringArray::addTokens (const String& text, const String& breakCharacters, c
|
|||
{
|
||||
const juce_wchar c = text[i];
|
||||
|
||||
bool isBreak = (c == 0);
|
||||
|
||||
if (! (insideQuotes || isBreak))
|
||||
{
|
||||
const juce_wchar* b = breakCharacters;
|
||||
while (*b != 0)
|
||||
{
|
||||
if (*b++ == c)
|
||||
{
|
||||
isBreak = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const bool isBreak = (c == 0) || ((! insideQuotes) && breakCharacters.containsChar (c));
|
||||
|
||||
if (! isBreak)
|
||||
{
|
||||
bool isQuote = false;
|
||||
const juce_wchar* q = quoteCharacters;
|
||||
while (*q != 0)
|
||||
{
|
||||
if (*q++ == c)
|
||||
{
|
||||
isQuote = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isQuote)
|
||||
if (quoteCharacters.containsChar (c))
|
||||
{
|
||||
if (insideQuotes)
|
||||
{
|
||||
|
|
@ -12789,9 +12777,11 @@ void StringArray::removeDuplicates (const bool ignoreCase)
|
|||
|
||||
void StringArray::appendNumbersToDuplicates (const bool ignoreCase,
|
||||
const bool appendNumberToFirstInstance,
|
||||
const tchar* const preNumberString,
|
||||
const tchar* const postNumberString)
|
||||
const juce_wchar* const preNumberString,
|
||||
const juce_wchar* const postNumberString)
|
||||
{
|
||||
jassert (preNumberString != 0 && postNumberString != 0); // These strings can't be null pointers..
|
||||
|
||||
for (int i = 0; i < size() - 1; ++i)
|
||||
{
|
||||
String& s = strings.getReference(i);
|
||||
|
|
@ -12830,30 +12820,30 @@ END_JUCE_NAMESPACE
|
|||
/*** Start of inlined file: juce_StringPairArray.cpp ***/
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
StringPairArray::StringPairArray (const bool ignoreCase_) throw()
|
||||
StringPairArray::StringPairArray (const bool ignoreCase_)
|
||||
: ignoreCase (ignoreCase_)
|
||||
{
|
||||
}
|
||||
|
||||
StringPairArray::StringPairArray (const StringPairArray& other) throw()
|
||||
StringPairArray::StringPairArray (const StringPairArray& other)
|
||||
: keys (other.keys),
|
||||
values (other.values),
|
||||
ignoreCase (other.ignoreCase)
|
||||
{
|
||||
}
|
||||
|
||||
StringPairArray::~StringPairArray() throw()
|
||||
StringPairArray::~StringPairArray()
|
||||
{
|
||||
}
|
||||
|
||||
StringPairArray& StringPairArray::operator= (const StringPairArray& other) throw()
|
||||
StringPairArray& StringPairArray::operator= (const StringPairArray& other)
|
||||
{
|
||||
keys = other.keys;
|
||||
values = other.values;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool StringPairArray::operator== (const StringPairArray& other) const throw()
|
||||
bool StringPairArray::operator== (const StringPairArray& other) const
|
||||
{
|
||||
for (int i = keys.size(); --i >= 0;)
|
||||
if (other [keys[i]] != values[i])
|
||||
|
|
@ -12862,12 +12852,12 @@ bool StringPairArray::operator== (const StringPairArray& other) const throw()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool StringPairArray::operator!= (const StringPairArray& other) const throw()
|
||||
bool StringPairArray::operator!= (const StringPairArray& other) const
|
||||
{
|
||||
return ! operator== (other);
|
||||
}
|
||||
|
||||
const String& StringPairArray::operator[] (const String& key) const throw()
|
||||
const String& StringPairArray::operator[] (const String& key) const
|
||||
{
|
||||
return values [keys.indexOf (key, ignoreCase)];
|
||||
}
|
||||
|
|
@ -12882,8 +12872,7 @@ const String StringPairArray::getValue (const String& key, const String& default
|
|||
return defaultReturnValue;
|
||||
}
|
||||
|
||||
void StringPairArray::set (const String& key,
|
||||
const String& value) throw()
|
||||
void StringPairArray::set (const String& key, const String& value)
|
||||
{
|
||||
const int i = keys.indexOf (key, ignoreCase);
|
||||
|
||||
|
|
@ -12904,24 +12893,24 @@ void StringPairArray::addArray (const StringPairArray& other)
|
|||
set (other.keys[i], other.values[i]);
|
||||
}
|
||||
|
||||
void StringPairArray::clear() throw()
|
||||
void StringPairArray::clear()
|
||||
{
|
||||
keys.clear();
|
||||
values.clear();
|
||||
}
|
||||
|
||||
void StringPairArray::remove (const String& key) throw()
|
||||
void StringPairArray::remove (const String& key)
|
||||
{
|
||||
remove (keys.indexOf (key, ignoreCase));
|
||||
}
|
||||
|
||||
void StringPairArray::remove (const int index) throw()
|
||||
void StringPairArray::remove (const int index)
|
||||
{
|
||||
keys.remove (index);
|
||||
values.remove (index);
|
||||
}
|
||||
|
||||
void StringPairArray::setIgnoresCase (const bool shouldIgnoreCase) throw()
|
||||
void StringPairArray::setIgnoresCase (const bool shouldIgnoreCase)
|
||||
{
|
||||
ignoreCase = shouldIgnoreCase;
|
||||
}
|
||||
|
|
@ -12940,7 +12929,7 @@ const String StringPairArray::getDescription() const
|
|||
return s;
|
||||
}
|
||||
|
||||
void StringPairArray::minimiseStorageOverheads() throw()
|
||||
void StringPairArray::minimiseStorageOverheads()
|
||||
{
|
||||
keys.minimiseStorageOverheads();
|
||||
values.minimiseStorageOverheads();
|
||||
|
|
@ -12953,7 +12942,7 @@ END_JUCE_NAMESPACE
|
|||
/*** Start of inlined file: juce_XmlDocument.cpp ***/
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
XmlDocument::XmlDocument (const String& documentText) throw()
|
||||
XmlDocument::XmlDocument (const String& documentText)
|
||||
: originalText (documentText),
|
||||
ignoreEmptyTextElements (true)
|
||||
{
|
||||
|
|
@ -12964,7 +12953,7 @@ XmlDocument::XmlDocument (const File& file)
|
|||
inputSource = new FileInputSource (file);
|
||||
}
|
||||
|
||||
XmlDocument::~XmlDocument() throw()
|
||||
XmlDocument::~XmlDocument()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -13061,7 +13050,7 @@ const String& XmlDocument::getLastParseError() const throw()
|
|||
return lastError;
|
||||
}
|
||||
|
||||
void XmlDocument::setLastError (const String& desc, const bool carryOn) throw()
|
||||
void XmlDocument::setLastError (const String& desc, const bool carryOn)
|
||||
{
|
||||
lastError = desc;
|
||||
errorOccurred = ! carryOn;
|
||||
|
|
@ -13104,7 +13093,7 @@ int XmlDocument::findNextTokenLength() throw()
|
|||
return len;
|
||||
}
|
||||
|
||||
void XmlDocument::skipHeader() throw()
|
||||
void XmlDocument::skipHeader()
|
||||
{
|
||||
const juce_wchar* const found = CharacterFunctions::find (input, T("<?xml"));
|
||||
|
||||
|
|
@ -13146,7 +13135,7 @@ void XmlDocument::skipHeader() throw()
|
|||
dtdText = String (docType, (int) (input - (docType + 1))).trim();
|
||||
}
|
||||
|
||||
void XmlDocument::skipNextWhiteSpace() throw()
|
||||
void XmlDocument::skipNextWhiteSpace()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
|
|
@ -13196,7 +13185,7 @@ void XmlDocument::skipNextWhiteSpace() throw()
|
|||
}
|
||||
}
|
||||
|
||||
void XmlDocument::readQuotedString (String& result) throw()
|
||||
void XmlDocument::readQuotedString (String& result)
|
||||
{
|
||||
const juce_wchar quote = readNextChar();
|
||||
|
||||
|
|
@ -13246,7 +13235,7 @@ void XmlDocument::readQuotedString (String& result) throw()
|
|||
}
|
||||
}
|
||||
|
||||
XmlElement* XmlDocument::readNextElement (const bool alsoParseSubElements) throw()
|
||||
XmlElement* XmlDocument::readNextElement (const bool alsoParseSubElements)
|
||||
{
|
||||
XmlElement* node = 0;
|
||||
|
||||
|
|
@ -13355,7 +13344,7 @@ XmlElement* XmlDocument::readNextElement (const bool alsoParseSubElements) throw
|
|||
return node;
|
||||
}
|
||||
|
||||
void XmlDocument::readChildElements (XmlElement* parent) throw()
|
||||
void XmlDocument::readChildElements (XmlElement* parent)
|
||||
{
|
||||
XmlElement* lastChildNode = 0;
|
||||
|
||||
|
|
@ -13541,7 +13530,7 @@ void XmlDocument::readChildElements (XmlElement* parent) throw()
|
|||
}
|
||||
}
|
||||
|
||||
void XmlDocument::readEntity (String& result) throw()
|
||||
void XmlDocument::readEntity (String& result)
|
||||
{
|
||||
// skip over the ampersand
|
||||
++input;
|
||||
|
|
@ -13647,43 +13636,33 @@ void XmlDocument::readEntity (String& result) throw()
|
|||
const String XmlDocument::expandEntity (const String& ent)
|
||||
{
|
||||
if (ent.equalsIgnoreCase (T("amp")))
|
||||
{
|
||||
return T("&");
|
||||
}
|
||||
else if (ent.equalsIgnoreCase (T("quot")))
|
||||
{
|
||||
|
||||
if (ent.equalsIgnoreCase (T("quot")))
|
||||
return T("\"");
|
||||
}
|
||||
else if (ent.equalsIgnoreCase (T("apos")))
|
||||
{
|
||||
|
||||
if (ent.equalsIgnoreCase (T("apos")))
|
||||
return T("\'");
|
||||
}
|
||||
else if (ent.equalsIgnoreCase (T("lt")))
|
||||
{
|
||||
|
||||
if (ent.equalsIgnoreCase (T("lt")))
|
||||
return T("<");
|
||||
}
|
||||
else if (ent.equalsIgnoreCase (T("gt")))
|
||||
{
|
||||
|
||||
if (ent.equalsIgnoreCase (T("gt")))
|
||||
return T(">");
|
||||
}
|
||||
else if (ent[0] == T('#'))
|
||||
|
||||
if (ent[0] == T('#'))
|
||||
{
|
||||
if (ent[1] == T('x') || ent[1] == T('X'))
|
||||
{
|
||||
return String::charToString (static_cast <juce_wchar> (ent.substring (2).getHexValue32()));
|
||||
}
|
||||
else if (ent[1] >= T('0') && ent[1] <= T('9'))
|
||||
{
|
||||
|
||||
if (ent[1] >= T('0') && ent[1] <= T('9'))
|
||||
return String::charToString (static_cast <juce_wchar> (ent.substring (1).getIntValue()));
|
||||
}
|
||||
|
||||
setLastError ("illegal escape sequence", false);
|
||||
return T("&");
|
||||
}
|
||||
else
|
||||
{
|
||||
return expandExternalEntity (ent);
|
||||
}
|
||||
|
||||
return expandExternalEntity (ent);
|
||||
}
|
||||
|
||||
const String XmlDocument::expandExternalEntity (const String& entity)
|
||||
|
|
@ -13833,8 +13812,7 @@ XmlElement::XmlAttributeNode::XmlAttributeNode (const XmlAttributeNode& other) t
|
|||
{
|
||||
}
|
||||
|
||||
XmlElement::XmlAttributeNode::XmlAttributeNode (const String& name_,
|
||||
const String& value_) throw()
|
||||
XmlElement::XmlAttributeNode::XmlAttributeNode (const String& name_, const String& value_) throw()
|
||||
: name (name_),
|
||||
value (value_),
|
||||
next (0)
|
||||
|
|
@ -14157,24 +14135,11 @@ void XmlElement::writeToStream (OutputStream& output,
|
|||
const int lineWrapLength) const
|
||||
{
|
||||
if (includeXmlHeader)
|
||||
{
|
||||
output << "<?xml version=\"1.0\" encoding=\"" << encodingType;
|
||||
|
||||
if (allOnOneLine)
|
||||
output << "\"?> ";
|
||||
else
|
||||
output << "\"?>\r\n\r\n";
|
||||
}
|
||||
output << "<?xml version=\"1.0\" encoding=\"" << encodingType
|
||||
<< (allOnOneLine ? "\"?> " : "\"?>\r\n\r\n");
|
||||
|
||||
if (dtdToUse.isNotEmpty())
|
||||
{
|
||||
output << dtdToUse;
|
||||
|
||||
if (allOnOneLine)
|
||||
output << " ";
|
||||
else
|
||||
output << "\r\n";
|
||||
}
|
||||
output << dtdToUse << (allOnOneLine ? " " : "\r\n");
|
||||
|
||||
writeElementAsText (output, allOnOneLine ? -1 : 0, lineWrapLength);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue