Skip to content

Commit a90936a

Browse files
committed
Properly initialize parsed simple types
1 parent 7c1cf6e commit a90936a

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/ifcparse/IfcEntityInstanceData.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class IFC_PARSE_API IfcEntityInstanceData {
4848
mutable bool initialized_;
4949
unsigned offset_in_file_;
5050

51-
void load_() const;
5251
public:
5352
IfcEntityInstanceData(IfcSchema::Type::Enum type, IfcParse::IfcFile* file_, unsigned id = 0, unsigned offset_in_file = 0)
5453
: file(file_), id_(id), type_(type), initialized_(false), offset_in_file_(offset_in_file)
@@ -70,6 +69,8 @@ class IFC_PARSE_API IfcEntityInstanceData {
7069
{}
7170
*/
7271

72+
void load() const;
73+
7374
IfcEntityInstanceData(const IfcEntityInstanceData& e);
7475

7576
~IfcEntityInstanceData();
@@ -83,7 +84,7 @@ class IFC_PARSE_API IfcEntityInstanceData {
8384

8485
unsigned int getArgumentCount() const {
8586
if (!initialized_) {
86-
load_();
87+
load();
8788
}
8889
return (unsigned int)attributes_.size();
8990
}

src/ifcparse/IfcParse.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -629,9 +629,10 @@ TokenArgument::TokenArgument(const Token& t) {
629629
EntityArgument::EntityArgument(const Token& t) {
630630
IfcParse::IfcFile* file = t.lexer->file;
631631
IfcEntityInstanceData* data = read(0, file, t.startPos);
632+
// Data needs to be loaded, for the tokens
633+
// to be consumed and parsing to continue.
634+
data->load();
632635
entity = IfcSchema::SchemaEntity(data);
633-
// Needs to be loaded, for the tokens to be consumed
634-
file->load(*data);
635636
}
636637

637638
//
@@ -920,7 +921,7 @@ void IfcParse::IfcFile::register_inverse(unsigned id_from, Token t) {
920921
//
921922
std::string IfcEntityInstanceData::toString(bool upper) const {
922923
if (!initialized_) {
923-
load_();
924+
load();
924925
}
925926

926927
std::stringstream ss;
@@ -979,7 +980,7 @@ IfcFile::IfcFile()
979980
setDefaultHeaderValues();
980981
}
981982

982-
void IfcEntityInstanceData::load_() const {
983+
void IfcEntityInstanceData::load() const {
983984
file->load(*this);
984985
initialized_ = true;
985986
}
@@ -998,7 +999,7 @@ IfcEntityInstanceData::IfcEntityInstanceData(const IfcEntityInstanceData& e) {
998999

9991000
Argument* IfcEntityInstanceData::getArgument(unsigned int i) const {
10001001
if (!initialized_) {
1001-
load_();
1002+
load();
10021003
}
10031004
if (i < attributes_.size()) {
10041005
return attributes_[i];
@@ -1009,7 +1010,7 @@ Argument* IfcEntityInstanceData::getArgument(unsigned int i) const {
10091010

10101011
void IfcEntityInstanceData::setArgument(unsigned int i, Argument* a, IfcUtil::ArgumentType attr_type) {
10111012
if (!initialized_) {
1012-
load_();
1013+
load();
10131014
}
10141015

10151016
while (attributes_.size() < i) {

src/ifcparse/IfcSpfHeader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ HeaderEntity::HeaderEntity(const char * const datatype, IfcFile* file)
4040
{
4141
if (file) {
4242
offset_in_file_ = file->stream->Tell();
43-
load_();
43+
load();
4444
} else {
4545
initialized_ = true;
4646
}

0 commit comments

Comments
 (0)