LLVM  6.0.0svn
Public Member Functions | List of all members
llvm::StringSwitch< T, R > Class Template Reference

A switch()-like statement whose cases are string literals. More...

#include "llvm/ADT/StringSwitch.h"

Public Member Functions

LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch (StringRef S)
 
 StringSwitch (const StringSwitch &)=delete
 
void operator= (const StringSwitch &)=delete
 
 StringSwitch (StringSwitch &&other)
 
StringSwitchoperator= (StringSwitch &&other)
 
 ~StringSwitch ()=default
 
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCase (const char(&S)[N], const T &Value)
 
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchEndsWith (const char(&S)[N], const T &Value)
 
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchStartsWith (const char(&S)[N], const T &Value)
 
template<unsigned N0, unsigned N1>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (const char(&S0)[N0], const char(&S1)[N1], const T &Value)
 
template<unsigned N0, unsigned N1, unsigned N2>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const T &Value)
 
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (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>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const char(&S4)[N4], const T &Value)
 
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4, unsigned N5>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (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)
 
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4, unsigned N5, unsigned N6>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (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)
 
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4, unsigned N5, unsigned N6, unsigned N7>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (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)
 
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4, unsigned N5, unsigned N6, unsigned N7, unsigned N8>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (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)
 
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4, unsigned N5, unsigned N6, unsigned N7, unsigned N8, unsigned N9>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (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)
 
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCaseLower (const char(&S)[N], const T &Value)
 
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchEndsWithLower (const char(&S)[N], const T &Value)
 
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchStartsWithLower (const char(&S)[N], const T &Value)
 
template<unsigned N0, unsigned N1>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCasesLower (const char(&S0)[N0], const char(&S1)[N1], const T &Value)
 
