13#ifndef ML_STRING_SWITCH_H
14#define ML_STRING_SWITCH_H
50template<
typename T,
typename R = T>
68 &&
N-1 == _string.size()
69 && (std::memcmp(s, _string.c_str(),
N-1) == 0))
79 if (!_result && s == _string)
92 && _string.size() >=
N-1
93 && std::memcmp(s, _string.c_str() + _string.size() + 1 -
N,
N-1) == 0)
105 && _string.size() >=
N-1
106 && std::memcmp(s, _string.c_str(),
N-1) == 0)
114 template<
unsigned N0,
unsigned N1>
117 return Case(
S0, Value).
Case(
S1, Value);
120 template<
unsigned N0,
unsigned N1,
unsigned N2>
126 template<
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3>
132 template<
unsigned N0,
unsigned N1,
unsigned N2,
unsigned N3,
unsigned N4>
147 template<
typename Ex,
typename ExP1>
157 template<
typename Ex,
typename ExP1,
typename ExP2>
167 template<
typename Ex,
typename ExP1,
typename ExP2,
typename ExP3>
181 throw std::domain_error(
"Fell off the end of the string switch");
187 const std::string _string;
StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const char(&S4)[N4], const T &Value)
StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const T &Value)
StringSwitch(const std::string &s)
StringSwitch(const char *s)
StringSwitch & StartsWith(const char(&s)[N], const T &Value)
StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const T &Value)
StringSwitch & EndsWith(const char(&s)[N], const T &Value)
StringSwitch & Case(const char(&s)[N], const T &Value)
R Throw(const ExP1 &p1, const ExP2 &p2) const
R Default(const T &Value) const
StringSwitch & Cases(const char(&S0)[N0], const char(&S1)[N1], const char(&S2)[N2], const char(&S3)[N3], const T &Value)
StringSwitch & Case(const std::string &s, const T &Value)
R Throw(const ExP1 &p1) const
R Throw(const ExP1 &p1, const ExP2 &p2, const ExP3 &p3) const
Target mlrange_cast(Source arg)
Generic version of checked ML casts.