Skip to content

Commit 1856c49

Browse files
committed
Fix misalignment between enum and boost::variant. See IfcOpenShell#200
1 parent 06cad59 commit 1856c49

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/ifcparse/IfcWrite.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ class SizeVisitor : public boost::static_visitor<int> {
308308
int operator()(const double& /*i*/) const { return -1; }
309309
int operator()(const std::string& /*i*/) const { return -1; }
310310
int operator()(const boost::dynamic_bitset<>& /*i*/) const { return -1; }
311+
int operator()(const IfcWriteArgument::empty_aggregate_t&) const { return 0; }
312+
int operator()(const IfcWriteArgument::empty_aggregate_of_aggregate_t&) const { return 0; }
311313
int operator()(const std::vector<int>& i) const { return (int)i.size(); }
312314
int operator()(const std::vector<double>& i) const { return (int)i.size(); }
313315
int operator()(const std::vector< std::vector<int> >& i) const { return (int)i.size(); }
@@ -435,6 +437,8 @@ class StringBuilderVisitor : public boost::static_visitor<void> {
435437
}
436438
data << ")";
437439
}
440+
void operator()(const IfcWriteArgument::empty_aggregate_t&) const { data << "()"; }
441+
void operator()(const IfcWriteArgument::empty_aggregate_of_aggregate_t&) const { data << "()"; }
438442
operator std::string() { return data.str(); }
439443
};
440444

src/ifcparse/IfcWrite.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ namespace IfcWrite {
5454
: data(data), enumeration_value(enumeration_value) {}
5555
};
5656
class Derived {};
57+
class empty_aggregate_t {};
58+
class empty_aggregate_of_aggregate_t {};
5759
private:
5860
boost::variant<
5961
// A null argument, it will always serialize to $
@@ -85,6 +87,7 @@ namespace IfcWrite {
8587
IfcUtil::IfcBaseClass*,
8688

8789
// AGGREGATES:
90+
empty_aggregate_t,
8891
// An aggregate of integers, e.g. (1,2,3)
8992
std::vector<int>,
9093
// An aggregate of floats, e.g. (12.3,4.)
@@ -99,6 +102,7 @@ namespace IfcWrite {
99102
IfcEntityList::ptr,
100103

101104
// AGGREGATES OF AGGREGATES:
105+
empty_aggregate_of_aggregate_t,
102106
// An aggregate of an aggregate of ints. E.g. ((1, 2), (3))
103107
std::vector< std::vector<int> >,
104108
// An aggregate of an aggregate of floats. E.g. ((1., 2.3), (4.))

0 commit comments

Comments
 (0)