-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpression.hpp
78 lines (54 loc) · 2.05 KB
/
expression.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// File: expression.hpp
// Author: Samuel McFalls
#ifndef EXPRESSION_H
#define EXPRESSION_H
#include <vector>
#include <string>
#include <tuple>
#include "atom.hpp"
class Expression {
public:
// Default construct an Expression of type None
Expression();
// Construct an Expression with a single Boolean atom with value
Expression(bool value);
// Construct an Expression with a single Number atom with value
Expression(double value);
// Construct an Expression with a single Symbol atom with value
Expression(const std::string & value);
// Construct an Expression with an atom as given
Expression(const Atom& atomValue);
// Construct an Expression with a single Point atom with value
Expression(std::tuple<double, double> value);
// Construct an Expression with a single Line atom with starting
// point start and ending point end
Expression(std::tuple<double, double> start,
std::tuple<double, double> end);
// Construct an Expression with a single Arc atom with center
// point center, starting point start, and spanning angle angle in radians
Expression(std::tuple<double, double> center,
std::tuple<double, double> start,
double angle);
// Equality operator for two Expressions, two expressions are equal if the have the same
// type, atom value, and number of arguments
bool operator==(const Expression & exp) const noexcept;
// Gets the last child of an Expression
// @return The last child of the Expression if it has children, nullptr otherwise
Expression lastChild();
// Gets all children of an Expression
// @return The vector of child pointers
std::vector<Expression> getChildren() const;
// Appends a child to an Expression
// @param atomAppend The atom to be held by the appended Expression
void appendChild(Atom atomAppend);
// Apples a child to an Expression
// @param expAppend The Expression to append
void appendChild(Expression expAppend);
// Gets the Atom held by an Expression
// @return The atom held by the Expression
Atom getAtom() const;
private:
std::vector<Expression> children;
Atom atom;
};
#endif