ifcopenshell.express.templates#

Module Contents#

ifcopenshell.express.templates.array_type = std::vector< %(instance_type)s > /*[%(lower)s:%(upper)s]*/#
ifcopenshell.express.templates.cast_function = %(schema_name)s::%(class_name)s::operator %(return_type)s() const { %(body)s }#
ifcopenshell.express.templates.const_function = %(return_type)s %(schema_name)s::%(class_name)s::%(name)s(%(arguments)s) const { %(body)s }#
ifcopenshell.express.templates.constructor = %(schema_name)s::%(class_name)s::%(class_name)s(%(arguments)s) { %(body)s }#
ifcopenshell.express.templates.constructor_single_initlist = %(schema_name)s::%(class_name)s::%(class_name)s(%(arguments)s) :...#
ifcopenshell.express.templates.constructor_stmt#
ifcopenshell.express.templates.constructor_stmt_array#
ifcopenshell.express.templates.constructor_stmt_derived#
ifcopenshell.express.templates.constructor_stmt_enum#
ifcopenshell.express.templates.constructor_stmt_optional =  if (%(name)s) {%(stmt)s } else { IfcWrite::IfcWriteArgument* attr = new...#
ifcopenshell.express.templates.derived_field_statement =     {std::set<int> idxs; %(statements)sderived_map[Type::%(type)s] = idxs;}#
ifcopenshell.express.templates.derived_field_statement_attrs = idxs.insert(%d);#
ifcopenshell.express.templates.entity = Multiline-String#
Show Value
1%(documentation)s
2class IFC_PARSE_API %(name)s : %(superclass)s {
3public:
4%(attributes)s    %(inverse)s    virtual const IfcParse::entity& declaration() const;
5    static const IfcParse::entity& Class();
6    %(name)s (IfcEntityInstanceData* e);
7    %(name)s (%(constructor_arguments)s);
8    typedef aggregate_of< %(name)s > list;
9};
ifcopenshell.express.templates.entity_descriptor = Multiline-String#
Show Value
1    current = entity_descriptor_map[Type::%(type)s] = new IfcEntityDescriptor(Type::%(type)s,%(parent_statement)s);
2%(entity_descriptor_attributes)s
ifcopenshell.express.templates.entity_descriptor_attribute_with_entity =     current->add("%(name)s",%(optional)s,%(type)s,Type::%(entity_name)s);#
ifcopenshell.express.templates.entity_descriptor_attribute_without_entity =     current->add("%(name)s",%(optional)s,%(type)s);#
ifcopenshell.express.templates.entity_descriptor_parent = entity_descriptor_map.find(Type::%(type)s)->second#
ifcopenshell.express.templates.entity_implementation = Multiline-String#
Show Value
1// Function implementations for %(name)s
2%(attributes)s
3%(inverse)s
4const IfcParse::entity& %(schema_name)s::%(name)s::declaration() const { return *%(schema_name_upper)s_%(name)s_type; }
5const IfcParse::entity& %(schema_name)s::%(name)s::Class() { return *%(schema_name_upper)s_%(name)s_type; }
6%(schema_name)s::%(name)s::%(name)s(IfcEntityInstanceData* e) : %(superclass)s { if (!e) return; if (e->type() != %(schema_name_upper)s_%(name)s_type) throw IfcException("Unable to find keyword in schema"); data_ = e; }
7%(schema_name)s::%(name)s::%(name)s(%(constructor_arguments)s) : %(superclass)s {data_ = new IfcEntityInstanceData(%(schema_name_upper)s_%(name)s_type); %(constructor_implementation)s }
ifcopenshell.express.templates.enum_from_string_stmt =     if (s == "%(value)s") return ::%(schema_name)s::%(name)s::%(short_name)s_%(value)s;#
ifcopenshell.express.templates.enum_header = Multiline-String#
Show Value
1#ifndef %(schema_name_upper)sENUM_H
2#define %(schema_name_upper)sENUM_H
3
4#include "../ifcparse/ifc_parse_api.h"
5
6#include <string>
7#include <boost/optional.hpp>
8
9#endif
ifcopenshell.express.templates.enumeration = Multiline-String#
Show Value
 1class IFC_PARSE_API %(name)s : public IfcUtil::IfcBaseType {
 2%(documentation)s
 3public:
 4    typedef enum {%(values)s} Value;
 5    static const char* ToString(Value v);
 6    static Value FromString(const std::string& s);
 7
 8    virtual const IfcParse::enumeration_type& declaration() const;
 9    static const IfcParse::enumeration_type& Class();
10    %(name)s (IfcEntityInstanceData* e);
11    %(name)s (Value v);
12    %(name)s (const std::string& v);
13    operator Value() const;
14};
ifcopenshell.express.templates.enumeration_descriptor = Multiline-String#
Show Value
1    values.clear(); values.reserve(128);
2%(enumeration_descriptor_values)s
3    enumeration_descriptor_map[Type::%(type)s] = new IfcEnumerationDescriptor(Type::%(type)s, values);
ifcopenshell.express.templates.enumeration_descriptor_value =     values.push_back("%(name)s");#
ifcopenshell.express.templates.enumeration_function = Multiline-String#
Show Value
 1const IfcParse::enumeration_type& %(schema_name)s::%(name)s::declaration() const { return *%(schema_name_upper)s_%(name)s_type; }
 2const IfcParse::enumeration_type& %(schema_name)s::%(name)s::Class() { return *%(schema_name_upper)s_%(name)s_type; }
 3
 4%(schema_name)s::%(name)s::%(name)s(IfcEntityInstanceData* e) {
 5    data_ = e;
 6}
 7
 8%(schema_name)s::%(name)s::%(name)s(Value v) {
 9    data_ = new IfcEntityInstanceData(%(schema_name_upper)s_%(name)s_type);
10    IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument();
11    attr->set(IfcWrite::IfcWriteArgument::EnumerationReference(v,ToString(v)));
12    data_->setArgument(0,attr);
13}
14
15%(schema_name)s::%(name)s::%(name)s(const std::string& v) {
16    data_ = new IfcEntityInstanceData(%(schema_name_upper)s_%(name)s_type);
17    IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument();
18    attr->set(IfcWrite::IfcWriteArgument::EnumerationReference(FromString(v),ToString(FromString(v))));
19    data_->setArgument(0,attr);
20}
21
22const char* %(schema_name)s::%(name)s::ToString(Value v) {
23    if ( v < 0 || v >= %(max_id)d ) throw IfcException("Unable to find keyword in schema");
24    const char* names[] = { %(values)s };
25    return names[v];
26}
27
28%(schema_name)s::%(name)s::Value %(schema_name)s::%(name)s::FromString(const std::string& s) {
29%(from_string_statements)s
30    throw IfcException("Unable to find keyword in schema: " + s);
31}
32
33%(schema_name)s::%(name)s::operator %(schema_name)s::%(name)s::Value() const {
34    return FromString((std::string) *data_->getArgument(0));
35}
ifcopenshell.express.templates.function = %(return_type)s %(schema_name)s::%(class_name)s::%(name)s(%(arguments)s) { %(body)s }#
ifcopenshell.express.templates.get_attr_stmt = %(null_check)s %(non_optional_type)s v = *data_->getArgument(%(index)d); return v;#
ifcopenshell.express.templates.get_attr_stmt_array = %(null_check)s aggregate_of_instance::ptr es = *data_->getArgument(%(index)d); return es->as<...#
ifcopenshell.express.templates.get_attr_stmt_entity = %(null_check)s return...#
ifcopenshell.express.templates.get_attr_stmt_enum = %(null_check)s return %(non_optional_type)s::FromString(*data_->getArgument(%(index)d));#
ifcopenshell.express.templates.get_attr_stmt_nested_array = %(null_check)s aggregate_of_aggregate_of_instance::ptr es = *data_->getArgument(%(index)d);...#
ifcopenshell.express.templates.get_inverse = return data_->getInverse(%(schema_name_upper)s_%(type)s_type, %(index)d)->as<%(type)s>();#
ifcopenshell.express.templates.header = Multiline-String#
Show Value
 1#ifndef %(schema_name_upper)s_H
 2#define %(schema_name_upper)s_H
 3
 4#include <string>
 5#include <vector>
 6
 7#include <boost/optional.hpp>
 8
 9#include "../ifcparse/ifc_parse_api.h"
10
11#include "../ifcparse/aggregate_of_instance.h"
12#include "../ifcparse/IfcBaseClass.h"
13#include "../ifcparse/IfcSchema.h"
14#include "../ifcparse/IfcException.h"
15#include "../ifcparse/Argument.h"
16
17struct %(schema_name)s {
18
19IFC_PARSE_API static const IfcParse::schema_definition& get_schema();
20
21IFC_PARSE_API static void clear_schema();
22
23static const char* const Identifier;
24
25// Forward definitions
26%(forward_definitions)s
27
28%(declarations)s
29
30%(class_definitions)s
31};
32
33#endif
ifcopenshell.express.templates.implementation = Multiline-String#
Show Value
 1#include "../ifcparse/%(schema_name)s.h"
 2#include "../ifcparse/IfcSchema.h"
 3#include "../ifcparse/IfcException.h"
 4#include "../ifcparse/IfcWrite.h"
 5
 6#include <map>
 7
 8const char* const %(schema_name)s::Identifier = "%(schema_name_upper)s";
 9
10using namespace IfcParse;
11using namespace IfcWrite;
12
13// External definitions
14%(external_definitions)s
15
16%(enumeration_functions)s
17
18%(simple_type_impl)s
19
20%(entity_implementations)s
ifcopenshell.express.templates.inverse_attr = aggregate_of< %(entity)s >::ptr %(name)s() const; // INVERSE %(entity)s::%(attribute)s#
ifcopenshell.express.templates.inverse_implementation =     inverse_map[Type::%(type)s].insert(std::make_pair("%(name)s",...#
ifcopenshell.express.templates.lb_header =#
ifcopenshell.express.templates.lb_implementation =#
ifcopenshell.express.templates.list_list_type = aggregate_of_aggregate_of< %(instance_type)s >::ptr#
ifcopenshell.express.templates.list_type = aggregate_of< %(instance_type)s >::ptr#
ifcopenshell.express.templates.nested_array_type = std::vector< std::vector< %(instance_type)s > >#
ifcopenshell.express.templates.optional_attr_stmt = return !data_->getArgument(%(index)d)->isNull();#
ifcopenshell.express.templates.optional_attribute_description = /// Whether the optional attribute %s is defined for this %s#
ifcopenshell.express.templates.parent_type_stmt =     if(v==%(name)s%(padding)s) { return %(parent)s; }#
ifcopenshell.express.templates.parent_type_test =  || %s::is(v)#
ifcopenshell.express.templates.schema_entity_stmt =         case Type::%(name)s: return new %(name)s(e); break;#
ifcopenshell.express.templates.select = Multiline-String#
Show Value
1%(documentation)s
2class IFC_PARSE_API %(name)s : public virtual IfcUtil::IfcBaseInterface {
3public:
4    static const IfcParse::select_type& Class();
5    typedef aggregate_of< %(name)s > list;
6};
ifcopenshell.express.templates.select_function = Multiline-String#
Show Value
1const IfcParse::select_type& %(schema_name)s::%(name)s::Class() { return *%(schema_name_upper)s_%(name)s_type; }
ifcopenshell.express.templates.set_attr_stmt#
ifcopenshell.express.templates.set_attr_stmt_array#
ifcopenshell.express.templates.set_attr_stmt_enum = {IfcWrite::IfcWriteArgument* attr = new...#
ifcopenshell.express.templates.simpletype = Multiline-String#
Show Value
1%(documentation)s
2class IFC_PARSE_API %(name)s : %(superclass)s {
3public:
4    virtual const IfcParse::type_declaration& declaration() const;
5    static const IfcParse::type_declaration& Class();
6    explicit %(name)s (IfcEntityInstanceData* e);
7    %(name)s (%(type)s v);
8    operator %(type)s() const;
9};
ifcopenshell.express.templates.simpletype_impl_argument = return data_->getArgument(i);#
ifcopenshell.express.templates.simpletype_impl_argument_type = if (i == 0) { return %(attr_type)s; } else { throw...#
ifcopenshell.express.templates.simpletype_impl_cast = return *data_->getArgument(0);#
ifcopenshell.express.templates.simpletype_impl_cast_templated = aggregate_of_instance::ptr es = *data_->getArgument(0); return es->as< %(underlying_type)s >();#
ifcopenshell.express.templates.simpletype_impl_class = return *%(schema_name_upper)s_%(class_name)s_type;#
ifcopenshell.express.templates.simpletype_impl_comment = // Function implementations for %(name)s#
ifcopenshell.express.templates.simpletype_impl_constructor#
ifcopenshell.express.templates.simpletype_impl_constructor_templated = data_ = new IfcEntityInstanceData(%(schema_name_upper)s_%(class_name)s_type);...#
ifcopenshell.express.templates.simpletype_impl_declaration = return *%(schema_name_upper)s_%(class_name)s_type;#
ifcopenshell.express.templates.simpletype_impl_explicit_constructor = data_ = e;#
ifcopenshell.express.templates.simpletype_impl_is_with_supertype = return v == %(class_name)s_type || %(superclass)s::is(v);#
ifcopenshell.express.templates.simpletype_impl_is_without_supertype = return v == %(class_name)s_type;#
ifcopenshell.express.templates.simpletype_impl_type = return *%(schema_name_upper)s_%(class_name)s_type;#
ifcopenshell.express.templates.string_map_statement =     string_map["%(uppercase_name)s"%(padding)s] = Type::%(name)s;#
ifcopenshell.express.templates.untyped_list = aggregate_of_instance::ptr#
ifcopenshell.express.templates.multi_line_comment(li)#