Skip to content

Commit 955190b

Browse files
committed
Add support for reading and writing BINARY attributes. Rename members of the IfcUtil::ArgumentType enumeration.
1 parent 462425f commit 955190b

21 files changed

+1909
-1709
lines changed

src/ifcconvert/XmlSerializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ boost::optional<std::string> format_attribute(const Argument* argument, IfcUtil:
3737
stream << v;
3838
value = stream.str();
3939
break; }
40-
case IfcUtil::Argument_ENTITY: {
40+
case IfcUtil::Argument_ENTITY_INSTANCE: {
4141
IfcUtil::IfcBaseClass* e = *argument;
4242
if (Type::IsSimple(e->type())) {
4343
IfcUtil::IfcBaseType* f = (IfcUtil::IfcBaseType*) e;

src/ifcexpressparser/mapping.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ class Mapping:
2828
'integer' : 'int',
2929
'real' : 'double',
3030
'number' : 'double',
31-
'string' : 'std::string'
31+
'string' : 'std::string',
32+
'binary' : 'boost::dynamic_bitset<>'
33+
}
34+
35+
supported_argument_types = {
36+
'INT', 'BOOL', 'DOUBLE', 'STRING', 'BINARY', 'ENUMERATION', 'ENTITY_INSTANCE',
37+
'AGGREGATE_OF_INT', 'AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_STRING', 'AGGREGATE_OF_BINARY', 'AGGREGATE_OF_ENTITY_INSTANCE',
38+
'AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE'
3239
}
3340

3441
def __init__(self, schema):
@@ -77,24 +84,21 @@ def make_argument_type(self, attr):
7784
def _make_argument_type(type):
7885
if type in self.express_to_cpp_typemapping:
7986
return self.express_to_cpp_typemapping.get(type, type).split('::')[-1].upper()
80-
elif self.schema.is_entity(type):
81-
return "ENTITY"
87+
elif self.schema.is_entity(type) or isinstance(type, nodes.SelectType):
88+
return "ENTITY_INSTANCE"
8289
elif self.schema.is_type(type):
8390
return _make_argument_type(self.schema.types[type].type.type)
8491
elif isinstance(type, nodes.BinaryType):
85-
return "UNKNOWN"
92+
return "BINARY"
8693
elif isinstance(type, nodes.EnumerationType):
8794
return "ENUMERATION"
88-
elif isinstance(type, nodes.SelectType):
89-
return "ENTITY"
9095
elif isinstance(type, nodes.AggregationType):
9196
ty = _make_argument_type(type.type)
9297
if ty == "UNKNOWN": return "UNKNOWN"
93-
return "%s_LIST"%ty if ty.startswith("ENTITY") else ("VECTOR_%s"%ty)
98+
return "AGGREGATE_OF_" + ty
9499
else: raise ValueError
95-
supported = {'INT', 'BOOL', 'DOUBLE', 'STRING', 'VECTOR_INT', 'VECTOR_DOUBLE', 'VECTOR_STRING', 'ENTITY', 'ENTITY_LIST', 'ENTITY_LIST_LIST', 'ENUMERATION'}
96100
ty = _make_argument_type(attr.type if hasattr(attr, 'type') else attr)
97-
if ty not in supported: ty = 'UNKNOWN'
101+
if ty not in self.supported_argument_types: ty = 'UNKNOWN'
98102
return "IfcUtil::Argument_%s" % ty
99103

100104
def get_type_dep(self, type):
@@ -104,7 +108,6 @@ def get_type_dep(self, type):
104108
return self.get_type_dep(type.type)
105109

106110
def get_parameter_type(self, attr, allow_optional, allow_entities, allow_pointer = True):
107-
108111
attr_type = self.flatten_type(attr.type)
109112
type_str = self.express_to_cpp_typemapping.get(str(attr_type), attr_type)
110113

@@ -115,7 +118,7 @@ def get_parameter_type(self, attr, allow_optional, allow_entities, allow_pointer
115118
elif isinstance(type_str, nodes.AggregationType):
116119
is_nested_list = isinstance(attr_type.type, nodes.AggregationType)
117120
ty = self.get_parameter_type(attr_type.type if is_nested_list else attr_type, False, allow_entities, False)
118-
if True and self.schema.is_select(attr_type.type):
121+
if self.schema.is_select(attr_type.type):
119122
type_str = templates.untyped_list
120123
elif self.schema.is_simpletype(ty) or ty in self.express_to_cpp_typemapping.values():
121124
type_str = templates.array_type % {
@@ -151,7 +154,7 @@ def derived_in_supertype(self, t):
151154
return c + ([str(s) for s in t.derive.elements] if t.derive else [])
152155

153156
def list_instance_type(self, attr):
154-
f = lambda v : 'IfcUtil::IfcBaseClass' if self.schema.is_select(v) else v
157+
f = lambda v : 'IfcUtil::IfcBaseClass' if self.schema.is_select(v) else str(v)
155158
if self.is_array(attr.type):
156159
if not isinstance(attr.type, str) and self.is_array(attr.type.type):
157160
if isinstance(attr.type.type, str):

src/ifcexpressparser/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class BinaryType(Node):
149149
def init(self):
150150
pass
151151
def __repr__(self):
152-
return "BINARY"
152+
return "binary"
153153

154154

155155
class BoundSpecification(Node):

src/ifcexpressparser/templates.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ class %(name)s %(superclass)s{
415415
enum_from_string_stmt = ' if (s == "%(value)s") return ::%(schema_name)s::%(name)s::%(short_name)s_%(value)s;'
416416

417417
schema_entity_stmt = ' case Type::%(name)s: return new %(name)s(e); break;'
418-
schema_simple_stmt = ' case Type::%(name)s: return new IfcUtil::IfcEntitySelect(e); break;'
419418
string_map_statement = ' string_map["%(uppercase_name)s"%(padding)s] = Type::%(name)s;'
420419
parent_type_stmt = ' if(v==%(name)s%(padding)s) { return %(parent)s; }'
421420

0 commit comments

Comments
 (0)