13 #ifndef LLVM_ADT_STRINGSWITCH_H
14 #define LLVM_ADT_STRINGSWITCH_H
41 template<
typename T,
typename R = T>
52 : Str(S), Result(nullptr) { }
56 if (!Result && N-1 == Str.
size() &&
57 (std::memcmp(S, Str.
data(), N-1) == 0)) {
66 if (!Result && Str.
size() >= N-1 &&
67 std::memcmp(S, Str.
data() + Str.
size() + 1 -
N, N-1) == 0) {
76 if (!Result && Str.
size() >= N-1 &&
77 std::memcmp(S, Str.
data(), N-1) == 0) {
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
data - Get a pointer to the start of the string (which may not be null terminated).
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)
StringRef - Represent a constant reference to a string, i.e.