template<unsigned N0, unsigned N1, unsigned N2>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCasesLower (const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const T &Value)
 
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCasesLower (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>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCasesLower (const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const char(&S4)[N4], const T &Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINEDefault (const T &Value) const
 
LLVM_ATTRIBUTE_ALWAYS_INLINE operator R () const
 

Detailed Description

template<typename T, typename R = T>
class llvm::StringSwitch< T, R >

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 43 of file StringSwitch.h.

Constructor & Destructor Documentation

◆ StringSwitch() [1/3]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE llvm::StringSwitch< T, R >::StringSwitch ( StringRef  S)
inlineexplicit

Definition at line 53 of file StringSwitch.h.

References llvm::StringSwitch< T, R >::operator=().

◆ StringSwitch() [2/3]

template<typename T , typename R = T>
llvm::StringSwitch< T, R >::StringSwitch ( const StringSwitch< T, R > &  )
delete

◆ StringSwitch() [3/3]

template<typename T , typename R = T>
llvm::StringSwitch< T, R >::StringSwitch ( StringSwitch< T, R > &&  other)
inline

Definition at line 60 of file StringSwitch.h.

◆ ~StringSwitch()

template<typename T , typename R = T>
llvm::StringSwitch< T, R >::~StringSwitch ( )
default

Member Function Documentation

◆ Case()

template<typename T , typename R = T>
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Case ( const char(&)  S[N],
const T Value 
)
inline

Definition at line 74 of file StringSwitch.h.

References assert(), llvm::StringRef::data(), LLVM_ATTRIBUTE_ALWAYS_INLINE, memcmp, and llvm::StringRef::size().

Referenced by llvm::AArch64StringToVectorLayout(), llvm::ARMCondCodeFromString(), llvm::StringSwitch< T, R >::Cases(), CheckBaseRegAndIndexRegAndScale(), llvm::classifyEHPersonality(), llvm::DWARFContext::defaultErrorHandler(), llvm::MipsSEFrameLowering::emitPrologue(), encodeCnt(), getArchSynonym(), llvm::Triple::getArchTypeForLLVMName(), getARClassRegisterMask(), llvm::DIFile::getChecksumKind(), llvm::DICompileUnit::getEmissionKind(), getEmulation(), llvm::ConstrainedFPIntrinsic::getExceptionBehavior(), getFPUSynonym(), llvm::objcarc::GetFunctionClass(), llvm::sys::detail::getHostCPUNameForARM(), llvm::sys::detail::getHostCPUNameForPowerPC(), llvm::sys::getHostNumPhysicalCores(), getIdentifierKind(), llvm::TGLexer::getLoc(), llvm::dwarf::getMacinfo(), getMClassFlagsMask(), getMetadataKeywordKind(), getNextRegister(), llvm::LanaiTargetLowering::getRegisterByName(), llvm::SparcTargetLowering::getRegisterByName(), llvm::AVRTargetLowering::getRegisterByName(), llvm::SITargetLowering::getRegisterByName(), llvm::PPCTargetLowering::getRegisterByName(), llvm::X86TargetLowering::getRegisterByName(), getRelaxedOpcode(), llvm::ConstrainedFPIntrinsic::getRoundingMode(), getSpecialRegForName(), llvm::RISCVMCExpr::getVariantKindForName(), isImplicitOperandIn(), isLoopPassName(), isRegOrImmWithInputMods(), llvm::object::MachOObjectFile::isValidArch(), llvm::object::Lexer::lex(), mayTailCallThisCC(), MCAttrForString(), parseArch(), parseAttrKind(), parseNamePrefix(), parsePhysicalReg(), parseValidVectorKind(), llvm::SparcMCExpr::parseVariantKind(), parseVendor(), RefineErrorLoc(), setRequiredFeatureString(), llvm::LPAC::stringToLanaiAluCode(), and UpgradeIntrinsicFunction1().

◆ CaseLower()

template<typename T , typename R = T>
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::CaseLower ( const char(&)  S[N],
const T Value 
)
inline

Definition at line 191 of file StringSwitch.h.

References llvm::StringRef::equals_lower().

Referenced by llvm::StringSwitch< T, R >::CasesLower().

◆ Cases() [1/9]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Cases ( const char(&)  S0[N0],
const char(&)  S1[N1],
const T Value 
)
inline

◆ Cases() [2/9]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1, unsigned N2>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Cases ( const char(&)  S0[N0],
const char(&)  S1[N1],
const char(&)  S2[N2],
const T Value 
)
inline

◆ Cases() [3/9]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3>
LLVM_ATTRIBUTE_ALWAYS_INLINE 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

◆ Cases() [4/9]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4>
LLVM_ATTRIBUTE_ALWAYS_INLINE 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

◆ Cases() [5/9]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4, unsigned N5>
LLVM_ATTRIBUTE_ALWAYS_INLINE 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 char(&)  S5[N5],
const T Value 
)
inline

◆ Cases() [6/9]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4, unsigned N5, unsigned N6>
LLVM_ATTRIBUTE_ALWAYS_INLINE 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 char(&)  S5[N5],
const char(&)  S6[N6],
const T Value 
)
inline

◆ Cases() [7/9]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4, unsigned N5, unsigned N6, unsigned N7>
LLVM_ATTRIBUTE_ALWAYS_INLINE 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 char(&)  S5[N5],
const char(&)  S6[N6],
const char(&)  S7[N7],
const T Value 
)
inline

◆ Cases() [8/9]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4, unsigned N5, unsigned N6, unsigned N7, unsigned N8>
LLVM_ATTRIBUTE_ALWAYS_INLINE 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 char(&)  S5[N5],
const char(&)  S6[N6],
const char(&)  S7[N7],
const char(&)  S8[N8],
const T Value 
)
inline

◆ Cases() [9/9]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4, unsigned N5, unsigned N6, unsigned N7, unsigned N8, unsigned N9>
LLVM_ATTRIBUTE_ALWAYS_INLINE 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 char(&)  S5[N5],
const char(&)  S6[N6],
const char(&)  S7[N7],
const char(&)  S8[N8],
const char(&)  S9[N9],
const T Value 
)
inline

◆ CasesLower() [1/4]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( const char(&)  S0[N0],
const char(&)  S1[N1],
const T Value 
)
inline

◆ CasesLower() [2/4]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1, unsigned N2>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( const char(&)  S0[N0],
const char(&)  S1[N1],
const char(&)  S2[N2],
const T Value 
)
inline

◆ CasesLower() [3/4]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( const char(&)  S0[N0],
const char(&)  S1[N1],
const char(&)  S2[N2],
const char(&)  S3[N3],
const T Value 
)
inline

◆ CasesLower() [4/4]

