forked from IfcOpenShell/IfcOpenShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIfcSpfHeader.h
More file actions
186 lines (152 loc) · 5.75 KB
/
IfcSpfHeader.h
File metadata and controls
186 lines (152 loc) · 5.75 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#ifndef IFCSPFHEADER_H
#define IFCSPFHEADER_H
#include "../ifcparse/IfcSpfStream.h"
#include "../ifcparse/IfcWrite.h"
namespace IfcParse {
class HeaderEntity : public IfcAbstractEntity {
private:
ArgumentList* _list;
const char * const _datatype;
protected:
HeaderEntity(const char * const datatype, IfcSpfLexer* lexer)
: _datatype(datatype), _list(0)
{
std::vector<unsigned int> ids;
_list = new ArgumentList();
if (lexer) {
_list->read(lexer, ids);
}
}
~HeaderEntity() {
delete _list;
}
void setArgument(unsigned int i, const std::string& s) {
IfcWrite::IfcWriteArgument* argument = new IfcWrite::IfcWriteArgument(this);
argument->set(s);
_list->set(i, argument);
}
void setArgument(unsigned int i, const std::vector<std::string>& s) {
IfcWrite::IfcWriteArgument* argument = new IfcWrite::IfcWriteArgument(this);
argument->set(s);
_list->set(i, argument);
}
public:
Argument* getArgument(unsigned int i) const {
return (*_list)[i];
}
Argument* getArgument(unsigned int i) {
return (*_list)[i];
}
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum type, int attribute_index) {
return IfcEntityList::ptr(new IfcEntityList);
}
std::string datatype() const {
return _datatype;
}
unsigned int getArgumentCount() const {
return _list->size();
}
IfcSchema::Type::Enum type() const {
return (IfcSchema::Type::Enum) -1;
}
bool is(IfcSchema::Type::Enum v) const {
return false;
}
std::string toString(bool upper=false) const {
std::stringstream ss;
ss << _datatype << _list->toString(upper) << ";";
return ss.str();
}
unsigned int id() {
return 0;
}
IfcWrite::IfcWritableEntity* isWritable() {
return 0;
}
};
class FileDescription : public HeaderEntity {
public:
explicit FileDescription(IfcSpfLexer* = 0);
std::vector<std::string> description() const { return *getArgument(0); }
std::string implementation_level() const { return *getArgument(1); }
void description(const std::vector<std::string>& value) { setArgument(0, value); }
void implementation_level(const std::string& value) { setArgument(1, value); }
};
class FileName : public HeaderEntity {
public:
explicit FileName(IfcSpfLexer* = 0);
std::string name() const { return *getArgument(0); }
std::string time_stamp() const { return *getArgument(1); }
std::vector<std::string> author() const { return *getArgument(2); }
std::vector<std::string> organization() const { return *getArgument(3); }
std::string preprocessor_version() const { return *getArgument(4); }
std::string originating_system() const { return *getArgument(5); }
std::string authorization() const { return *getArgument(6); }
void name(const std::string& value) { setArgument(0, value); }
void time_stamp(const std::string& value) { setArgument(1, value); }
void author(const std::vector<std::string>& value) { setArgument(2, value); }
void organization(const std::vector<std::string>& value) { setArgument(3, value); }
void preprocessor_version(const std::string& value) { setArgument(4, value); }
void originating_system(const std::string& value) { setArgument(5, value); }
void authorization(const std::string& value) { setArgument(6, value); }
};
class FileSchema : public HeaderEntity {
public:
explicit FileSchema(IfcSpfLexer* = 0);
std::vector<std::string> schema_identifiers() const { return *getArgument(0); }
void schema_identifiers(const std::vector<std::string>& value) { setArgument(0, value); }
};
class IfcSpfHeader {
private:
IfcSpfLexer* _lexer;
FileDescription* _file_description;
FileName* _file_name;
FileSchema* _file_schema;
void readParen();
void readSemicolon();
enum Trail {
TRAILING_SEMICOLON,
TRAILING_PAREN,
NONE
};
void readTerminal(const std::string& term, Trail trail);
public:
explicit IfcSpfHeader(IfcSpfLexer* lexer = 0)
: _lexer(lexer), _file_description(0), _file_name(0), _file_schema(0)
{
_file_description = new FileDescription();
_file_name = new FileName();
_file_schema = new FileSchema();
}
IfcSpfLexer* lexer() { return _lexer; }
void lexer(IfcSpfLexer* l) { _lexer = l; }
void read();
bool tryRead();
void write(std::ostream& os) const;
const FileDescription& file_description() const;
const FileName& file_name() const;
const FileSchema& file_schema() const;
FileDescription& file_description();
FileName& file_name();
FileSchema& file_schema();
};
}
#endif