diff --git a/modules/juce_core/text/juce_Identifier.cpp b/modules/juce_core/text/juce_Identifier.cpp index 2bfe8e42d9..6950a7cd06 100644 --- a/modules/juce_core/text/juce_Identifier.cpp +++ b/modules/juce_core/text/juce_Identifier.cpp @@ -45,16 +45,16 @@ Identifier& Identifier::operator= (const Identifier& other) noexcept return *this; } -Identifier::Identifier (const String& name_) - : name (Identifier::getPool().getPooledString (name_)) +Identifier::Identifier (const String& nm) + : name (Identifier::getPool().getPooledString (nm)) { /* An Identifier string must be suitable for use as a script variable or XML attribute, so it can only contain this limited set of characters.. */ - jassert (isValidIdentifier (name_)); + jassert (isValidIdentifier (nm)); } -Identifier::Identifier (const char* const name_) - : name (Identifier::getPool().getPooledString (name_)) +Identifier::Identifier (const char* const nm) + : name (Identifier::getPool().getPooledString (nm)) { /* An Identifier string must be suitable for use as a script variable or XML attribute, so it can only contain this limited set of characters.. */ @@ -65,6 +65,8 @@ Identifier::~Identifier() { } +Identifier Identifier::null; + bool Identifier::isValidIdentifier (const String& possibleIdentifier) noexcept { return possibleIdentifier.isNotEmpty() diff --git a/modules/juce_core/text/juce_Identifier.h b/modules/juce_core/text/juce_Identifier.h index 875b409004..7decd5291d 100644 --- a/modules/juce_core/text/juce_Identifier.h +++ b/modules/juce_core/text/juce_Identifier.h @@ -81,6 +81,15 @@ public: /** Returns this identifier's raw string pointer. */ const String::CharPointerType getCharPointer() const noexcept { return name; } + /** Returns true if this Identifier is not null */ + bool isValid() const noexcept { return name.getAddress() != nullptr; } + + /** Returns true if this Identifier is null */ + bool isNull() const noexcept { return name.getAddress() == nullptr; } + + /** A null identifier. */ + static Identifier null; + /** Checks a given string for characters that might not be valid in an Identifier. Since Identifiers are used as a script variables and XML attributes, they should only contain alphanumeric characters, underscores, or the '-' and ':' characters.