OpenShot Audio Library | OpenShotAudio: juce_StringRef.h Source File

OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_StringRef.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
61 class JUCE_API StringRef final
62{
63public:
69 StringRef (const char* stringLiteral) noexcept;
70
75 StringRef (String::CharPointerType stringLiteral) noexcept;
76
82 StringRef (const String& string) noexcept;
83
89 StringRef (const std::string& string);
90
92 StringRef() noexcept;
93
94 //==============================================================================
96 operator const String::CharPointerType::CharType*() const noexcept { return text.getAddress(); }
98 operator String::CharPointerType() const noexcept { return text; }
99
101 bool isEmpty() const noexcept { return text.isEmpty(); }
103 bool isNotEmpty() const noexcept { return ! text.isEmpty(); }
105 int length() const noexcept { return (int) text.length(); }
106
108 juce_wchar operator[] (int index) const noexcept { return text[index]; }
109
111 bool operator== (const String& s) const noexcept { return text.compare (s.getCharPointer()) == 0; }
113 bool operator!= (const String& s) const noexcept { return text.compare (s.getCharPointer()) != 0; }
115 bool operator< (const String& s) const noexcept { return text.compare (s.getCharPointer()) < 0; }
117 bool operator<= (const String& s) const noexcept { return text.compare (s.getCharPointer()) <= 0; }
119 bool operator> (const String& s) const noexcept { return text.compare (s.getCharPointer()) > 0; }
121 bool operator>= (const String& s) const noexcept { return text.compare (s.getCharPointer()) >= 0; }
122
124 bool operator== (StringRef s) const noexcept { return text.compare (s.text) == 0; }
126 bool operator!= (StringRef s) const noexcept { return text.compare (s.text) != 0; }
127
128 //==============================================================================
130 String::CharPointerType text;
131
132 #if JUCE_STRING_UTF_TYPE != 8 && ! defined (DOXYGEN)
133 // Sorry, non-UTF8 people, you're unable to take advantage of StringRef, because
134 // you've chosen a character encoding that doesn't match C++ string literals.
135 String stringCopy;
136 #endif
137};
138
139//==============================================================================
141JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, StringRef string2) noexcept;
143JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, StringRef string2) noexcept;
145JUCE_API bool JUCE_CALLTYPE operator< (const String& string1, StringRef string2) noexcept;
147JUCE_API bool JUCE_CALLTYPE operator<= (const String& string1, StringRef string2) noexcept;
149JUCE_API bool JUCE_CALLTYPE operator> (const String& string1, StringRef string2) noexcept;
151JUCE_API bool JUCE_CALLTYPE operator>= (const String& string1, StringRef string2) noexcept;
152
153inline String operator+ (String s1, StringRef s2) { return s1 += String (s2.text); }
154inline String operator+ (StringRef s1, const String& s2) { return String (s1.text) + s2; }
155inline String operator+ (const char* s1, StringRef s2) { return String (s1) + String (s2.text); }
156inline String operator+ (StringRef s1, const char* s2) { return String (s1.text) + String (s2); }
157
158} // namespace juce
juce::StringRef
Definition juce_StringRef.h:62
juce::StringRef::isNotEmpty
bool isNotEmpty() const noexcept
Definition juce_StringRef.h:103
juce::StringRef::length
int length() const noexcept
Definition juce_StringRef.h:105
juce::StringRef::text
String::CharPointerType text
Definition juce_StringRef.h:130
juce::StringRef::isEmpty
bool isEmpty() const noexcept
Definition juce_StringRef.h:101
juce::String
Definition juce_String.h:53