Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Operators.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <ext/string>
9
10namespace abstraction {
11
12class Operators {
13public:
14 enum class BinaryOperators {
20 ADD,
21 SUB,
22 MUL,
23 MOD,
24 DIV,
25 EQUALS,
27 LESS,
29 MORE,
31 ASSIGN
32 };
33
34 enum class PrefixOperators {
35 PLUS,
36 MINUS,
41 };
42
43 enum class PostfixOperators {
46 };
47
48 static std::string toString ( BinaryOperators type ) {
49 switch ( type ) {
51 return "binary_and";
53 return "binary_or";
55 return "binary_xor";
57 return "logical_and";
59 return "logical_or";
61 return "add";
63 return "sub";
65 return "mul";
67 return "mod";
69 return "div";
71 return "equals";
73 return "not_equals";
75 return "less";
77 return "less_or_equal";
79 return "more";
81 return "more_or_equal";
83 return "assign";
84 }
85 throw std::invalid_argument ( "Undefined option" );
86 }
87
88 static std::string toString ( PrefixOperators type ) {
89 switch ( type ) {
91 return "plus";
93 return "minus";
95 return "logical_not";
97 return "binary_neg";
99 return "increment";
101 return "decrement";
102 }
103 throw std::invalid_argument ( "Undefined option" );
104 }
105
106 static std::string toString ( PostfixOperators type ) {
107 switch ( type ) {
109 return "increment";
111 return "decrement";
112 }
113 throw std::invalid_argument ( "Undefined option" );
114 }
115
116
117};
118
119std::ostream & operator << ( std::ostream & os, Operators::BinaryOperators oper );
120
121std::ostream & operator << ( std::ostream & os, Operators::PrefixOperators oper );
122
123std::ostream & operator << ( std::ostream & os, Operators::PostfixOperators oper );
124
125} /* namespace abstraction */
126
Definition: Operators.hpp:12
static std::string toString(PrefixOperators type)
Definition: Operators.hpp:88
static std::string toString(BinaryOperators type)
Definition: Operators.hpp:48
static std::string toString(PostfixOperators type)
Definition: Operators.hpp:106
PostfixOperators
Definition: Operators.hpp:43
PrefixOperators
Definition: Operators.hpp:34
BinaryOperators
Definition: Operators.hpp:14
Definition: AlgorithmAbstraction.hpp:11
std::ostream & operator<<(std::ostream &os, AlgorithmCategories::AlgorithmCategory category)
Definition: AlgorithmCategories.cpp:52