mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 11:43:53 +00:00
Some successes writing and reading
This commit is contained in:
+13
-99
@@ -22,115 +22,29 @@
|
||||
|
||||
#include "ifc_parse_api.h"
|
||||
#include "IfcEntityInstanceData.h"
|
||||
#include "Header_section_schema.h"
|
||||
|
||||
namespace IfcParse {
|
||||
class IfcFile;
|
||||
|
||||
class IFC_PARSE_API HeaderEntity {
|
||||
private:
|
||||
const char* const datatype_;
|
||||
IfcFile* file_;
|
||||
|
||||
HeaderEntity(const HeaderEntity&); //N/A
|
||||
HeaderEntity& operator=(const HeaderEntity&); //N/A
|
||||
protected:
|
||||
IfcEntityInstanceData data_;
|
||||
|
||||
HeaderEntity(const char* const datatype, size_t size, IfcParse::IfcFile* file);
|
||||
virtual ~HeaderEntity();
|
||||
|
||||
public:
|
||||
virtual size_t getArgumentCount() const {
|
||||
return data_.size();
|
||||
}
|
||||
|
||||
AttributeValue getArgument(size_t index) const {
|
||||
return data_.get_attribute_value(index);
|
||||
}
|
||||
|
||||
std::string toString(bool upper = false) const {
|
||||
std::stringstream stream;
|
||||
stream << datatype_;
|
||||
data_.toString(stream, upper);
|
||||
return stream.str();
|
||||
}
|
||||
};
|
||||
|
||||
class IFC_PARSE_API FileDescription : public HeaderEntity {
|
||||
public:
|
||||
explicit FileDescription(IfcFile* = 0);
|
||||
|
||||
std::vector<std::string> description() const { return data_.get_attribute_value(0); }
|
||||
std::string implementation_level() const { return data_.get_attribute_value(1); }
|
||||
|
||||
void description(const std::vector<std::string>& value) { data_.set_attribute_value(0, value); }
|
||||
void implementation_level(const std::string& value) { data_.set_attribute_value(1, value); }
|
||||
};
|
||||
|
||||
class IFC_PARSE_API FileName : public HeaderEntity {
|
||||
public:
|
||||
explicit FileName(IfcFile* = 0);
|
||||
|
||||
std::string name() const { return data_.get_attribute_value(0); }
|
||||
std::string time_stamp() const { return data_.get_attribute_value(1); }
|
||||
std::vector<std::string> author() const { return data_.get_attribute_value(2); }
|
||||
std::vector<std::string> organization() const { return data_.get_attribute_value(3); }
|
||||
std::string preprocessor_version() const { return data_.get_attribute_value(4); }
|
||||
std::string originating_system() const { return data_.get_attribute_value(5); }
|
||||
std::string authorization() const { return data_.get_attribute_value(6); }
|
||||
|
||||
void name(const std::string& value) { data_.set_attribute_value(0, value); }
|
||||
void time_stamp(const std::string& value) { data_.set_attribute_value(1, value); }
|
||||
void author(const std::vector<std::string>& value) { data_.set_attribute_value(2, value); }
|
||||
void organization(const std::vector<std::string>& value) { data_.set_attribute_value(3, value); }
|
||||
void preprocessor_version(const std::string& value) { data_.set_attribute_value(4, value); }
|
||||
void originating_system(const std::string& value) { data_.set_attribute_value(5, value); }
|
||||
void authorization(const std::string& value) { data_.set_attribute_value(6, value); }
|
||||
};
|
||||
|
||||
class IFC_PARSE_API FileSchema : public HeaderEntity {
|
||||
public:
|
||||
explicit FileSchema(IfcFile* = 0);
|
||||
|
||||
std::vector<std::string> schema_identifiers() const { return data_.get_attribute_value(0); }
|
||||
|
||||
void schema_identifiers(const std::vector<std::string>& value) { data_.set_attribute_value(0, value); }
|
||||
};
|
||||
class IfcFile;
|
||||
|
||||
class IFC_PARSE_API IfcSpfHeader {
|
||||
private:
|
||||
IfcFile* file_;
|
||||
FileDescription* file_description_;
|
||||
FileName* file_name_;
|
||||
FileSchema* file_schema_;
|
||||
void readParen();
|
||||
mutable Header_section_schema::file_description* file_description_;
|
||||
mutable Header_section_schema::file_name* file_name_;
|
||||
mutable Header_section_schema::file_schema* file_schema_;
|
||||
void readSemicolon();
|
||||
enum Trail {
|
||||
TRAILING_SEMICOLON,
|
||||
TRAILING_PAREN,
|
||||
NONE
|
||||
};
|
||||
void readTerminal(const std::string& term, Trail trail);
|
||||
|
||||
public:
|
||||
explicit IfcSpfHeader(IfcParse::IfcFile* file = nullptr)
|
||||
: file_(file),
|
||||
file_description_(0),
|
||||
file_name_(0),
|
||||
file_schema_(0)
|
||||
{
|
||||
if (file == nullptr) {
|
||||
file_description_ = new FileDescription(file_);
|
||||
file_name_ = new FileName(file_);
|
||||
file_schema_ = new FileSchema(file_);
|
||||
}
|
||||
}
|
||||
explicit IfcSpfHeader(IfcParse::IfcFile* file = nullptr);
|
||||
|
||||
~IfcSpfHeader() {
|
||||
delete file_schema_;
|
||||
delete file_name_;
|
||||
delete file_description_;
|
||||
}
|
||||
~IfcSpfHeader();
|
||||
|
||||
IfcParse::IfcFile* file() { return file_; }
|
||||
void file(IfcParse::IfcFile* file) { file_ = file; }
|
||||
@@ -140,13 +54,13 @@ class IFC_PARSE_API IfcSpfHeader {
|
||||
|
||||
void write(std::ostream& out) const;
|
||||
|
||||
const FileDescription& file_description() const;
|
||||
const FileName& file_name() const;
|
||||
const FileSchema& file_schema() const;
|
||||
const Header_section_schema::file_description* file_description() const;
|
||||
const Header_section_schema::file_name* file_name() const;
|
||||
const Header_section_schema::file_schema* file_schema() const;
|
||||
|
||||
FileDescription& file_description();
|
||||
FileName& file_name();
|
||||
FileSchema& file_schema();
|
||||
Header_section_schema::file_description* file_description();
|
||||
Header_section_schema::file_name* file_name();
|
||||
Header_section_schema::file_schema* file_schema();
|
||||
};
|
||||
|
||||
} // namespace IfcParse
|
||||
|
||||
Reference in New Issue
Block a user