13 #ifndef LLVM_ADT_STRINGSWITCH_H
14 #define LLVM_ADT_STRINGSWITCH_H
41 template<
typename T,
typename R = T>
52 : Str(S), Result(0) { }
56 if (!Result && N-1 == Str.
size() &&
66 if (!Result && Str.
size() >= N-1 &&
76 if (!Result && Str.
size() >= N-1 &&
84 template<
unsigned N0,
unsigned N1>
87 return Case(S0, Value).
Case(S1, Value);
90 template<
unsigned N0,
unsigned N1,
unsigned N2>
92 const char (&S2)[N2],
const T&
Value) {
96 template<
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3>
98 const char (&S2)[N2],
const char (&S3)[N3],
103 template<
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3,
unsigned N4>
105 const char (&S2)[N2],
const char (&S3)[N3],
106 const char (&S4)[N4],
const T&
Value) {
119 assert(Result &&
"Fell off the end of a string-switch");
126 #endif // LLVM_ADT_STRINGSWITCH_H
size_t size() const
size - Get the string size.
StringSwitch & Case(const char(&S)[N], const T &Value)
StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const T &Value)
StringSwitch & EndsWith(const char(&S)[N], const T &Value)
const char * data() const
int memcmp(const void *s1, const void *s2, size_t n);
A switch()-like statement whose cases are string literals.
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)
StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const T &Value)
StringSwitch & StartsWith(const char(&S)[N], const T &Value)
StringSwitch(StringRef S)
R Default(const T &Value) const
LLVM Value Representation.
StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const T &Value)