mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
Fix errors in serialization
This commit is contained in:
@@ -707,19 +707,23 @@ std::string Entity::datatype() const {
|
|||||||
// Note that this initializes the entity if it is not initialized
|
// Note that this initializes the entity if it is not initialized
|
||||||
//
|
//
|
||||||
std::string Entity::toString(bool upper) const {
|
std::string Entity::toString(bool upper) const {
|
||||||
if ( ! args ) {
|
if (!args) {
|
||||||
std::vector<unsigned int> ids;
|
std::vector<unsigned int> ids;
|
||||||
Load(ids, true);
|
Load(ids, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::string dt = datatype();
|
std::string dt = datatype();
|
||||||
if ( upper ) {
|
if (upper) {
|
||||||
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
|
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IfcSchema::Type::IsSimple(type()) || _id != 0) {
|
if (!IfcSchema::Type::IsSimple(type()) || _id != 0) {
|
||||||
ss << "#" << _id << "=";
|
ss << "#" << _id << "=";
|
||||||
}
|
}
|
||||||
|
|
||||||
ss << dt << args->toString(upper);
|
ss << dt << args->toString(upper);
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1024,7 +1028,9 @@ std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) {
|
|||||||
|
|
||||||
for ( IfcFile::entity_by_id_t::const_iterator it = f.begin(); it != f.end(); ++ it ) {
|
for ( IfcFile::entity_by_id_t::const_iterator it = f.begin(); it != f.end(); ++ it ) {
|
||||||
const IfcUtil::IfcBaseClass* e = it->second;
|
const IfcUtil::IfcBaseClass* e = it->second;
|
||||||
os << e->entity->toString(true) << ";" << std::endl;
|
if (!IfcSchema::Type::IsSimple(e->type())) {
|
||||||
|
os << e->entity->toString(true) << ";" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
os << "ENDSEC;" << std::endl;
|
os << "ENDSEC;" << std::endl;
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ IfcWritableEntity::IfcWritableEntity(IfcAbstractEntity* e)
|
|||||||
{
|
{
|
||||||
file = e->file;
|
file = e->file;
|
||||||
_type = e->type();
|
_type = e->type();
|
||||||
delete _id;
|
|
||||||
_id = new int(e->id());
|
_id = new int(e->id());
|
||||||
|
|
||||||
const unsigned int count = e->getArgumentCount();
|
const unsigned int count = e->getArgumentCount();
|
||||||
@@ -77,17 +76,23 @@ bool IfcWritableEntity::is(IfcSchema::Type::Enum v) const { return _type == v; }
|
|||||||
std::string IfcWritableEntity::toString(bool upper) const {
|
std::string IfcWritableEntity::toString(bool upper) const {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::string dt = datatype();
|
std::string dt = datatype();
|
||||||
if ( upper ) {
|
if (upper) {
|
||||||
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
|
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
|
||||||
}
|
}
|
||||||
if ( _id ) ss << "#" << *_id;
|
|
||||||
ss << "=" << dt << "(";
|
if (_id && !IfcSchema::Type::IsSimple(type())) {
|
||||||
for ( std::map<int,Argument*>::const_iterator it = args.begin(); it != args.end(); ++ it ) {
|
ss << "#" << *_id;
|
||||||
|
ss << "=";
|
||||||
|
}
|
||||||
|
|
||||||
|
ss << dt << "(";
|
||||||
|
for (std::map<int,Argument*>::const_iterator it = args.begin(); it != args.end(); ++ it) {
|
||||||
if ( it != args.begin() ) ss << ",";
|
if ( it != args.begin() ) ss << ",";
|
||||||
const Argument* a = it->second;
|
const Argument* a = it->second;
|
||||||
ss << it->second->toString(upper);
|
ss << it->second->toString(upper);
|
||||||
}
|
}
|
||||||
ss << ")";
|
ss << ")";
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
unsigned int IfcWritableEntity::id() {
|
unsigned int IfcWritableEntity::id() {
|
||||||
@@ -228,8 +233,11 @@ public:
|
|||||||
void operator()(const double& i) { data << format_double(i); }
|
void operator()(const double& i) { data << format_double(i); }
|
||||||
void operator()(const std::string& i) {
|
void operator()(const std::string& i) {
|
||||||
std::string s = i;
|
std::string s = i;
|
||||||
if (upper) s = IfcCharacterEncoder(s);
|
if (upper) {
|
||||||
data << s;
|
data << static_cast<std::string>(IfcCharacterEncoder(s));
|
||||||
|
} else {
|
||||||
|
data << '\'' << s << '\'';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void operator()(const std::vector<int>& i);
|
void operator()(const std::vector<int>& i);
|
||||||
void operator()(const std::vector<double>& i);
|
void operator()(const std::vector<double>& i);
|
||||||
|
|||||||
Reference in New Issue
Block a user