LLVM  9.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

 StringSwitch (StringRef S)
 
 StringSwitch (const StringSwitch &)=delete
 
void operator= (const StringSwitch &)=delete
 
void operator= (StringSwitch &&other)=delete
 
 StringSwitch (StringSwitch &&other)
 
 ~StringSwitch ()=default
 
StringSwitchCase (StringLiteral S, T Value)
 
StringSwitchEndsWith (StringLiteral S, T Value)
 
StringSwitchStartsWith (StringLiteral S, T Value)
 
StringSwitchCases (StringLiteral S0, StringLiteral S1, T Value)
 
StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, T Value)
 
StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, T Value)
 
StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, T Value)
 
StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, T Value)
 
StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, T Value)
 
StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, StringLiteral S7, T Value)
 
StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, StringLiteral S7, StringLiteral S8, T Value)
 
StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, StringLiteral S7, StringLiteral S8, StringLiteral S9, T Value)
 
StringSwitchCaseLower (StringLiteral S, T Value)
 
StringSwitchEndsWithLower (StringLiteral S, T Value)
 
StringSwitchStartsWithLower (StringLiteral S, T Value)
 
StringSwitchCasesLower (StringLiteral S0, StringLiteral S1, T Value)
 
StringSwitchCasesLower (StringLiteral S0, StringLiteral S1, StringLiteral S2, T Value)
 
StringSwitchCasesLower (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, T Value)
 
StringSwitchCasesLower (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, T Value)
 
LLVM_NODISCARDDefault (T Value)
 
LLVM_NODISCARD operator R ()
 

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

Constructor & Destructor Documentation

◆ StringSwitch() [1/3]

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

Definition at line 51 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 61 of file StringSwitch.h.

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

◆ ~StringSwitch()

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

Member Function Documentation

◆ Case()

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::Case ( StringLiteral  S,
T  Value 
)
inline

Definition at line 67 of file StringSwitch.h.

Referenced by llvm::AArch64StringToVectorLayout(), llvm::ARMCondCodeFromString(), llvm::StringSwitch< T, R >::Cases(), checkParametrizedPassName(), llvm::classifyEHPersonality(), llvm::RISCVABI::computeTargetABI(), llvm::DWARFContext::defaultErrorHandler(), llvm::AMDGPU::HSAMD::MetadataStreamerV2::emitKernel(), llvm::MipsSEFrameLowering::emitPrologue(), encodeCnt(), llvm::ARM::getArchSynonym(), llvm::Triple::getArchTypeForLLVMName(), getARClassRegisterMask(), llvm::DIFile::getChecksumKind(), llvm::DICompileUnit::getEmissionKind(), getEmulation(), llvm::ConstrainedFPIntrinsic::getExceptionBehavior(), llvm::MipsAsmBackend::getFixupKind(), llvm::ARM::getFPUSynonym(), llvm::sys::detail::getHostCPUNameForARM(), llvm::sys::detail::getHostCPUNameForPowerPC(), llvm::sys::getHostNumPhysicalCores(), getIdentifierKind(), llvm::TGLexer::getLoc(), llvm::dwarf::getMacinfo(), getMClassFlagsMask(), getMetadataKeywordKind(), llvm::DICompileUnit::getNameTableKind(), getNextRegister(), getOSTypeFromPlatform(), llvm::LanaiTargetLowering::getRegisterByName(), llvm::SparcTargetLowering::getRegisterByName(), llvm::AVRTargetLowering::getRegisterByName(), llvm::SITargetLowering::getRegisterByName(), llvm::PPCTargetLowering::getRegisterByName(), llvm::X86TargetLowering::getRegisterByName(), getRelaxedOpcode(), llvm::ConstrainedFPIntrinsic::getRoundingMode(), llvm::pdb::PDBSymbolCompiland::getSourceFileFullPath(), getSpecialRegForName(), llvm::RISCVMCExpr::getVariantKindForName(), llvm::object::WasmObjectFile::getWasmRelocation(), llvm::yaml::ScalarTraits< ELFArchMapper >::input(), llvm::yaml::ScalarTraits< SwiftVersion >::input(), isRegOrImmWithInputMods(), llvm::object::MachOObjectFile::isValidArch(), MCAttrForString(), llvm::yaml::ScalarTraits< FlowStringRef >::mustQuote(), parseArch(), parseAttrKind(), parseNamePrefix(), llvm::SparcMCExpr::parseVariantKind(), parseVendor(), llvm::SymbolRemappingReader::read(), RefineErrorLoc(), llvm::LPAC::stringToLanaiAluCode(), llvm::RISCVFPRndMode::stringToRoundingMode(), UpgradeIntrinsicFunction1(), and verifyAddrSpace().

◆ CaseLower()

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::CaseLower ( StringLiteral  S,
T  Value 
)
inline

Definition at line 140 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>
StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
T  Value 
)
inline

◆ Cases() [2/9]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
T  Value 
)
inline

◆ Cases() [3/9]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
T  Value 
)
inline

◆ Cases() [4/9]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
T  Value 
)
inline

◆ Cases() [5/9]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
StringLiteral  S5,
T  Value 
)
inline

◆ Cases() [6/9]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
StringLiteral  S5,
StringLiteral  S6,
T  Value 
)
inline

