LLVM  14.0.0git
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.

◆ 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.

◆ ~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,
Value 
)
inline

Definition at line 67 of file StringSwitch.h.

References move, and S.

Referenced by llvm::AArch64StringToVectorLayout(), llvm::ARMCondCodeFromString(), llvm::ARMVectorCondCodeFromString(), llvm::StringSwitch< T, R >::Cases(), llvm::classifyEHPersonality(), llvm::ELF::convertArchNameToEMachine(), llvm::MachO::Target::create(), llvm::DwarfStreamer::emitSectionContents(), llvm::ARM::getArchSynonym(), llvm::Triple::getArchTypeForLLVMName(), llvm::DIFile::getChecksumKind(), llvm::DICompileUnit::getEmissionKind(), llvm::ARMAsmBackend::getFixupKind(), llvm::MipsAsmBackend::getFixupKind(), llvm::RISCVAsmBackend::getFixupKind(), llvm::ARM::getFPUSynonym(), llvm::sys::detail::getHostCPUNameForARM(), llvm::sys::detail::getHostCPUNameForPowerPC(), getHWDivSynonym(), getIdentifierKind(), llvm::getMachineType(), llvm::dwarf::getMacinfo(), getMClassFlagsMask(), getMetadataKeywordKind(), llvm::DICompileUnit::getNameTableKind(), llvm::dwarf::getOperationEncoding(), llvm::MachO::getPlatformFromName(), llvm::ConstrainedFPCmpIntrinsic::getPredicate(), llvm::RISCVTargetLowering::getRegForInlineAsmConstraint(), llvm::VETargetLowering::getRegisterByName(), llvm::LanaiTargetLowering::getRegisterByName(), llvm::SparcTargetLowering::getRegisterByName(), llvm::AVRTargetLowering::getRegisterByName(), llvm::HexagonTargetLowering::getRegisterByName(), llvm::MipsTargetLowering::getRegisterByName(), llvm::SITargetLowering::getRegisterByName(), llvm::SystemZTargetLowering::getRegisterByName(), llvm::PPCTargetLowering::getRegisterByName(), llvm::X86TargetLowering::getRegisterByName(), llvm::pdb::PDBSymbolCompiland::getSourceFileFullPath(), getSpecialRegForName(), llvm::RISCVABI::getTargetABI(), llvm::AMDGPU::HSAMD::MetadataStreamerV3::getValueKind(), llvm::RISCVMCExpr::getVariantKindForName(), llvm::VFABI::getVFParamKindFromString(), llvm::yaml::ScalarTraits< IFSEndiannessType >::input(), llvm::yaml::ScalarTraits< SwiftVersion >::input(), llvm::yaml::ScalarTraits< IFSBitWidthType >::input(), isSpecialLLVMGlobalArrayToSkip(), llvm::object::XCOFFObjectFile::mapDebugSectionName(), llvm::object::MachOObjectFile::mapDebugSectionName(), llvm::object::COFFObjectFile::mapDebugSectionName(), MCAttrForString(), llvm::HexagonMCInstrInfo::packetSize(), parseArch(), llvm::WebAssembly::parseBlockType(), parseConstraintCode(), llvm::parseDenormalFPAttributeComponent(), llvm::remarks::parseFormat(), llvm::WebAssembly::parseHeapType(), llvm::WebAssembly::parseMVT(), parseNamePrefix(), llvm::VEMCExpr::parseVariantKind(), llvm::SparcMCExpr::parseVariantKind(), parseVendor(), llvm::SymbolRemappingReader::read(), llvm::LPAC::stringToLanaiAluCode(), llvm::RISCVFPRndMode::stringToRoundingMode(), llvm::stringToVEFCondCode(), llvm::stringToVEICondCode(), llvm::stringToVERD(), llvm::StrToExceptionBehavior(), llvm::StrToRoundingMode(), and UpgradeIntrinsicFunction1().

◆ CaseLower()

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

Definition at line 140 of file StringSwitch.h.

References move, and S.

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,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
StringLiteral  S5,
StringLiteral  S6,
StringLiteral  S7,
StringLiteral  S8,
StringLiteral  S9,
Value 
)
inline

◆ Cases() [2/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,
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,
StringLiteral  S4,
StringLiteral  S5,
StringLiteral  S6,
StringLiteral  S7,
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,
StringLiteral  S5,
StringLiteral  S6,
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,
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,
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,
Value 
)
inline

◆ Cases() [8/9]

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

◆ Cases() [9/9]

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

◆ CasesLower() [1/4]

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

◆ CasesLower() [2/4]

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

◆ CasesLower() [3/4]

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

◆ CasesLower() [4/4]

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

◆ Default()

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

Definition at line 181 of file StringSwitch.h.

References move.

