mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-17 02:49:12 +00:00
Make header values writable
This commit is contained in:
+110
-20
@@ -21,45 +21,124 @@
|
||||
#define IFCSPFHEADER_H
|
||||
|
||||
#include "../ifcparse/IfcSpfStream.h"
|
||||
#include "../ifcparse/IfcWrite.h"
|
||||
|
||||
namespace IfcParse {
|
||||
|
||||
class HeaderEntity {
|
||||
class HeaderEntity : public IfcAbstractEntity {
|
||||
private:
|
||||
ArgumentList* list;
|
||||
ArgumentList* _list;
|
||||
const char * const _datatype;
|
||||
protected:
|
||||
HeaderEntity(IfcSpfLexer* lexer) {
|
||||
HeaderEntity(const char * const datatype, IfcSpfLexer* lexer)
|
||||
: _datatype(datatype), _list(0)
|
||||
{
|
||||
std::vector<unsigned int> ids;
|
||||
list = new ArgumentList(lexer, 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];
|
||||
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 : private HeaderEntity {
|
||||
class FileDescription : public HeaderEntity {
|
||||
public:
|
||||
FileDescription(IfcSpfLexer* lexer) : HeaderEntity(lexer) {}
|
||||
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 : private HeaderEntity {
|
||||
class FileName : public HeaderEntity {
|
||||
public:
|
||||
FileName(IfcSpfLexer* lexer) : HeaderEntity(lexer) {}
|
||||
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); }
|
||||
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 : private HeaderEntity {
|
||||
class FileSchema : public HeaderEntity {
|
||||
public:
|
||||
FileSchema(IfcSpfLexer* lexer) : HeaderEntity(lexer) {}
|
||||
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 {
|
||||
@@ -69,7 +148,7 @@ private:
|
||||
FileName* _file_name;
|
||||
FileSchema* _file_schema;
|
||||
void readParen();
|
||||
void readSemicolon();\
|
||||
void readSemicolon();
|
||||
enum Trail {
|
||||
TRAILING_SEMICOLON,
|
||||
TRAILING_PAREN,
|
||||
@@ -77,18 +156,29 @@ private:
|
||||
};
|
||||
void readTerminal(const std::string& term, Trail trail);
|
||||
public:
|
||||
IfcSpfHeader() : _lexer(0), _file_description(0), _file_name(0), _file_schema(0) {}
|
||||
explicit IfcSpfHeader(IfcSpfLexer* lexer) : _lexer(lexer) {}
|
||||
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 FileName& file_name();
|
||||
const FileSchema& file_schema();
|
||||
const FileDescription& file_description() const;
|
||||
const FileName& file_name() const;
|
||||
const FileSchema& file_schema() const;
|
||||
|
||||
FileDescription& file_description();
|
||||
FileName& file_name();
|
||||
FileSchema& file_schema();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user