mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-01 03:10:06 +00:00
Identifier::null, isNull, isValid methods.
This commit is contained in:
parent
ed83df2d75
commit
7fbd29e84e
2 changed files with 16 additions and 5 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue