Browse Source

CharacterFunctions: Add new function to move pointer past whitespace

tags/2021-05-28
reuk 5 years ago
parent
commit
64b9366e8f
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
17 changed files with 46 additions and 23 deletions
  1. +2
    -2
      examples/Assets/WavefrontObjParser.h
  2. +2
    -2
      extras/Projucer/Source/Utility/Helpers/jucer_MiscUtilities.cpp
  3. +2
    -2
      extras/Projucer/Source/Utility/Helpers/jucer_TranslationHelpers.h
  4. +1
    -1
      modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h
  5. +1
    -1
      modules/juce_core/javascript/juce_Javascript.cpp
  6. +5
    -5
      modules/juce_core/maths/juce_Expression.cpp
  7. +3
    -0
      modules/juce_core/text/juce_CharPointer_ASCII.h
  8. +3
    -0
      modules/juce_core/text/juce_CharPointer_UTF16.h
  9. +3
    -0
      modules/juce_core/text/juce_CharPointer_UTF32.h
  10. +3
    -0
      modules/juce_core/text/juce_CharPointer_UTF8.h
  11. +14
    -3
      modules/juce_core/text/juce_CharacterFunctions.h
  12. +1
    -1
      modules/juce_core/xml/juce_XmlDocument.cpp
  13. +1
    -1
      modules/juce_graphics/geometry/juce_Path.cpp
  14. +2
    -2
      modules/juce_gui_basics/drawables/juce_SVGParser.cpp
  15. +1
    -1
      modules/juce_gui_basics/positioning/juce_RelativePoint.cpp
  16. +1
    -1
      modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp
  17. +1
    -1
      modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp

+ 2
- 2
examples/Assets/WavefrontObjParser.h View File

@@ -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);


+ 2
- 2
extras/Projucer/Source/Utility/Helpers/jucer_MiscUtilities.cpp View File

@@ -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 == '=')
{


+ 2
- 2
extras/Projucer/Source/Utility/Helpers/jucer_TranslationHelpers.h View File

@@ -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() == '"')
{


+ 1
- 1
modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h View File

@@ -272,7 +272,7 @@ private:
{
for (;;)
{
p = p.findEndOfWhitespace();
p.incrementToEndOfWhitespace();
if (*p == '/')
{


+ 1
- 1
modules/juce_core/javascript/juce_Javascript.cpp View File

@@ -940,7 +940,7 @@ struct JavascriptEngine::RootObject : public DynamicObject
{
for (;;)
{
p = p.findEndOfWhitespace();
p.incrementToEndOfWhitespace();
if (*p == '/')
{


+ 5
- 5
modules/juce_core/maths/juce_Expression.cpp View File

@@ -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])))


+ 3
- 0
modules/juce_core/text/juce_CharPointer_ASCII.h View File

@@ -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
{


+ 3
- 0
modules/juce_core/text/juce_CharPointer_UTF16.h View File

@@ -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
{


+ 3
- 0
modules/juce_core/text/juce_CharPointer_UTF32.h View File

@@ -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
{


+ 3
- 0
modules/juce_core/text/juce_CharPointer_UTF8.h View File

@@ -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
{


+ 14
- 3
modules/juce_core/text/juce_CharacterFunctions.h View File

@@ -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;
}


+ 1
- 1
modules/juce_core/xml/juce_XmlDocument.cpp View File

@@ -291,7 +291,7 @@ void XmlDocument::skipNextWhiteSpace()
{
for (;;)
{
input = input.findEndOfWhitespace();
input.incrementToEndOfWhitespace();
if (input.isEmpty())
{


+ 1
- 1
modules/juce_graphics/geometry/juce_Path.cpp View File

@@ -37,7 +37,7 @@ namespace PathHelpers
static String nextToken (String::CharPointerType& t)
{
t = t.findEndOfWhitespace();
t.incrementToEndOfWhitespace();
auto start = t;
size_t numChars = 0;


+ 2
- 2
modules/juce_gui_basics/drawables/juce_SVGParser.cpp View File

@@ -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;


+ 1
- 1
modules/juce_gui_basics/positioning/juce_RelativePoint.cpp View File

@@ -30,7 +30,7 @@ namespace RelativePointHelpers
{
inline void skipComma (String::CharPointerType& s)
{
s = s.findEndOfWhitespace();
s.incrementToEndOfWhitespace();
if (*s == ',')
++s;


+ 1
- 1
modules/juce_gui_basics/positioning/juce_RelativeRectangle.cpp View File

@@ -30,7 +30,7 @@ namespace RelativeRectangleHelpers
{
inline void skipComma (String::CharPointerType& s)
{
s = s.findEndOfWhitespace();
s.incrementToEndOfWhitespace();
if (*s == ',')
++s;


+ 1
- 1
modules/juce_gui_extra/misc/juce_LiveConstantEditor.cpp View File

@@ -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…
Cancel
Save