mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Encode characters outside the valid range for IFC SPF files and escape backslashes when writing IFC files
This commit is contained in:
@@ -468,7 +468,7 @@ TokenArgument::operator IfcUtil::IfcSchemaEntity() const { return token.first->f
|
||||
TokenArgument::operator IfcEntities() const { throw IfcException("Argument is not a list of entities"); }
|
||||
unsigned int TokenArgument::Size() const { return 1; }
|
||||
ArgumentPtr TokenArgument::operator [] (unsigned int i) const { throw IfcException("Argument is not a list of arguments"); }
|
||||
std::string TokenArgument::toString(bool upper) const { return TokenFunc::toString(token); }
|
||||
std::string TokenArgument::toString(bool upper) const { if ( upper && TokenFunc::isString(token) ) return IfcWrite::IfcCharacterEncoder(TokenFunc::toString(token)); else return TokenFunc::toString(token); }
|
||||
bool TokenArgument::isNull() const { return TokenFunc::isOperator(token,'$'); }
|
||||
//
|
||||
// Functions for casting the EntityArgument to other types
|
||||
@@ -488,10 +488,11 @@ ArgumentPtr EntityArgument::operator [] (unsigned int i) const { throw IfcExcept
|
||||
std::string EntityArgument::toString(bool upper) const {
|
||||
ArgumentPtr arg = entity->wrappedValue();
|
||||
IfcParse::TokenArgument* token_arg = dynamic_cast<IfcParse::TokenArgument*>(arg);
|
||||
std::string token_string = ( token_arg ) ? TokenFunc::toString(token_arg->token) : "";
|
||||
std::string token_string = ( token_arg ) ? TokenFunc::toString(token_arg->token) : std::string();
|
||||
std::string dt = Ifc2x3::Type::ToString(entity->type());
|
||||
if ( upper ) {
|
||||
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
|
||||
token_string = IfcWrite::IfcCharacterEncoder(token_string);
|
||||
}
|
||||
return dt + "(" + token_string + ")";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user