mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
Properly initialize parsed simple types
This commit is contained in:
@@ -48,7 +48,6 @@ protected:
|
||||
mutable bool initialized_;
|
||||
unsigned offset_in_file_;
|
||||
|
||||
void load_() const;
|
||||
public:
|
||||
IfcEntityInstanceData(IfcSchema::Type::Enum type, IfcParse::IfcFile* file_, unsigned id = 0, unsigned offset_in_file = 0)
|
||||
: file(file_), id_(id), type_(type), initialized_(false), offset_in_file_(offset_in_file)
|
||||
@@ -70,6 +69,8 @@ public:
|
||||
{}
|
||||
*/
|
||||
|
||||
void load() const;
|
||||
|
||||
IfcEntityInstanceData(const IfcEntityInstanceData& e);
|
||||
|
||||
~IfcEntityInstanceData();
|
||||
@@ -83,7 +84,7 @@ public:
|
||||
|
||||
unsigned int getArgumentCount() const {
|
||||
if (!initialized_) {
|
||||
load_();
|
||||
load();
|
||||
}
|
||||
return (unsigned int)attributes_.size();
|
||||
}
|
||||
|
||||
@@ -629,9 +629,10 @@ TokenArgument::TokenArgument(const Token& t) {
|
||||
EntityArgument::EntityArgument(const Token& t) {
|
||||
IfcParse::IfcFile* file = t.lexer->file;
|
||||
IfcEntityInstanceData* data = read(0, file, t.startPos);
|
||||
// Data needs to be loaded, for the tokens
|
||||
// to be consumed and parsing to continue.
|
||||
data->load();
|
||||
entity = IfcSchema::SchemaEntity(data);
|
||||
// Needs to be loaded, for the tokens to be consumed
|
||||
file->load(*data);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -920,7 +921,7 @@ void IfcParse::IfcFile::register_inverse(unsigned id_from, Token t) {
|
||||
//
|
||||
std::string IfcEntityInstanceData::toString(bool upper) const {
|
||||
if (!initialized_) {
|
||||
load_();
|
||||
load();
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
@@ -979,7 +980,7 @@ IfcFile::IfcFile()
|
||||
setDefaultHeaderValues();
|
||||
}
|
||||
|
||||
void IfcEntityInstanceData::load_() const {
|
||||
void IfcEntityInstanceData::load() const {
|
||||
file->load(*this);
|
||||
initialized_ = true;
|
||||
}
|
||||
@@ -998,7 +999,7 @@ IfcEntityInstanceData::IfcEntityInstanceData(const IfcEntityInstanceData& e) {
|
||||
|
||||
Argument* IfcEntityInstanceData::getArgument(unsigned int i) const {
|
||||
if (!initialized_) {
|
||||
load_();
|
||||
load();
|
||||
}
|
||||
if (i < attributes_.size()) {
|
||||
return attributes_[i];
|
||||
@@ -1009,7 +1010,7 @@ Argument* IfcEntityInstanceData::getArgument(unsigned int i) const {
|
||||
|
||||
void IfcEntityInstanceData::setArgument(unsigned int i, Argument* a, IfcUtil::ArgumentType attr_type) {
|
||||
if (!initialized_) {
|
||||
load_();
|
||||
load();
|
||||
}
|
||||
|
||||
while (attributes_.size() < i) {
|
||||
|
||||
@@ -40,7 +40,7 @@ HeaderEntity::HeaderEntity(const char * const datatype, IfcFile* file)
|
||||
{
|
||||
if (file) {
|
||||
offset_in_file_ = file->stream->Tell();
|
||||
load_();
|
||||
load();
|
||||
} else {
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user