◆ Cases() [7/9]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
StringLiteral  S5,
StringLiteral  S6,
StringLiteral  S7,
T  Value 
)
inline

◆ Cases() [8/9]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
StringLiteral  S5,
StringLiteral  S6,
StringLiteral  S7,
StringLiteral  S8,
T  Value 
)
inline

◆ Cases() [9/9]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
StringLiteral  S5,
StringLiteral  S6,
StringLiteral  S7,
StringLiteral  S8,
StringLiteral  S9,
T  Value 
)
inline

◆ CasesLower() [1/4]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( StringLiteral  S0,
StringLiteral  S1,
T  Value 
)
inline

◆ CasesLower() [2/4]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
T  Value 
)
inline

◆ CasesLower() [3/4]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
T  Value 
)
inline

◆ CasesLower() [4/4]

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
T  Value 
)
inline

◆ Default()

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

Definition at line 181 of file StringSwitch.h.

References LLVM_NODISCARD.

Referenced by llvm::AArch64StringToVectorLayout(), llvm::ARMCondCodeFromString(), checkParametrizedPassName(), llvm::classifyEHPersonality(), llvm::RISCVABI::computeTargetABI(), llvm::createX86_64AsmBackend(), llvm::DWARFContext::defaultErrorHandler(), llvm::AMDGPU::HSAMD::MetadataStreamerV2::emitKernel(), llvm::MipsSEFrameLowering::emitPrologue(), encodeCnt(), llvm::ARM::getArchSynonym(), llvm::Triple::getArchTypeForLLVMName(), getARClassRegisterMask(), llvm::DIFile::getChecksumKind(), llvm::DICompileUnit::getEmissionKind(), getEmulation(), llvm::ConstrainedFPIntrinsic::getExceptionBehavior(), llvm::MipsAsmBackend::getFixupKind(), llvm::ARM::getFPUSynonym(), llvm::sys::detail::getHostCPUNameForARM(), llvm::sys::detail::getHostCPUNameForPowerPC(), llvm::sys::getHostNumPhysicalCores(), getHWDivSynonym(), getIdentifierKind(), llvm::TGLexer::getLoc(), llvm::dwarf::getMacinfo(), getMClassFlagsMask(), getMetadataKeywordKind(), llvm::DICompileUnit::getNameTableKind(), getNextRegister(), getOSTypeFromPlatform(), llvm::LanaiTargetLowering::getRegisterByName(), llvm::SparcTargetLowering::getRegisterByName(), llvm::AVRTargetLowering::getRegisterByName(), llvm::HexagonTargetLowering::getRegisterByName(), llvm::SITargetLowering::getRegisterByName(), llvm::MipsTargetLowering::getRegisterByName(), llvm::PPCTargetLowering::getRegisterByName(), llvm::X86TargetLowering::getRegisterByName(), getRelaxedOpcode(), llvm::ConstrainedFPIntrinsic::getRoundingMode(), llvm::pdb::PDBSymbolCompiland::getSourceFileFullPath(), getSpecialRegForName(), llvm::RISCVMCExpr::getVariantKindForName(), llvm::object::WasmObjectFile::getWasmRelocation(), llvm::yaml::ScalarTraits< ELFArchMapper >::input(), llvm::yaml::ScalarTraits< SwiftVersion >::input(), isRegOrImmWithInputMods(), llvm::object::MachOObjectFile::isValidArch(), LowerVectorINT_TO_FP(), llvm::object::MachOObjectFile::mapDebugSectionName(), llvm::object::COFFObjectFile::mapDebugSectionName(), MaybePredicatedInst(), MCAttrForString(), llvm::yaml::ScalarTraits< FlowStringRef >::mustQuote(), parseArch(), llvm::ARM::parseArchISA(), parseAttrKind(), parseEnvironment(), parseFormat(), parseNamePrefix(), parseOS(), parseSubArch(), llvm::SparcMCExpr::parseVariantKind(), parseVendor(), llvm::SymbolRemappingReader::read(), RefineErrorLoc(), SizeForSuffix(), llvm::LPAC::stringToLanaiAluCode(), llvm::RISCVFPRndMode::stringToRoundingMode(), llvm::LPCC::suffixToLanaiCondCode(), llvm::Triple::Triple(), UpgradeIntrinsicFunction1(), and verifyAddrSpace().

◆ EndsWith()

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::EndsWith ( StringLiteral  S,
T  Value 
)
inline

◆ EndsWithLower()

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::EndsWithLower ( StringLiteral  S,
T  Value 
)
inline

Definition at line 147 of file StringSwitch.h.

References llvm::StringRef::endswith_lower().

◆ operator R()

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

Definition at line 188 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>
void llvm::StringSwitch< T, R >::operator= ( StringSwitch< T, R > &&  other)
delete

◆ StartsWith()

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::StartsWith ( StringLiteral  S,
T  Value 
)
inline

◆ StartsWithLower()

template<typename T, typename R = T>
StringSwitch& llvm::StringSwitch< T, R >::StartsWithLower ( StringLiteral  S,
T  Value 
)
inline

Definition at line 154 of file StringSwitch.h.

References llvm::StringRef::startswith_lower().


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