13 #ifndef LLVM_ADT_STRINGSWITCH_H
14 #define LLVM_ADT_STRINGSWITCH_H
42 template<
typename T,
typename R = T>
54 : Str(S), Result(nullptr) { }
61 *
this = std::move(other);
65 Result = other.Result;
76 if (!Result && N-1 == Str.
size() &&
77 (N == 1 || std::memcmp(S, Str.
data(), N-1) == 0)) {
87 if (!Result && Str.
size() >= N-1 &&
88 (N == 1 || std::memcmp(S, Str.
data() + Str.
size() + 1 -
N, N-1) == 0)) {
98 if (!Result && Str.
size() >= N-1 &&
99 (N == 1 || std::memcmp(S, Str.
data(), N-1) == 0)) {
105 template<
unsigned N0,
unsigned N1>
109 return Case(S0, Value).
Case(S1, Value);
112 template<
unsigned N0,
unsigned N1,
unsigned N2>
115 const char (&S2)[N2],
const T&
Value) {
116 return Case(S0, Value).
Cases(S1, S2, Value);
119 template<
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3>
122 const char (&S2)[N2],
const char (&S3)[N3],
124 return Case(S0, Value).
Cases(S1, S2, S3, Value);
127 template<
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3,
unsigned N4>
130 const char (&S2)[N2],
const char (&S3)[N3],
131 const char (&S4)[N4],
const T&
Value) {
132 return Case(S0, Value).
Cases(S1, S2, S3, S4, Value);
135 template <
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3,
unsigned N4,
139 const char (&S2)[N2],
const char (&S3)[N3],
140 const char (&S4)[N4],
const char (&S5)[N5],
142 return Case(S0, Value).
Cases(S1, S2, S3, S4, S5, Value);
145 template <
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3,
unsigned N4,
146 unsigned N5,
unsigned N6>
149 const char (&S2)[N2],
const char (&S3)[N3],
150 const char (&S4)[N4],
const char (&S5)[N5],
151 const char (&S6)[N6],
const T &
Value) {
152 return Case(S0, Value).
Cases(S1, S2, S3, S4, S5, S6, Value);
155 template <
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3,
unsigned N4,
156 unsigned N5,
unsigned N6,
unsigned N7>
159 const char (&S2)[N2],
const char (&S3)[N3],
160 const char (&S4)[N4],
const char (&S5)[N5],
161 const char (&S6)[N6],
const char (&S7)[N7],
163 return Case(S0, Value).
Cases(S1, S2, S3, S4, S5, S6, S7, Value);
166 template <
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3,
unsigned N4,
167 unsigned N5,
unsigned N6,
unsigned N7,
unsigned N8>
170 const char (&S2)[N2],
const char (&S3)[N3],
171 const char (&S4)[N4],
const char (&S5)[N5],
172 const char (&S6)[N6],
const char (&S7)[N7],
173 const char (&S8)[N8],
const T &
Value) {
174 return Case(S0, Value).
Cases(S1, S2, S3, S4, S5, S6, S7, S8, Value);
177 template <
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3,
unsigned N4,
178 unsigned N5,
unsigned N6,
unsigned N7,
unsigned N8,
unsigned N9>
181 const char (&S2)[N2],
const char (&S3)[N3],
182 const char (&S4)[N4],
const char (&S5)[N5],
183 const char (&S6)[N6],
const char (&S7)[N7],
184 const char (&S8)[N8],
const char (&S9)[N9],
186 return Case(S0, Value).
Cases(S1, S2, S3, S4, S5, S6, S7, S8, S9, Value);
190 template <
unsigned N>
199 template <
unsigned N>
208 template <
unsigned N>
216 template <
unsigned N0,
unsigned N1>
222 template <
unsigned N0,
unsigned N1,
unsigned N2>
224 CasesLower(
const char (&S0)[N0],
const char (&S1)[N1],
const char (&S2)[N2],
229 template <
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3>
231 CasesLower(
const char (&S0)[N0],
const char (&S1)[N1],
const char (&S2)[N2],
232 const char (&S3)[N3],
const T &
Value) {
236 template <
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3,
unsigned N4>
238 CasesLower(
const char (&S0)[N0],
const char (&S1)[N1],
const char (&S2)[N2],
239 const char (&S3)[N3],
const char (&S4)[N4],
const T &
Value) {
252 assert(Result &&
"Fell off the end of a string-switch");
259 #endif // LLVM_ADT_STRINGSWITCH_H
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & CaseLower(const char(&S)[N], const T &Value)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & CasesLower(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const char(&S4)[N4], const T &Value)
LLVM_NODISCARD bool equals_lower(StringRef RHS) const
equals_lower - Check for string equality, ignoring case.
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const T &Value)
LLVM_NODISCARD bool endswith_lower(StringRef Suffix) const
Check if this string ends with the given Suffix, ignoring case.
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(const T &Value) const
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & EndsWith(const char(&S)[N], const T &Value)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(const char(&S)[N], const T &Value)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & CasesLower(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const T &Value)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const char(&S4)[N4], const T &Value)
A switch()-like statement whose cases are string literals.
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & StartsWithLower(const char(&S)[N], const T &Value)
StringSwitch & operator=(StringSwitch &&other)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & EndsWithLower(const char(&S)[N], const T &Value)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const char(&S4)[N4], const char(&S5)[N5], const char(&S6)[N6], const char(&S7)[N7], const char(&S8)[N8], const char(&S9)[N9], const T &Value)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const char(&S4)[N4], const char(&S5)[N5], const char(&S6)[N6], const char(&S7)[N7], const char(&S8)[N8], const T &Value)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const char(&S4)[N4], const char(&S5)[N5], const char(&S6)[N6], const T &Value)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const T &Value)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & CasesLower(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const T &Value)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const T &Value)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch(StringRef S)
StringSwitch(StringSwitch &&other)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & CasesLower(const char(&S0)[N0], const char(&S1)[N1], const T &Value)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const char(&S4)[N4], const char(&S5)[N5], const T &Value)
LLVM Value Representation.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
void operator=(const StringSwitch &)=delete
StringRef - Represent a constant reference to a string, i.e.
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & StartsWith(const char(&S)[N], const T &Value)
LLVM_NODISCARD bool startswith_lower(StringRef Prefix) const
Check if this string starts with the given Prefix, ignoring case.
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const char(&S4)[N4], const char(&S5)[N5], const char(&S6)[N6], const char(&S7)[N7], const T &Value)