7 #include "../ExpressionTree/ExprTreeNode.hpp" 8 #include "../ExpressionTree/ExpressionTree.hpp" 11 extern std::wstring string2wstring(
const std::string& str);
12 extern std::string wstring2string(
const std::wstring& wstr);
36 typedef enum SymbolType{
50 s.str =
new std::string(
"");
57 Symbol (
char c) : type(STRING_TYPE) {
61 s.str =
new std::string(localC);
68 explicit Symbol (
const char* c) : type(STRING_TYPE) {
69 s.str =
new std::string(c);
75 explicit Symbol (
const wchar_t* c) : type(WSTRING_TYPE) {
76 s.wstr =
new std::wstring(c);
83 explicit Symbol (
const std::string& a) : type(STRING_TYPE) {
84 s.str =
new std::string(a);
91 explicit Symbol (
const std::wstring& a) : type(WSTRING_TYPE) {
92 s.wstr =
new std::wstring(a);
102 s.str =
new std::string(*a.s.str);
106 s.wstr =
new std::wstring(*a.s.wstr);
155 return (*
this = std::string(localC));
191 s.str =
new std::string(a);
217 s.str =
new std::string(
"");
237 s.str =
new std::string(*a.s.str);
249 s.wstr =
new std::wstring(*a.s.wstr);
279 b = string2wstring(a);
306 s.wstr =
new std::wstring(*a.s.wstr);
323 b = string2wstring(*s.str);
325 s.wstr =
new std::wstring(b);
326 *s.wstr += *a.s.wstr;
340 b = string2wstring(*a.s.str);
345 *s.wstr += *a.s.wstr;
417 return (s1<s2 || s1==s2);
476 out = wstring2string(*s.wstr);
friend bool operator==(const Symbol &s1, const Symbol &s2)
Equality comparison operator between two Symbol.
~Symbol()
Destructor.
Definition: Symbol.hpp:115
std::string toString() const
Conver a Symbol to a std::string.
Definition: Symbol.hpp:467
friend std::ostream & operator<<(std::ostream &out, const Symbol &b)
Output operator.
Definition: Symbol.hpp:488
Symbol & operator=(char c)
Get the type of this Symbol.
Definition: Symbol.hpp:151
friend bool operator<=(const Symbol &s1, const Symbol &s2)
Less-than-equal comparison operator between two Symbol.
Definition: Symbol.hpp:416
Symbol(const std::wstring &a)
Construct a Symbol from a wide string, std::wstring.
Definition: Symbol.hpp:91
An ExpressionTree encompasses various forms of data that can be expressed generically as a binary tre...
Definition: ExpressionTree.hpp:17
friend bool operator!=(const Symbol &s1, const Symbol &s2)
Inequality comparison operator between two Symbol.
Definition: Symbol.hpp:446
friend bool operator!=(const std::string &s2, const Symbol &s1)
Inequality comparison operator between a Symbol and a string.
Symbol(const Symbol &a)
Copy constructor.
Definition: Symbol.hpp:98
ExpressionTree convertToExpressionTree() const
Convert a Symbol to an ExpressionTree.
Definition: Symbol.hpp:497
friend bool operator>(const Symbol &s1, const Symbol &s2)
Greater-than comparison operator between two Symbol.
Definition: Symbol.hpp:426
Symbol()
Construct an empty Symbol.
Definition: Symbol.hpp:49
Symbol(const char *c)
Construct a Symbol from a c-string.
Definition: Symbol.hpp:68
friend bool operator<(const Symbol &s1, const Symbol &s2)
Less than comparison operator between two Symbol.
static std::vector< Symbol > randomElements(int n)
Get a vector of pair-wise different random Symbols.
An encapsulation of a mathematical symbol.
Definition: Symbol.hpp:23
static Symbol randomElement()
Get a random Symbol.
Symbol(const wchar_t *c)
Construct a Symbol from a wide character c-string.
Definition: Symbol.hpp:75
Symbol(char c)
Construct a Symbol from the given character.
Definition: Symbol.hpp:57
Symbol(const std::string &a)
Construct a Symbol from a std::string.
Definition: Symbol.hpp:83
Symbol & operator+=(const std::string &a)
Concatenate a string to this Symbol.
Definition: Symbol.hpp:267
ExprTreeNode is a single node in the bianry tree of an ExpressionTree.
Definition: ExprTreeNode.hpp:76
friend bool operator>=(const Symbol &s1, const Symbol &s2)
Greater-than-equal comparison operator between two Symbol.
Definition: Symbol.hpp:436