From a57a305e9d80db40b7be28085f915541eabbcf5c Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 17 Feb 2015 22:14:09 +0000 Subject: [PATCH] Correctly cast writable enumeration attributes to string, as reported in: https://sourceforge.net/p/ifcopenshell/discussion/1782717/thread/53b70ea0 --- src/ifcparse/IfcWrite.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ifcparse/IfcWrite.cpp b/src/ifcparse/IfcWrite.cpp index 8e663e257b..4be7e096ad 100644 --- a/src/ifcparse/IfcWrite.cpp +++ b/src/ifcparse/IfcWrite.cpp @@ -71,7 +71,8 @@ IfcEntityList::ptr IfcWritableEntity::getInverse(IfcSchema::Type::Enum type, int } std::string IfcWritableEntity::datatype() const { return IfcSchema::Type::ToString(_type); } -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(); } +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(); } IfcSchema::Type::Enum IfcWritableEntity::type() const { return _type; } bool IfcWritableEntity::is(IfcSchema::Type::Enum v) const { return _type == v; } std::string IfcWritableEntity::toString(bool upper) const { @@ -314,7 +315,12 @@ void StringBuilderVisitor::operator()(const std::vector& i) { seria IfcWriteArgument::operator int() const { return as(); } IfcWriteArgument::operator bool() const { return as(); } IfcWriteArgument::operator double() const { return as(); } -IfcWriteArgument::operator std::string() const { return as(); } +IfcWriteArgument::operator std::string() const { + if (type() == IfcUtil::Argument_ENUMERATION) { + return as().enumeration_value; + } + return as(); +} IfcWriteArgument::operator std::vector() const { return as >(); } IfcWriteArgument::operator std::vector() const { return as >(); } IfcWriteArgument::operator std::vector() const { return as >(); }