template<typename T , typename R = T>
template<unsigned N0, unsigned N1, unsigned N2, unsigned N3, unsigned N4>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( const char(&)  S0[N0],
const char(&)  S1[N1],
const char(&)  S2[N2],
const char(&)  S3[N3],
const char(&)  S4[N4],
const T Value 
)
inline

◆ Default()

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE R llvm::StringSwitch< T, R >::Default ( const T Value) const
inline

Definition at line 244 of file StringSwitch.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE.

Referenced by llvm::AArch64StringToVectorLayout(), llvm::ARMCondCodeFromString(), CheckBaseRegAndIndexRegAndScale(), llvm::classifyEHPersonality(), llvm::createX86_64AsmBackend(), llvm::DWARFContext::defaultErrorHandler(), llvm::MipsSEFrameLowering::emitPrologue(), encodeCnt(), getArchSynonym(), llvm::Triple::getArchTypeForLLVMName(), getARClassRegisterMask(), llvm::DIFile::getChecksumKind(), llvm::DICompileUnit::getEmissionKind(), getEmulation(), llvm::ConstrainedFPIntrinsic::getExceptionBehavior(), llvm::MipsAsmBackend::getFixupKind(), getFPUSynonym(), llvm::objcarc::GetFunctionClass(), llvm::sys::detail::getHostCPUNameForARM(), llvm::sys::detail::getHostCPUNameForPowerPC(), llvm::sys::getHostNumPhysicalCores(), getHWDivSynonym(), getIdentifierKind(), llvm::TGLexer::getLoc(), llvm::dwarf::getMacinfo(), getMClassFlagsMask(), getMetadataKeywordKind(), getNextRegister(), llvm::LanaiTargetLowering::getRegisterByName(), llvm::SparcTargetLowering::getRegisterByName(), llvm::AVRTargetLowering::getRegisterByName(), llvm::SITargetLowering::getRegisterByName(), llvm::MipsTargetLowering::getRegisterByName(), llvm::PPCTargetLowering::getRegisterByName(), llvm::X86TargetLowering::getRegisterByName(), getRelaxedOpcode(), llvm::ConstrainedFPIntrinsic::getRoundingMode(), getSpecialRegForName(), llvm::RISCVMCExpr::getVariantKindForName(), isImplicitOperandIn(), isRegOrImmWithInputMods(), llvm::object::MachOObjectFile::isValidArch(), llvm::object::Lexer::lex(), LowerVectorINT_TO_FP(), llvm::object::MachOObjectFile::mapDebugSectionName(), MaybePredicatedInst(), mayTailCallThisCC(), MCAttrForString(), parseArch(), llvm::ARM::parseArchISA(), parseAttrKind(), parseEnvironment(), parseFormat(), parseNamePrefix(), parseOS(), parsePhysicalReg(), parseSubArch(), parseValidVectorKind(), llvm::SparcMCExpr::parseVariantKind(), parseVendor(), RefineErrorLoc(), setRequiredFeatureString(), SizeForSuffix(), llvm::LPAC::stringToLanaiAluCode(), llvm::LPCC::suffixToLanaiCondCode(), and UpgradeIntrinsicFunction1().

◆ EndsWith()

template<typename T , typename R = T>
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::EndsWith ( const char(&)  S[N],
const T Value 
)
inline

◆ EndsWithLower()

template<typename T , typename R = T>
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::EndsWithLower ( const char(&)  S[N],
const T Value 
)
inline

Definition at line 200 of file StringSwitch.h.

References llvm::StringRef::endswith_lower().

◆ operator R()

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE llvm::StringSwitch< T, R >::operator R ( ) const
inline

Definition at line 251 of file StringSwitch.h.

References assert().

◆ operator=() [1/2]

template<typename T , typename R = T>
void llvm::StringSwitch< T, R >::operator= ( const StringSwitch< T, R > &  )
delete

◆ operator=() [2/2]

template<typename T , typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::operator= ( StringSwitch< T, R > &&  other)
inline

◆ StartsWith()

template<typename T , typename R = T>
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::StartsWith ( const char(&)  S[N],
const T Value 
)
inline

◆ StartsWithLower()

template<typename T , typename R = T>
template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::StartsWithLower ( const char(&)  S[N],
const T Value 
)
inline

The documentation for this class was generated from the following file: