mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-29 11:46:33 +00:00
Properly initialize parsed simple types
This commit is contained in:
@@ -48,7 +48,6 @@ protected:
|
|||||||
mutable bool initialized_;
|
mutable bool initialized_;
|
||||||
unsigned offset_in_file_;
|
unsigned offset_in_file_;
|
||||||
|
|
||||||
void load_() const;
|
|
||||||
public:
|
public:
|
||||||
IfcEntityInstanceData(IfcSchema::Type::Enum type, IfcParse::IfcFile* file_, unsigned id = 0, unsigned offset_in_file = 0)
|
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)
|
: 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(const IfcEntityInstanceData& e);
|
||||||
|
|
||||||
~IfcEntityInstanceData();
|
~IfcEntityInstanceData();
|
||||||
@@ -83,7 +84,7 @@ public:
|
|||||||
|
|
||||||
unsigned int getArgumentCount() const {
|
unsigned int getArgumentCount() const {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
load_();
|
load();
|
||||||
}
|
}
|
||||||
return (unsigned int)attributes_.size();
|
return (unsigned int)attributes_.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -629,9 +629,10 @@ TokenArgument::TokenArgument(const Token& t) {
|
|||||||
EntityArgument::EntityArgument(const Token& t) {
|
EntityArgument::EntityArgument(const Token& t) {
|
||||||
IfcParse::IfcFile* file = t.lexer->file;
|
IfcParse::IfcFile* file = t.lexer->file;
|
||||||
IfcEntityInstanceData* data = read(0, file, t.startPos);
|
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);
|
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 {
|
std::string IfcEntityInstanceData::toString(bool upper) const {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
load_();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
@@ -979,7 +980,7 @@ IfcFile::IfcFile()
|
|||||||
setDefaultHeaderValues();
|
setDefaultHeaderValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcEntityInstanceData::load_() const {
|
void IfcEntityInstanceData::load() const {
|
||||||
file->load(*this);
|
file->load(*this);
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
}
|
}
|
||||||
@@ -998,7 +999,7 @@ IfcEntityInstanceData::IfcEntityInstanceData(const IfcEntityInstanceData& e) {
|
|||||||
|
|
||||||
Argument* IfcEntityInstanceData::getArgument(unsigned int i) const {
|
Argument* IfcEntityInstanceData::getArgument(unsigned int i) const {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
load_();
|
load();
|
||||||
}
|
}
|
||||||
if (i < attributes_.size()) {
|
if (i < attributes_.size()) {
|
||||||
return attributes_[i];
|
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) {
|
void IfcEntityInstanceData::setArgument(unsigned int i, Argument* a, IfcUtil::ArgumentType attr_type) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
load_();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (attributes_.size() < i) {
|
while (attributes_.size() < i) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ HeaderEntity::HeaderEntity(const char * const datatype, IfcFile* file)
|
|||||||
{
|
{
|
||||||
if (file) {
|
if (file) {
|
||||||
offset_in_file_ = file->stream->Tell();
|
offset_in_file_ = file->stream->Tell();
|
||||||
load_();
|
load();
|
||||||
} else {
|
} else {
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user