Referenced by llvm::AArch64StringToVectorLayout(), llvm::ARMCondCodeFromString(), llvm::ARMVectorCondCodeFromString(), llvm::classifyEHPersonality(), llvm::ELF::convertArchNameToEMachine(), llvm::MachO::Target::create(), llvm::DwarfStreamer::emitSectionContents(), llvm::MachO::getArchitectureFromName(), llvm::ARM::getArchSynonym(), llvm::Triple::getArchTypeForLLVMName(), llvm::dwarf::getAttributeEncoding(), llvm::Attribute::getAttrKindFromName(), llvm::dwarf::getCallingConvention(), llvm::DIFile::getChecksumKind(), llvm::AArch64::getCPUArchKind(), llvm::AArch64::getDefaultExtensions(), llvm::ARM::getDefaultExtensions(), llvm::AArch64::getDefaultFPU(), llvm::ARM::getDefaultFPU(), llvm::DICompileUnit::getEmissionKind(), llvm::ARMAsmBackend::getFixupKind(), llvm::RISCVAsmBackend::getFixupKind(), llvm::DINode::getFlag(), llvm::DISubprogram::getFlag(), llvm::ARM::getFPUSynonym(), llvm::sys::detail::getHostCPUNameForARM(), llvm::sys::detail::getHostCPUNameForPowerPC(), getHWDivSynonym(), getIdentifierKind(), llvm::dwarf::getLanguage(), llvm::getMachineType(), llvm::dwarf::getMacinfo(), llvm::dwarf::getMacro(), getMClassFlagsMask(), getMetadataKeywordKind(), llvm::DICompileUnit::getNameTableKind(), llvm::omp::getOpenMPContextTraitPropertyForSelector(), llvm::omp::getOpenMPContextTraitSelectorKind(), llvm::omp::getOpenMPContextTraitSetKind(), llvm::dwarf::getOperationEncoding(), llvm::MachO::getPlatformFromName(), llvm::ConstrainedFPCmpIntrinsic::getPredicate(), llvm::RISCVTargetLowering::getRegForInlineAsmConstraint(), llvm::VETargetLowering::getRegisterByName(), llvm::LanaiTargetLowering::getRegisterByName(), llvm::SparcTargetLowering::getRegisterByName(), llvm::AVRTargetLowering::getRegisterByName(), llvm::HexagonTargetLowering::getRegisterByName(), llvm::MipsTargetLowering::getRegisterByName(), llvm::SITargetLowering::getRegisterByName(), llvm::SystemZTargetLowering::getRegisterByName(), llvm::PPCTargetLowering::getRegisterByName(), llvm::X86TargetLowering::getRegisterByName(), llvm::pdb::PDBSymbolCompiland::getSourceFileFullPath(), getSpecialRegForName(), llvm::dwarf::getTag(), llvm::RISCVABI::getTargetABI(), llvm::AMDGPU::HSAMD::MetadataStreamerV3::getValueKind(), llvm::RISCVMCExpr::getVariantKindForName(), llvm::VFABI::getVFParamKindFromString(), llvm::dwarf::getVirtuality(), llvm::yaml::ScalarTraits< IFSEndiannessType >::input(), llvm::yaml::ScalarTraits< SwiftVersion >::input(), llvm::yaml::ScalarTraits< IFSBitWidthType >::input(), llvm::Attribute::isExistingAttribute(), isSpecialLLVMGlobalArrayForStaticInit(), isSpecialLLVMGlobalArrayToSkip(), llvm::remarks::magicToFormat(), llvm::object::XCOFFObjectFile::mapDebugSectionName(), llvm::object::MachOObjectFile::mapDebugSectionName(), llvm::object::COFFObjectFile::mapDebugSectionName(), MaybePredicatedInst(), MCAttrForString(), llvm::HexagonMCInstrInfo::packetSize(), parseArch(), llvm::ARM::parseArchISA(), llvm::WebAssembly::parseBlockType(), parseConstraintCode(), llvm::RISCV::parseCPUKind(), llvm::parseDenormalFPAttributeComponent(), parseEnvironment(), llvm::remarks::parseFormat(), parseFormat(), llvm::WebAssembly::parseHeapType(), llvm::WebAssembly::parseMVT(), parseNamePrefix(), parseOS(), parseSubArch(), llvm::RISCV::parseTuneCPUKind(), llvm::VEMCExpr::parseVariantKind(), llvm::SparcMCExpr::parseVariantKind(), parseVendor(), llvm::SymbolRemappingReader::read(), llvm::RISCV::resolveTuneCPUAlias(), SizeForSuffix(), llvm::LPAC::stringToLanaiAluCode(), llvm::RISCVFPRndMode::stringToRoundingMode(), llvm::stringToVEFCondCode(), llvm::stringToVEICondCode(), llvm::stringToVERD(), llvm::StrToExceptionBehavior(), llvm::StrToRoundingMode(), llvm::LPCC::suffixToLanaiCondCode(), llvm::Triple::Triple(), and UpgradeIntrinsicFunction1().

◆ EndsWith()

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

Definition at line 74 of file StringSwitch.h.

References move, and S.

Referenced by parseFormat(), parseSubArch(), SizeForSuffix(), and llvm::LPCC::suffixToLanaiCondCode().

◆ EndsWithLower()

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

Definition at line 147 of file StringSwitch.h.

References S.

◆ 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(), and move.

◆ 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,
Value 
)
inline

◆ StartsWithLower()

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

Definition at line 154 of file StringSwitch.h.

References move, and S.


The documentation for this class was generated from the following file:
i
i
Definition: README.txt:29