JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::Identifier Class Referencefinal

Represents a string identifier, designed for accessing properties by name. More...

#include <juce_Identifier.h>

Collaboration diagram for juce::Identifier:

Public Member Functions

 Identifier () noexcept
 Creates a null identifier. More...
 
 Identifier (const char *name)
 Creates an identifier with a specified name. More...
 
 Identifier (const String &name)
 Creates an identifier with a specified name. More...
 
 Identifier (String::CharPointerType nameStart, String::CharPointerType nameEnd)
 Creates an identifier with a specified name. More...
 
 Identifier (const Identifier &other) noexcept
 Creates a copy of another identifier. More...
 
 Identifier (Identifier &&other) noexcept
 Creates a copy of another identifier. More...
 
 ~Identifier () noexcept
 Destructor. More...
 
String::CharPointerType getCharPointer () const noexcept
 Returns this identifier's raw string pointer. More...
 
bool isNull () const noexcept
 Returns true if this Identifier is null. More...
 
bool isValid () const noexcept
 Returns true if this Identifier is not null. More...
 
 operator String::CharPointerType () const noexcept
 Returns this identifier's raw string pointer. More...
 
 operator StringRef () const noexcept
 Returns this identifier as a StringRef. More...
 
bool operator!= (const Identifier &other) const noexcept
 Compares two identifiers. More...
 
bool operator!= (StringRef other) const noexcept
 Compares the identifier with a string. More...
 
bool operator< (StringRef other) const noexcept
 Compares the identifier with a string. More...
 
bool operator<= (StringRef other) const noexcept
 Compares the identifier with a string. More...
 
Identifieroperator= (const Identifier &other) noexcept
 Creates a copy of another identifier. More...
 
Identifieroperator= (Identifier &&other) noexcept
 Creates a copy of another identifier. More...
 
bool operator== (const Identifier &other) const noexcept
 Compares two identifiers. More...
 
bool operator== (StringRef other) const noexcept
 Compares the identifier with a string. More...
 
bool operator> (StringRef other) const noexcept
 Compares the identifier with a string. More...
 
bool operator>= (StringRef other) const noexcept
 Compares the identifier with a string. More...
 
const StringtoString () const noexcept
 Returns this identifier as a string. More...
 

Static Public Member Functions

static bool isValidIdentifier (const String &possibleIdentifier) noexcept
 Checks a given string for characters that might not be valid in an Identifier. More...
 

Static Public Attributes

static Identifier null
 A null identifier. More...
 

Private Attributes

String name
 

Detailed Description

Represents a string identifier, designed for accessing properties by name.

Comparing two Identifier objects is very fast (an O(1) operation), but creating them can be slower than just using a String directly, so the optimal way to use them is to keep some static Identifier objects for the things you use often.

See also
NamedValueSet, ValueTree

{Core}

Constructor & Destructor Documentation

◆ Identifier() [1/6]

juce::Identifier::Identifier ( )
noexcept

Creates a null identifier.

◆ Identifier() [2/6]

juce::Identifier::Identifier ( const char *  name)

Creates an identifier with a specified name.

Because this name may need to be used in contexts such as script variables or XML tags, it must only contain ascii letters and digits, or the underscore character.

◆ Identifier() [3/6]

juce::Identifier::Identifier ( const String name)

Creates an identifier with a specified name.

Because this name may need to be used in contexts such as script variables or XML tags, it must only contain ascii letters and digits, or the underscore character.

◆ Identifier() [4/6]

juce::Identifier::Identifier ( String::CharPointerType  nameStart,
String::CharPointerType  nameEnd 
)

Creates an identifier with a specified name.

Because this name may need to be used in contexts such as script variables or XML tags, it must only contain ascii letters and digits, or the underscore character.

◆ Identifier() [5/6]

juce::Identifier::Identifier ( const Identifier other)
noexcept

Creates a copy of another identifier.

◆ Identifier() [6/6]

juce::Identifier::Identifier ( Identifier &&  other)
noexcept

Creates a copy of another identifier.

◆ ~Identifier()

juce::Identifier::~Identifier ( )
noexcept

Destructor.

Member Function Documentation

◆ getCharPointer()

String::CharPointerType juce::Identifier::getCharPointer ( ) const
inlinenoexcept

Returns this identifier's raw string pointer.

References juce::String::getCharPointer().

◆ isNull()

bool juce::Identifier::isNull ( ) const
inlinenoexcept

Returns true if this Identifier is null.

References juce::String::isEmpty().

◆ isValid()

bool juce::Identifier::isValid ( ) const
inlinenoexcept

Returns true if this Identifier is not null.

References juce::String::isNotEmpty().

◆ isValidIdentifier()

static bool juce::Identifier::isValidIdentifier ( const String possibleIdentifier)
staticnoexcept

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.

◆ operator String::CharPointerType()

juce::Identifier::operator String::CharPointerType ( ) const
inlinenoexcept

Returns this identifier's raw string pointer.

References juce::String::getCharPointer().

◆ operator StringRef()

juce::Identifier::operator StringRef ( ) const
inlinenoexcept

Returns this identifier as a StringRef.

◆ operator!=() [1/2]

bool juce::Identifier::operator!= ( const Identifier other) const
inlinenoexcept

Compares two identifiers.

This is a very fast operation.

References juce::String::getCharPointer(), and name.

◆ operator!=() [2/2]

bool juce::Identifier::operator!= ( StringRef  other) const
inlinenoexcept

Compares the identifier with a string.

◆ operator<()

bool juce::Identifier::operator< ( StringRef  other) const
inlinenoexcept

Compares the identifier with a string.

◆ operator<=()

bool juce::Identifier::operator<= ( StringRef  other) const
inlinenoexcept

Compares the identifier with a string.

◆ operator=() [1/2]

Identifier& juce::Identifier::operator= ( const Identifier other)
noexcept

Creates a copy of another identifier.

◆ operator=() [2/2]

Identifier& juce::Identifier::operator= ( Identifier &&  other)
noexcept

Creates a copy of another identifier.

◆ operator==() [1/2]

bool juce::Identifier::operator== ( const Identifier other) const
inlinenoexcept

Compares two identifiers.

This is a very fast operation.

References juce::String::getCharPointer(), and name.

◆ operator==() [2/2]

bool juce::Identifier::operator== ( StringRef  other) const
inlinenoexcept

Compares the identifier with a string.

◆ operator>()

bool juce::Identifier::operator> ( StringRef  other) const
inlinenoexcept

Compares the identifier with a string.

◆ operator>=()

bool juce::Identifier::operator>= ( StringRef  other) const
inlinenoexcept

Compares the identifier with a string.

◆ toString()

const String& juce::Identifier::toString ( ) const
inlinenoexcept

Returns this identifier as a string.

Member Data Documentation

◆ name

String juce::Identifier::name
private

Referenced by operator!=(), and operator==().

◆ null

Identifier juce::Identifier::null
static

A null identifier.


The documentation for this class was generated from the following file: