Skip to content

Commit a57a305

Browse files
committed
Correctly cast writable enumeration attributes to string, as reported in: https://sourceforge.net/p/ifcopenshell/discussion/1782717/thread/53b70ea0
1 parent e6ff112 commit a57a305

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/ifcparse/IfcWrite.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ IfcEntityList::ptr IfcWritableEntity::getInverse(IfcSchema::Type::Enum type, int
7171
}
7272

7373
std::string IfcWritableEntity::datatype() const { return IfcSchema::Type::ToString(_type); }
74-
Argument* IfcWritableEntity::getArgument (unsigned int i) { if ( i >= getArgumentCount() ) throw IfcParse::IfcException("Argument not set"); return args[i]; }unsigned int IfcWritableEntity::getArgumentCount() const {return args.size(); }
74+
Argument* IfcWritableEntity::getArgument (unsigned int i) { if ( i >= getArgumentCount() ) throw IfcParse::IfcException("Argument not set"); return args[i]; }
75+
unsigned int IfcWritableEntity::getArgumentCount() const {return args.size(); }
7576
IfcSchema::Type::Enum IfcWritableEntity::type() const { return _type; }
7677
bool IfcWritableEntity::is(IfcSchema::Type::Enum v) const { return _type == v; }
7778
std::string IfcWritableEntity::toString(bool upper) const {
@@ -314,7 +315,12 @@ void StringBuilderVisitor::operator()(const std::vector<std::string>& i) { seria
314315
IfcWriteArgument::operator int() const { return as<int>(); }
315316
IfcWriteArgument::operator bool() const { return as<bool>(); }
316317
IfcWriteArgument::operator double() const { return as<double>(); }
317-
IfcWriteArgument::operator std::string() const { return as<std::string>(); }
318+
IfcWriteArgument::operator std::string() const {
319+
if (type() == IfcUtil::Argument_ENUMERATION) {
320+
return as<EnumerationReference>().enumeration_value;
321+
}
322+
return as<std::string>();
323+
}
318324
IfcWriteArgument::operator std::vector<double>() const { return as<std::vector<double> >(); }
319325
IfcWriteArgument::operator std::vector<int>() const { return as<std::vector<int> >(); }
320326
IfcWriteArgument::operator std::vector<std::string>() const { return as<std::vector<std::string > >(); }

0 commit comments

Comments
 (0)