AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::Impl::StringConvertImpl::For< bool, void > Struct Reference

#include "StringConvert.h"

Static Public Member Functions

static Optional< bool > FromString (std::string_view str, int strict=0)
 
static std::string ToString (bool val)
 

Detailed Description

Member Function Documentation

◆ FromString()

static Optional< bool > Acore::Impl::StringConvertImpl::For< bool, void >::FromString ( std::string_view  str,
int  strict = 0 
)
inlinestatic
97 {
98 if (strict)
99 {
100 if (str == "1")
101 {
102 return true;
103 }
104 if (str == "0")
105 {
106 return false;
107 }
108 return std::nullopt;
109 }
110 else
111 {
112 if ((str == "1") || StringEqualI(str, "y") || StringEqualI(str, "on") || StringEqualI(str, "yes") || StringEqualI(str, "true"))
113 {
114 return true;
115 }
116 if ((str == "0") || StringEqualI(str, "n") || StringEqualI(str, "off") || StringEqualI(str, "no") || StringEqualI(str, "false"))
117 {
118 return false;
119 }
120 return std::nullopt;
121 }
122 }
bool StringEqualI(std::string_view a, std::string_view b)
Definition: Util.cpp:592

References StringEqualI().

◆ ToString()

static std::string Acore::Impl::StringConvertImpl::For< bool, void >::ToString ( bool  val)
inlinestatic
125 {
126 return (val ? "1" : "0");
127 }