ifcopenshell.express.templates

Module Contents

ifcopenshell.express.templates.multi_line_comment(li)
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 = 'set_attribute_value(%(index)d, (%(name)s));'
ifcopenshell.express.templates.constructor_stmt_array = 'set_attribute_value(%(index)d, (%(name)s)->generalize());'
ifcopenshell.express.templates.constructor_stmt_derived = ''
ifcopenshell.express.templates.constructor_stmt_enum = 'set_attribute_value(%(index)d, (EnumerationReference(&%(type)s::Class(),(size_t)%(name)s)));'
ifcopenshell.express.templates.constructor_stmt_instance = 'set_attribute_value(%(index)d, %(name)s ? %(name)s->as<IfcUtil::IfcBaseClass>() :...
ifcopenshell.express.templates.constructor_stmt_optional = ' if (%(name)s) {%(stmt)s }'
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
"""%(documentation)s
class IFC_PARSE_API %(name)s : %(superclass)s {
public:
%(attributes)s    %(inverse)s    virtual const IfcParse::entity& declaration() const;
    static const IfcParse::entity& Class();
    %(name)s (IfcEntityInstanceData&& e);
    %(name)s (%(constructor_arguments)s);
    typedef aggregate_of< %(name)s > list;
};
"""
ifcopenshell.express.templates.entity_descriptor = Multiline-String
Show Value
"""    current = entity_descriptor_map[Type::%(type)s] = new IfcEntityDescriptor(Type::%(type)s,%(parent_statement)s);
%(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
"""// Function implementations for %(name)s
%(attributes)s
%(inverse)s
const IfcParse::entity& %(schema_name)s::%(name)s::declaration() const { return *((IfcParse::entity*)%(schema_name_upper)s_types[%(index_in_schema)d]); }
const IfcParse::entity& %(schema_name)s::%(name)s::Class() { return *((IfcParse::entity*)%(schema_name_upper)s_types[%(index_in_schema)d]); }
%(schema_name)s::%(name)s::%(name)s(IfcEntityInstanceData&& e) : %(superclass)s { }
%(schema_name)s::%(name)s::%(name)s(%(constructor_arguments)s) : %(superclass_num_attrs)s { %(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
"""
#ifndef %(schema_name_upper)sENUM_H
#define %(schema_name_upper)sENUM_H

#include "../ifcparse/ifc_parse_api.h"

#include <string>
#include <boost/optional.hpp>

#endif
"""
ifcopenshell.express.templates.enumeration = Multiline-String
Show Value
"""class IFC_PARSE_API %(name)s : public IfcUtil::IfcBaseType {
%(documentation)s
public:
    typedef enum {%(values)s} Value;
    static const char* ToString(Value v);
    static Value FromString(const std::string& s);

    virtual const IfcParse::enumeration_type& declaration() const;
    static const IfcParse::enumeration_type& Class();
    %(name)s (IfcEntityInstanceData&& e);
    %(name)s (Value v);
    %(name)s (const std::string& v);
    operator Value() const;
};
"""
ifcopenshell.express.templates.enumeration_descriptor = Multiline-String
Show Value
"""    values.clear(); values.reserve(128);
%(enumeration_descriptor_values)s
    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
"""
const IfcParse::enumeration_type& %(schema_name)s::%(name)s::declaration() const { return *((IfcParse::enumeration_type*)%(schema_name_upper)s_types[%(index_in_schema)d]); }
const IfcParse::enumeration_type& %(schema_name)s::%(name)s::Class() { return *((IfcParse::enumeration_type*)%(schema_name_upper)s_types[%(index_in_schema)d]); }

%(schema_name)s::%(name)s::%(name)s(IfcEntityInstanceData&& e)
    : IfcBaseType(std::move(e))
{}

%(schema_name)s::%(name)s::%(name)s(Value v) {
    set_attribute_value(0, EnumerationReference(&declaration(), static_cast<size_t>(v)));
}

%(schema_name)s::%(name)s::%(name)s(const std::string& v) {
    set_attribute_value(0, EnumerationReference(&declaration(), declaration().lookup_enum_offset(v)));
}

const char* %(schema_name)s::%(name)s::ToString(Value v) {
    return %(schema_name)s::%(name)s::%(name)s::Class().lookup_enum_value((size_t)v);
}

%(schema_name)s::%(name)s::Value %(schema_name)s::%(name)s::FromString(const std::string& s) {
    return (%(schema_name)s::%(name)s::Value) %(schema_name)s::%(name)s::%(name)s::Class().lookup_enum_offset(s);
}

%(schema_name)s::%(name)s::operator %(schema_name)s::%(name)s::Value() const {
    return (%(schema_name)s::%(name)s::Value) data_.storage_.get<EnumerationReference>(0).index();
}
"""
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_.get_attribute_value(%(index)d); return v;'
ifcopenshell.express.templates.get_attr_stmt_array = '%(null_check)s aggregate_of_instance::ptr es = data_.get_attribute_value(%(index)d); return...
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_.get_attribute_value(%(index)d));'
ifcopenshell.express.templates.get_attr_stmt_nested_array = '%(null_check)s aggregate_of_aggregate_of_instance::ptr es =...
ifcopenshell.express.templates.get_inverse = 'if (!file_) { return nullptr; } return file_->getInverse(id_,...
ifcopenshell.express.templates.header = Multiline-String
Show Value
"""
#ifndef %(schema_name_upper)s_H
#define %(schema_name_upper)s_H

#include <string>
#include <vector>

#include <boost/optional.hpp>

#include "../ifcparse/ifc_parse_api.h"

#include "../ifcparse/aggregate_of_instance.h"
#include "../ifcparse/IfcBaseClass.h"
#include "../ifcparse/IfcSchema.h"
#include "../ifcparse/IfcException.h"
#include "../ifcparse/Argument.h"

struct %(schema_name)s {

IFC_PARSE_API static const IfcParse::schema_definition& get_schema();

IFC_PARSE_API static void clear_schema();

static const char* const Identifier;

// Forward definitions
%(forward_definitions)s

%(declarations)s

%(class_definitions)s
};

#endif
"""
ifcopenshell.express.templates.implementation = Multiline-String
Show Value
"""
#include "../ifcparse/%(schema_name)s.h"
#include "../ifcparse/IfcSchema.h"
#include "../ifcparse/IfcException.h"
#include "../ifcparse/IfcFile.h"

#include <map>

const char* const %(schema_name)s::Identifier = "%(schema_name_upper)s";

using namespace IfcParse;

// External definitions
%(external_definitions)s

%(enumeration_functions)s

%(simple_type_impl)s

%(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_.get_attribute_value(%(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
"""%(documentation)s
class IFC_PARSE_API %(name)s : public virtual IfcUtil::IfcBaseInterface {
public:
    static const IfcParse::select_type& Class();
    typedef aggregate_of< %(name)s > list;
};
"""
ifcopenshell.express.templates.select_function = Multiline-String
Show Value
"""
const IfcParse::select_type& %(schema_name)s::%(name)s::Class() { return *((IfcParse::select_type*)%(schema_name_upper)s_types[%(index_in_schema)d]); }
"""
ifcopenshell.express.templates.set_attr_instance = '%(check_optional_set_begin)sset_attribute_value(%(index)d,...
ifcopenshell.express.templates.set_attr_stmt = '%(check_optional_set_begin)sset_attribute_value(%(index)d,...
ifcopenshell.express.templates.set_attr_stmt_array = '%(check_optional_set_begin)sset_attribute_value(%(index)d,...
ifcopenshell.express.templates.set_attr_stmt_enum = '%(check_optional_set_begin)sset_attribute_value(%(index)d,...
ifcopenshell.express.templates.simpletype = Multiline-String
Show Value
"""%(documentation)s
class IFC_PARSE_API %(name)s : %(superclass)s {
public:
    virtual const IfcParse::type_declaration& declaration() const;
    static const IfcParse::type_declaration& Class();
    explicit %(name)s (IfcEntityInstanceData&& e);
    %(name)s (%(type)s v);
    operator %(type)s() const;
};
"""
ifcopenshell.express.templates.simpletype_impl_argument = 'return data_.get_attribute_value(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_.get_attribute_value(0);'
ifcopenshell.express.templates.simpletype_impl_cast_templated = 'aggregate_of_instance::ptr es = data_.get_attribute_value(0); return es->as< %(underlying_type)s >();'
ifcopenshell.express.templates.simpletype_impl_class = 'return *((IfcParse::type_declaration*)%(schema_name_upper)s_types[%(index_in_schema)d]);'
ifcopenshell.express.templates.simpletype_impl_comment = '// Function implementations for %(name)s'
ifcopenshell.express.templates.simpletype_impl_constructor = 'data_ = new IfcEntityInstanceData(%(schema_name_upper)s_types[%(index_in_schema)d]);...
ifcopenshell.express.templates.simpletype_impl_constructor_templated = 'data_ = new IfcEntityInstanceData(%(schema_name_upper)s_types[%(index_in_schema)d]);...
ifcopenshell.express.templates.simpletype_impl_declaration = 'return *((IfcParse::type_declaration*)%(schema_name_upper)s_types[%(index_in_schema)d]);'
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 *((IfcParse::type_declaration*)%(schema_name_upper)s_types[%(index_in_schema)d]);'
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'