-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplatter.h
executable file
·74 lines (59 loc) · 1.93 KB
/
platter.h
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
#ifndef __PLATTER__H
#define __PLATTER__H
#include "exceptions/invalidOperatorFormat.h"
#include <istream>
#include <limits>
class platter
{
public:
static_assert(std::numeric_limits<unsigned int>::digits == 32,
"platters is written under assumptions that unsigned int is "
"a 32 bit integer");
/* Default value is 0. */
platter();
platter(unsigned int v);
/*
* Reads 4 bytes from the stream and stores them as a platter. Throws
* invalidOperatorFormat if there are less than 4 bytes available in the
* stream.
*/
platter(std::istream & is) throw(exceptions::invalidOperatorFormat);
platter(const platter & rhs);
platter & operator=(unsigned int v);
struct operator_
{
enum value
{
conditionalMove = 0,
arrayIndex = 1,
arrayAmendment = 2,
addition = 3,
multiplication = 4,
division = 5,
notAnd = 6,
halt = 7,
allocation = 8,
abandonment = 9,
output = 10,
input = 11,
loadProgram = 12,
orthography = 13
};
private:
/* This struct is just a container for value. */
operator_();
};
/*
* Not all operators have values for all the A, B, C and value arguments.
* If a register or value argument is not relevant for an operator it may or
* may not be modified. Its value should not be relied upon.
*/
operator_::value decode
(unsigned int & A, unsigned int & B, unsigned int & C,
unsigned int & value) const
throw(exceptions::invalidOperatorFormat);
operator unsigned int() const;
private:
unsigned int _v;
};
#endif /* __PLATTER__H */