Botan 3.9.0
Crypto and TLS for C&
cpuid_features.cpp
Go to the documentation of this file.
1/**
2* (C) 2025 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/internal/cpuid_features.h>
8
9#include <botan/exceptn.h>
10
11namespace Botan {
12
13std::string CPUFeature::to_string() const {
14 switch(m_bit) {
15 case CPUFeature::Bit::LSX:
16 return "lsx";
17 case CPUFeature::Bit::LASX:
18 return "lasx";
19 case CPUFeature::Bit::CRYPTO:
20 return "crypto";
21 }
22 throw Invalid_State("CPUFeature invalid bit");
23}
24
25//static
26std::optional<CPUFeature> CPUFeature::from_string(std::string_view tok) {
27 if(tok == "lsx") {
28 return CPUFeature::Bit::LSX;
29 } else if(tok == "lasx") {
30 return CPUFeature::Bit::LASX;
31 } else if(tok == "crypto") {
32 return CPUFeature::Bit::CRYPTO;
33 } else {
34 return {};
35 }
36}
37
38} // namespace Botan
static std::optional< CPUFeature > from_string(std::string_view)
Definition cpuid.cpp:24
std::string to_string() const
Definition cpuid.cpp:28