2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCE_IDENTIFIER_JUCEHEADER__
27 #define __JUCE_IDENTIFIER_JUCEHEADER__
32 //==============================================================================
34 Represents a string identifier, designed for accessing properties by name.
36 Identifier objects are very light and fast to copy, but slower to initialise
37 from a string, so it's much faster to keep a static identifier object to refer
38 to frequently-used names, rather than constructing them each time you need it.
40 @see NamedPropertySet, ValueTree
42 class JUCE_API Identifier
45 /** Creates a null identifier. */
46 Identifier() noexcept
;
48 /** Creates an identifier with a specified name.
49 Because this name may need to be used in contexts such as script variables or XML
50 tags, it must only contain ascii letters and digits, or the underscore character.
52 Identifier (const char* name
);
54 /** Creates an identifier with a specified name.
55 Because this name may need to be used in contexts such as script variables or XML
56 tags, it must only contain ascii letters and digits, or the underscore character.
58 Identifier (const String
& name
);
60 /** Creates a copy of another identifier. */
61 Identifier (const Identifier
& other
) noexcept
;
63 /** Creates a copy of another identifier. */
64 Identifier
& operator= (const Identifier
& other
) noexcept
;
69 /** Compares two identifiers. This is a very fast operation. */
70 inline bool operator== (const Identifier
& other
) const noexcept
{ return name
== other
.name
; }
72 /** Compares two identifiers. This is a very fast operation. */
73 inline bool operator!= (const Identifier
& other
) const noexcept
{ return name
!= other
.name
; }
75 /** Returns this identifier as a string. */
76 String
toString() const { return name
; }
78 /** Returns this identifier's raw string pointer. */
79 operator const String::CharPointerType() const noexcept
{ return name
; }
81 /** Checks a given string for characters that might not be valid in an Identifier.
82 Since Identifiers are used as a script variables and XML attributes, they should only contain
83 alphanumeric characters, underscores, or the '-' and ':' characters.
85 static bool isValidIdentifier (const String
& possibleIdentifier
) noexcept
;
89 //==============================================================================
90 String::CharPointerType name
;
92 static StringPool
& getPool();
96 #endif // __JUCE_IDENTIFIER_JUCEHEADER__