Properly initialize parsed simple types

This commit is contained in:
Thomas Krijnen
2017-06-24 21:35:38 +02:00
parent 7c1cf6ebd0
commit a90936a7de
3 changed files with 11 additions and 9 deletions
+3 -2
View File
@@ -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();
}
+7 -6
View File
@@ -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) {
+1 -1
View File
@@ -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;
}