mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
CharacterFunctions: Add new function to move pointer past whitespace
This commit is contained in:
parent
dc6b4ee43f
commit
64b9366e8f
17 changed files with 46 additions and 23 deletions
|
|
@ -143,7 +143,7 @@ private:
|
|||
|
||||
static float parseFloat (String::CharPointerType& t)
|
||||
{
|
||||
t = t.findEndOfWhitespace();
|
||||
t.incrementToEndOfWhitespace();
|
||||
return (float) CharacterFunctions::readDoubleValue (t);
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ private:
|
|||
{
|
||||
TripleIndex i;
|
||||
|
||||
t = t.findEndOfWhitespace();
|
||||
t.incrementToEndOfWhitespace();
|
||||
i.vertexIndex = t.getIntValue32() - 1;
|
||||
t = findEndOfFaceToken (t);
|
||||
|
||||
|
|
|
|||
|
|
@ -123,12 +123,12 @@ StringPairArray parsePreprocessorDefs (const String& text)
|
|||
while (! s.isEmpty())
|
||||
{
|
||||
String token, value;
|
||||
s = s.findEndOfWhitespace();
|
||||
s.incrementToEndOfWhitespace();
|
||||
|
||||
while ((! s.isEmpty()) && *s != '=' && ! s.isWhitespace())
|
||||
token << s.getAndAdvance();
|
||||
|
||||
s = s.findEndOfWhitespace();
|
||||
s.incrementToEndOfWhitespace();
|
||||
|
||||
if (*s == '=')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ struct TranslationHelpers
|
|||
break;
|
||||
|
||||
p += 5;
|
||||
p = p.findEndOfWhitespace();
|
||||
p.incrementToEndOfWhitespace();
|
||||
|
||||
if (*p == '(')
|
||||
{
|
||||
|
|
@ -63,7 +63,7 @@ struct TranslationHelpers
|
|||
|
||||
static void parseStringLiteral (String::CharPointerType& p, MemoryOutputStream& out) noexcept
|
||||
{
|
||||
p = p.findEndOfWhitespace();
|
||||
p.incrementToEndOfWhitespace();
|
||||
|
||||
if (p.getAndAdvance() == '"')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ private:
|
|||
{
|
||||
for (;;)
|
||||
{
|
||||
p = p.findEndOfWhitespace();
|
||||
p.incrementToEndOfWhitespace();
|
||||
|
||||
if (*p == '/')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -940,7 +940,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
|
|||
{
|
||||
for (;;)
|
||||
{
|
||||
p = p.findEndOfWhitespace();
|
||||
p.incrementToEndOfWhitespace();
|
||||
|
||||
if (*p == '/')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -699,7 +699,7 @@ struct Expression::Helpers
|
|||
|
||||
bool readOperator (const char* ops, char* const opType = nullptr) noexcept
|
||||
{
|
||||
text = text.findEndOfWhitespace();
|
||||
text.incrementToEndOfWhitespace();
|
||||
|
||||
while (*ops != 0)
|
||||
{
|
||||
|
|
@ -719,7 +719,7 @@ struct Expression::Helpers
|
|||
|
||||
bool readIdentifier (String& identifier) noexcept
|
||||
{
|
||||
text = text.findEndOfWhitespace();
|
||||
text.incrementToEndOfWhitespace();
|
||||
auto t = text;
|
||||
int numChars = 0;
|
||||
|
||||
|
|
@ -747,21 +747,21 @@ struct Expression::Helpers
|
|||
|
||||
Term* readNumber() noexcept
|
||||
{
|
||||
text = text.findEndOfWhitespace();
|
||||
text.incrementToEndOfWhitespace();
|
||||
auto t = text;
|
||||
bool isResolutionTarget = (*t == '@');
|
||||
|
||||
if (isResolutionTarget)
|
||||
{
|
||||
++t;
|
||||
t = t.findEndOfWhitespace();
|
||||
t.incrementToEndOfWhitespace();
|
||||
text = t;
|
||||
}
|
||||
|
||||
if (*t == '-')
|
||||
{
|
||||
++t;
|
||||
t = t.findEndOfWhitespace();
|
||||
t.incrementToEndOfWhitespace();
|
||||
}
|
||||
|
||||
if (isDecimalDigit (*t) || (*t == '.' && isDecimalDigit (t[1])))
|
||||
|
|
|
|||
|
|
@ -350,6 +350,9 @@ public:
|
|||
/** Returns the first non-whitespace character in the string. */
|
||||
CharPointer_ASCII findEndOfWhitespace() const noexcept { return CharacterFunctions::findEndOfWhitespace (*this); }
|
||||
|
||||
/** Move this pointer to the first non-whitespace character in the string. */
|
||||
void incrementToEndOfWhitespace() noexcept { CharacterFunctions::incrementToEndOfWhitespace (*this); }
|
||||
|
||||
/** Returns true if the given unicode character can be represented in this encoding. */
|
||||
static bool canRepresent (juce_wchar character) noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -426,6 +426,9 @@ public:
|
|||
/** Returns the first non-whitespace character in the string. */
|
||||
CharPointer_UTF16 findEndOfWhitespace() const noexcept { return CharacterFunctions::findEndOfWhitespace (*this); }
|
||||
|
||||
/** Move this pointer to the first non-whitespace character in the string. */
|
||||
void incrementToEndOfWhitespace() noexcept { CharacterFunctions::incrementToEndOfWhitespace (*this); }
|
||||
|
||||
/** Returns true if the given unicode character can be represented in this encoding. */
|
||||
static bool canRepresent (juce_wchar character) noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -341,6 +341,9 @@ public:
|
|||
/** Returns the first non-whitespace character in the string. */
|
||||
CharPointer_UTF32 findEndOfWhitespace() const noexcept { return CharacterFunctions::findEndOfWhitespace (*this); }
|
||||
|
||||
/** Move this pointer to the first non-whitespace character in the string. */
|
||||
void incrementToEndOfWhitespace() noexcept { CharacterFunctions::incrementToEndOfWhitespace (*this); }
|
||||
|
||||
/** Returns true if the given unicode character can be represented in this encoding. */
|
||||
static bool canRepresent (juce_wchar character) noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -483,6 +483,9 @@ public:
|
|||
/** Returns the first non-whitespace character in the string. */
|
||||
CharPointer_UTF8 findEndOfWhitespace() const noexcept { return CharacterFunctions::findEndOfWhitespace (*this); }
|
||||
|
||||
/** Move this pointer to the first non-whitespace character in the string. */
|
||||
void incrementToEndOfWhitespace() noexcept { CharacterFunctions::incrementToEndOfWhitespace (*this); }
|
||||
|
||||
/** Returns true if the given unicode character can be represented in this encoding. */
|
||||
static bool canRepresent (juce_wchar character) noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -794,6 +794,19 @@ public:
|
|||
return -1;
|
||||
}
|
||||
|
||||
/** Increments a pointer until it points to the first non-whitespace character
|
||||
in a string.
|
||||
|
||||
If the string contains only whitespace, the pointer will point to the
|
||||
string's null terminator.
|
||||
*/
|
||||
template <typename Type>
|
||||
static void incrementToEndOfWhitespace (Type& text) noexcept
|
||||
{
|
||||
while (text.isWhitespace())
|
||||
++text;
|
||||
}
|
||||
|
||||
/** Returns a pointer to the first non-whitespace character in a string.
|
||||
If the string contains only whitespace, this will return a pointer
|
||||
to its null terminator.
|
||||
|
|
@ -801,9 +814,7 @@ public:
|
|||
template <typename Type>
|
||||
static Type findEndOfWhitespace (Type text) noexcept
|
||||
{
|
||||
while (text.isWhitespace())
|
||||
++text;
|
||||
|
||||
incrementToEndOfWhitespace (text);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ void XmlDocument::skipNextWhiteSpace()
|
|||
{
|
||||
for (;;)
|
||||
{
|
||||
input = input.findEndOfWhitespace();
|
||||
input.incrementToEndOfWhitespace();
|
||||
|
||||
if (input.isEmpty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace PathHelpers
|
|||
|
||||
static String nextToken (String::CharPointerType& t)
|
||||
{
|
||||
t = t.findEndOfWhitespace();
|
||||
t.incrementToEndOfWhitespace();
|
||||
|
||||
auto start = t;
|
||||
size_t numChars = 0;
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ public:
|
|||
case 'z':
|
||||
path.closeSubPath();
|
||||
last = last2 = subpathStart;
|
||||
d = d.findEndOfWhitespace();
|
||||
d.incrementToEndOfWhitespace();
|
||||
currentCommand = 'M';
|
||||
break;
|
||||
|
||||
|
|
@ -755,7 +755,7 @@ private:
|
|||
|
||||
dashLengths.add (value);
|
||||
|
||||
t = t.findEndOfWhitespace();
|
||||
t.incrementToEndOfWhitespace();
|
||||
|
||||
if (*t == ',')
|
||||
++t;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace RelativePointHelpers
|
|||
{
|
||||
inline void skipComma (String::CharPointerType& s)
|
||||
{
|
||||
s = s.findEndOfWhitespace();
|
||||
s.incrementToEndOfWhitespace();
|
||||
|
||||
if (*s == ',')
|
||||
++s;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace RelativeRectangleHelpers
|
|||
{
|
||||
inline void skipComma (String::CharPointerType& s)
|
||||
{
|
||||
s = s.findEndOfWhitespace();
|
||||
s.incrementToEndOfWhitespace();
|
||||
|
||||
if (*s == ',')
|
||||
++s;
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ void LivePropertyEditorBase::findOriginalValueInCode()
|
|||
}
|
||||
|
||||
p += (int) (sizeof ("JUCE_LIVE_CONSTANT") - 1);
|
||||
p = p.findEndOfWhitespace();
|
||||
p.incrementToEndOfWhitespace();
|
||||
|
||||
if (! CharacterFunctions::find (p, CharPointer_ASCII ("JUCE_LIVE_CONSTANT")).isEmpty())
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue