openshot-audio  0.1.6
juce_StringRef.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the juce_core module of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission to use, copy, modify, and/or distribute this software for any purpose with
8  or without fee is hereby granted, provided that the above copyright notice and this
9  permission notice appear in all copies.
10 
11  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
12  TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
13  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
15  IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 
18  ------------------------------------------------------------------------------
19 
20  NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
21  All other JUCE modules are covered by a dual GPL/commercial license, so if you are
22  using any other modules, be sure to check that you also comply with their license.
23 
24  For more details, visit www.juce.com
25 
26  ==============================================================================
27 */
28 
29 #ifndef JUCE_STRINGREF_H_INCLUDED
30 #define JUCE_STRINGREF_H_INCLUDED
31 
32 //==============================================================================
66 {
67 public:
73  StringRef (const char* stringLiteral) noexcept;
74 
79  StringRef (String::CharPointerType stringLiteral) noexcept;
80 
86  StringRef (const String& string) noexcept;
87 
90 
91  //==============================================================================
93  operator const String::CharPointerType::CharType*() const noexcept { return text.getAddress(); }
95  operator String::CharPointerType() const noexcept { return text; }
96 
98  bool isEmpty() const noexcept { return text.isEmpty(); }
100  bool isNotEmpty() const noexcept { return ! text.isEmpty(); }
102  int length() const noexcept { return (int) text.length(); }
103 
105  juce_wchar operator[] (int index) const noexcept { return text[index]; }
106 
108  bool operator== (const String& s) const noexcept { return text.compare (s.getCharPointer()) == 0; }
110  bool operator!= (const String& s) const noexcept { return text.compare (s.getCharPointer()) != 0; }
111 
113  bool operator== (StringRef s) const noexcept { return text.compare (s.text) == 0; }
115  bool operator!= (StringRef s) const noexcept { return text.compare (s.text) != 0; }
116 
117  //==============================================================================
119  String::CharPointerType text;
120 
121  #if JUCE_STRING_UTF_TYPE != 8 && ! defined (DOXYGEN)
122  // Sorry, non-UTF8 people, you're unable to take advantage of StringRef, because
123  // you've chosen a character encoding that doesn't match C++ string literals.
125  #endif
126 };
127 
128 //==============================================================================
130 JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, StringRef string2) noexcept;
132 JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, StringRef string2) noexcept;
133 
134 #if JUCE_STRING_UTF_TYPE != 8 && ! defined (DOXYGEN)
135  inline String operator+ (String s1, StringRef s2) { return s1 += String (s2.text); }
136 #endif
137 
138 #endif // JUCE_STRINGREF_H_INCLUDED
JUCE_API bool JUCE_CALLTYPE operator!=(const String &string1, StringRef string2) noexcept
Definition: juce_String.cpp:581
String::CharPointerType text
Definition: juce_StringRef.h:119
JUCE_API bool JUCE_CALLTYPE operator==(const String &string1, StringRef string2) noexcept
Definition: juce_String.cpp:580
#define noexcept
Definition: juce_CompilerSupport.h:141
#define JUCE_CALLTYPE
Definition: juce_PlatformDefs.h:50
Definition: juce_String.h:43
String stringCopy
Definition: juce_StringRef.h:124
#define JUCE_API
Definition: juce_StandardHeader.h:139
int length() const noexcept
Definition: juce_StringRef.h:102
bool isEmpty() const noexcept
Definition: juce_StringRef.h:98
wchar_t juce_wchar
Definition: juce_CharacterFunctions.h:49
String operator+(String s1, StringRef s2)
Definition: juce_StringRef.h:135
bool isNotEmpty() const noexcept
Definition: juce_StringRef.h:100
Definition: juce_StringRef.h:65