LLVM API Documentation
A switch()-like statement whose cases are string literals. More...
#include <StringSwitch.h>
Public Member Functions | |
StringSwitch (StringRef S) | |
template<unsigned N> | |
StringSwitch & | Case (const char(&S)[N], const T &Value) |
template<unsigned N> | |
StringSwitch & | EndsWith (const char(&S)[N], const T &Value) |
template<unsigned N> | |
StringSwitch & | StartsWith (const char(&S)[N], const T &Value) |
template<unsigned N0, unsigned N1> | |
StringSwitch & | Cases (const char(&S0)[N0], const char(&S1)[N1], const T &Value) |
template<unsigned N0, unsigned N1, unsigned N2> | |
StringSwitch & | Cases (const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const T &Value) |
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3> | |
StringSwitch & | Cases (const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const T &Value) |
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4> | |
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) |
R | Default (const T &Value) const |
operator R () const |
A switch()-like statement whose cases are string literals.
The StringSwitch class is a simple form of a switch() statement that determines whether the given string matches one of the given string literals. The template type parameter T
is the type of the value that will be returned from the string-switch expression. For example, the following code switches on the name of a color in argv
[i]:
Color color = StringSwitch<Color>(argv[i]) .Case("red", Red) .Case("orange", Orange) .Case("yellow", Yellow) .Case("green", Green) .Case("blue", Blue) .Case("indigo", Indigo) .Cases("violet", "purple", Violet) .Default(UnknownColor);
Definition at line 42 of file StringSwitch.h.
llvm::StringSwitch< T, R >::StringSwitch | ( | StringRef | S | ) | [inline, explicit] |
Definition at line 51 of file StringSwitch.h.
StringSwitch& llvm::StringSwitch< T, R >::Case | ( | const char(&) | S[N], |
const T & | Value | ||
) | [inline] |
Definition at line 55 of file StringSwitch.h.
References llvm::StringRef::data(), llvm::LibFunc::memcmp, and llvm::StringRef::size().
Referenced by llvm::AArch64StringToVectorLayout(), llvm::StringSwitch< T, R >::Cases(), llvm::DWARFContextInMemory::DWARFContextInMemory(), llvm::Triple::getArchTypeForLLVMName(), llvm::Triple::getARMCPUForArch(), llvm::objcarc::GetFunctionClass(), llvm::PPCTargetLowering::getRegisterByName(), llvm::object::MachOObjectFile::isValidArch(), LowerINTRINSIC_W_CHAIN(), MCAttrForString(), parseArch(), llvm::SparcMCExpr::parseVariantKind(), parseVendor(), and RecognizePersonality().
StringSwitch& llvm::StringSwitch< T, R >::Cases | ( | const char(&) | S0[N0], |
const char(&) | S1[N1], | ||
const T & | Value | ||
) | [inline] |
Definition at line 85 of file StringSwitch.h.
References llvm::StringSwitch< T, R >::Case().
Referenced by llvm::createARMAsmBackend(), llvm::Triple::getARMCPUForArch(), getIntelMemOperandSize(), MCAttrForString(), and parseArch().
StringSwitch& llvm::StringSwitch< T, R >::Cases | ( | const char(&) | S0[N0], |
const char(&) | S1[N1], | ||
const char(&) | S2[N2], | ||
const T & | Value | ||
) | [inline] |
Definition at line 91 of file StringSwitch.h.
References llvm::StringSwitch< T, R >::Case().
StringSwitch& llvm::StringSwitch< T, R >::Cases | ( | const char(&) | S0[N0], |
const char(&) | S1[N1], | ||
const char(&) | S2[N2], | ||
const char(&) | S3[N3], | ||
const T & | Value | ||
) | [inline] |
Definition at line 97 of file StringSwitch.h.
References llvm::StringSwitch< T, R >::Case().
StringSwitch& llvm::StringSwitch< T, R >::Cases | ( | const char(&) | S0[N0], |
const char(&) | S1[N1], | ||
const char(&) | S2[N2], | ||
const char(&) | S3[N3], | ||
const char(&) | S4[N4], | ||
const T & | Value | ||
) | [inline] |
Definition at line 104 of file StringSwitch.h.
References llvm::StringSwitch< T, R >::Case().
R llvm::StringSwitch< T, R >::Default | ( | const T & | Value | ) | const [inline] |
Definition at line 111 of file StringSwitch.h.
Referenced by llvm::AArch64StringToVectorLayout(), llvm::createARMAsmBackend(), llvm::createX86_64AsmBackend(), llvm::DWARFContextInMemory::DWARFContextInMemory(), llvm::Triple::getArchTypeForLLVMName(), llvm::Triple::getARMCPUForArch(), llvm::objcarc::GetFunctionClass(), getIntelMemOperandSize(), llvm::PPCTargetLowering::getRegisterByName(), llvm::object::MachOObjectFile::isValidArch(), LowerINTRINSIC_W_CHAIN(), MCAttrForString(), parseArch(), parseEnvironment(), parseFormat(), parseOS(), parseSubArch(), llvm::SparcMCExpr::parseVariantKind(), parseVendor(), and RecognizePersonality().
StringSwitch& llvm::StringSwitch< T, R >::EndsWith | ( | const char(&) | S[N], |
const T & | Value | ||
) | [inline] |
Definition at line 65 of file StringSwitch.h.
References llvm::StringRef::data(), llvm::LibFunc::memcmp, and llvm::StringRef::size().
Referenced by parseFormat(), and parseSubArch().
llvm::StringSwitch< T, R >::operator R | ( | ) | const [inline] |
Definition at line 118 of file StringSwitch.h.
StringSwitch& llvm::StringSwitch< T, R >::StartsWith | ( | const char(&) | S[N], |
const T & | Value | ||
) | [inline] |
Definition at line 75 of file StringSwitch.h.
References llvm::StringRef::data(), llvm::LibFunc::memcmp, and llvm::StringRef::size().
Referenced by parseArch(), parseEnvironment(), and parseOS().