10 #ifndef CHAISCRIPT_ALGEBRAIC_HPP_ 11 #define CHAISCRIPT_ALGEBRAIC_HPP_ 13 #include "../utility/hash.hpp" 55 constexpr
static const char *to_string(Opers t_oper) noexcept {
56 constexpr
const char *opers[]
57 = {
"",
"==",
"<",
">",
"<=",
">=",
"!=",
"",
"=",
"++",
"--",
"*=",
"+=",
"/=",
"-=",
"",
"&=",
"|=",
"<<=",
">>=",
"%=",
"^=",
"",
"<<",
">>",
"%",
"&",
"|",
"^",
"~",
"",
"+",
"/",
"*",
"-",
"+",
"-",
""};
58 return opers[
static_cast<int>(t_oper)];
61 constexpr
static Opers to_operator(std::string_view t_str,
bool t_is_unary =
false) noexcept {
62 #ifdef CHAISCRIPT_MSVC 64 #pragma warning(disable : 4307) 67 const auto op_hash = utility::hash(t_str);
69 case utility::hash(
"=="): {
72 case utility::hash(
"<"): {
73 return Opers::less_than;
75 case utility::hash(
">"): {
76 return Opers::greater_than;
78 case utility::hash(
"<="): {
79 return Opers::less_than_equal;
81 case utility::hash(
">="): {
82 return Opers::greater_than_equal;
84 case utility::hash(
"!="): {
85 return Opers::not_equal;
87 case utility::hash(
"="): {
90 case utility::hash(
"++"): {
91 return Opers::pre_increment;
93 case utility::hash(
"--"): {
94 return Opers::pre_decrement;
96 case utility::hash(
"*="): {
97 return Opers::assign_product;
99 case utility::hash(
"+="): {
100 return Opers::assign_sum;
102 case utility::hash(
"-="): {
103 return Opers::assign_difference;
105 case utility::hash(
"&="): {
106 return Opers::assign_bitwise_and;
108 case utility::hash(
"|="): {
109 return Opers::assign_bitwise_or;
111 case utility::hash(
"<<="): {
112 return Opers::assign_shift_left;
114 case utility::hash(
">>="): {
115 return Opers::assign_shift_right;
117 case utility::hash(
"%="): {
118 return Opers::assign_remainder;
120 case utility::hash(
"^="): {
121 return Opers::assign_bitwise_xor;
123 case utility::hash(
"<<"): {
124 return Opers::shift_left;
126 case utility::hash(
">>"): {
127 return Opers::shift_right;
129 case utility::hash(
"%"): {
130 return Opers::remainder;
132 case utility::hash(
"&"): {
133 return Opers::bitwise_and;
135 case utility::hash(
"|"): {
136 return Opers::bitwise_or;
138 case utility::hash(
"^"): {
139 return Opers::bitwise_xor;
141 case utility::hash(
"~"): {
142 return Opers::bitwise_complement;
144 case utility::hash(
"+"): {
145 return t_is_unary ? Opers::unary_plus : Opers::sum;
147 case utility::hash(
"-"): {
148 return t_is_unary ? Opers::unary_minus : Opers::difference;
150 case utility::hash(
"/"): {
151 return Opers::quotient;
153 case utility::hash(
"*"): {
154 return Opers::product;
157 return Opers::invalid;
160 #ifdef CHAISCRIPT_MSVC Namespace chaiscript contains every API call that the average user will be concerned with...
Definition: chaiscript_algebraic.hpp:18