/
AttributeSet.cpp
116 lines (110 loc) · 3.51 KB
/
AttributeSet.cpp
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
**
** AttributeSet.cpp
** Copyright by Jan Poeschko
**
*/
#include "StdAfx.h"
#include "AttributeSet.h"
#include "Exceptions.h"
AttributeSet::AttributeSet()
{
}
AttributeSet::~AttributeSet()
{
}
set<string> AttributeSet::AsStringSet()
{
set<string> result;
for(set<Attribute>::const_iterator item = attributes.begin(); item != attributes.end(); ++item)
switch(*item)
{
case atProtected: result.insert("Protected"); break;
case atLocked: result.insert("Locked"); break;
case atReadProtected: result.insert("ReadProtected"); break;
case atFlat: result.insert("Flat"); break;
case atOneIdentity: result.insert("OneIdentity"); break;
case atOrderless: result.insert("Orderless"); break;
case atListable: result.insert("Listable"); break;
case atNumericFunction: result.insert("NumericFunction"); break;
case atHoldFirst: result.insert("HoldFirst"); break;
case atHoldRest: result.insert("HoldRest"); break;
case atHoldAll: result.insert("HoldAll"); break;
case atHoldAllComplete: result.insert("HoldAllComplete"); break;
case atSequenceHold: result.insert("SequenceHold"); break;
case atTemporary: result.insert("Temporary"); break;
default:
throw UnknownClassException("AttributeSet::AsStringSet: Unknown Attribute."); break;
}
return result;
}
void AttributeSet::Include(string attributeName)
{
Attribute attribute;
if(attributeName == "Protected")
attribute = atProtected;
else if(attributeName == "Locked")
attribute = atLocked;
else if(attributeName == "ReadProtected")
attribute = atReadProtected;
else if(attributeName == "Flat")
attribute = atFlat;
else if(attributeName == "OneIdentity")
attribute = atOneIdentity;
else if(attributeName == "Orderless")
attribute = atOrderless;
else if(attributeName == "Listable")
attribute = atListable;
else if(attributeName == "NumericFunction")
attribute = atNumericFunction;
else if(attributeName == "HoldFirst")
attribute = atHoldFirst;
else if(attributeName == "HoldRest")
attribute = atHoldRest;
else if(attributeName == "HoldAll")
attribute = atHoldAll;
else if(attributeName == "HoldAllComplete")
attribute = atHoldAllComplete;
else if(attributeName == "SequenceHold")
attribute = atSequenceHold;
else if(attributeName == "Temporary")
attribute = atTemporary;
else
throw EvaluateException("Unknown Attribute.");
Include(attribute);
}
void AttributeSet::Exclude(string attributeName)
{
Attribute attribute;
if(attributeName == "Protected")
attribute = atProtected;
else if(attributeName == "Locked")
attribute = atLocked;
else if(attributeName == "ReadProtected")
attribute = atReadProtected;
else if(attributeName == "Flat")
attribute = atFlat;
else if(attributeName == "OneIdentity")
attribute = atOneIdentity;
else if(attributeName == "Orderless")
attribute = atOrderless;
else if(attributeName == "Listable")
attribute = atListable;
else if(attributeName == "NumericFunction")
attribute = atNumericFunction;
else if(attributeName == "HoldFirst")
attribute = atHoldFirst;
else if(attributeName == "HoldRest")
attribute = atHoldRest;
else if(attributeName == "HoldAll")
attribute = atHoldAll;
else if(attributeName == "HoldAllComplete")
attribute = atHoldAllComplete;
else if(attributeName == "SequenceHold")
attribute = atSequenceHold;
else if(attributeName == "Temporary")
attribute = atTemporary;
else
throw EvaluateException("Unknown Attribute.");
Exclude(attribute);
}