mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-18 19:30:25 +00:00
Last minute refactoring
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "file.h"
|
||||
|
||||
// @todo is size() still needed?
|
||||
class SizeVisitor {
|
||||
class size_visitor {
|
||||
public:
|
||||
typedef int result_type;
|
||||
|
||||
@@ -25,9 +25,9 @@ public:
|
||||
int operator()(const std::vector<std::string>& i) const { return (int)i.size(); }
|
||||
int operator()(const std::vector<boost::dynamic_bitset<>>& i) const { return (int)i.size(); }
|
||||
int operator()(const enumeration_reference& /*i*/) const { return -1; }
|
||||
int operator()(const express::Base& /*i*/) const { return -1; }
|
||||
int operator()(const std::vector<express::Base>& i) const { return (int)i.size(); }
|
||||
int operator()(const std::vector<std::vector<express::Base>>& i) const { return (int)i.size(); }
|
||||
int operator()(const express::base& /*i*/) const { return -1; }
|
||||
int operator()(const std::vector<express::base>& i) const { return (int)i.size(); }
|
||||
int operator()(const std::vector<std::vector<express::base>>& i) const { return (int)i.size(); }
|
||||
};
|
||||
|
||||
namespace {
|
||||
@@ -59,7 +59,7 @@ namespace {
|
||||
if constexpr (
|
||||
// the following types cannot be directly deserialized from rocksdb, but need to be constructed
|
||||
!std::is_same_v<T, enumeration_reference> &&
|
||||
!std::is_same_v<std::remove_cv_t<T>, express::Base>)
|
||||
!std::is_same_v<std::remove_cv_t<T>, express::base>)
|
||||
{
|
||||
std::string str;
|
||||
array_.db_ptr->db->Get(rocksdb::ReadOptions{},
|
||||
@@ -70,8 +70,8 @@ namespace {
|
||||
} else {
|
||||
static_assert(
|
||||
std::is_same_v<T, enumeration_reference> ||
|
||||
std::is_same_v<std::remove_cv_t<T>, express::Base>,
|
||||
"RocksDB deserialization must be specialized for this enumeration_reference and express::Base"
|
||||
std::is_same_v<std::remove_cv_t<T>, express::base>,
|
||||
"RocksDB deserialization must be specialized for this enumeration_reference and express::base"
|
||||
);
|
||||
}
|
||||
return val;
|
||||
@@ -98,7 +98,7 @@ namespace {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return str[0] == TypeEncoder::encode_type<T>();
|
||||
return str[0] == type_encoder::encode_type<T>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -116,7 +116,7 @@ namespace {
|
||||
(is_header ? "h|" : (entity_or_type->as_entity() ? "i|" : "t|")) +
|
||||
(is_header ? entity_or_type->name() : std::to_string(instance_name_)) + "|" +
|
||||
std::to_string(index_), &str).ok()) {
|
||||
return TypeEncoder::encode_type<blank>() - 'A';
|
||||
return type_encoder::encode_type<blank>() - 'A';
|
||||
}
|
||||
return (size_t) str[0] - 'A';
|
||||
}
|
||||
@@ -201,10 +201,10 @@ attribute_value::operator boost::dynamic_bitset<>() const
|
||||
return dispatch_get_<boost::dynamic_bitset<>>(array_, storage_model_, instance_name_, entity_or_type_, index_);
|
||||
}
|
||||
|
||||
attribute_value::operator express::Base () const
|
||||
attribute_value::operator express::base () const
|
||||
{
|
||||
if (storage_model_ == 0) {
|
||||
return dispatch_get_<express::Base>(array_, storage_model_, instance_name_, entity_or_type_, index_);
|
||||
return dispatch_get_<express::base>(array_, storage_model_, instance_name_, entity_or_type_, index_);
|
||||
}
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
else {
|
||||
@@ -249,9 +249,9 @@ attribute_value::operator std::vector<boost::dynamic_bitset<>>() const
|
||||
return dispatch_get_<std::vector<boost::dynamic_bitset<>>>(array_, storage_model_, instance_name_, entity_or_type_, index_);
|
||||
}
|
||||
|
||||
attribute_value::operator std::vector<express::Base>() const
|
||||
attribute_value::operator std::vector<express::base>() const
|
||||
{
|
||||
return dispatch_get_<std::vector<express::Base>>(array_, storage_model_, instance_name_, entity_or_type_, index_);
|
||||
return dispatch_get_<std::vector<express::base>>(array_, storage_model_, instance_name_, entity_or_type_, index_);
|
||||
}
|
||||
|
||||
attribute_value::operator std::vector<std::vector<int64_t>>() const
|
||||
@@ -264,9 +264,9 @@ attribute_value::operator std::vector<std::vector<double>>() const
|
||||
return dispatch_get_<std::vector<std::vector<double>>>(array_, storage_model_, instance_name_, entity_or_type_, index_);
|
||||
}
|
||||
|
||||
attribute_value::operator std::vector<std::vector<express::Base>>() const
|
||||
attribute_value::operator std::vector<std::vector<express::base>>() const
|
||||
{
|
||||
return dispatch_get_<std::vector<std::vector<express::Base>>>(array_, storage_model_, instance_name_, entity_or_type_, index_);
|
||||
return dispatch_get_<std::vector<std::vector<express::base>>>(array_, storage_model_, instance_name_, entity_or_type_, index_);
|
||||
}
|
||||
|
||||
bool attribute_value::isNull() const
|
||||
@@ -277,7 +277,7 @@ bool attribute_value::isNull() const
|
||||
unsigned int attribute_value::size() const
|
||||
{
|
||||
// @todo
|
||||
return array_.storage_ptr->apply_visitor(SizeVisitor{}, index_);
|
||||
return array_.storage_ptr->apply_visitor(size_visitor{}, index_);
|
||||
}
|
||||
|
||||
ifcopenshell::argument_type attribute_value::type() const
|
||||
@@ -287,11 +287,11 @@ ifcopenshell::argument_type attribute_value::type() const
|
||||
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
|
||||
bool impl::serialize(std::string& val, const express::Base& t)
|
||||
bool impl::serialize(std::string& val, const express::base& t)
|
||||
{
|
||||
auto s = sizeof(size_t);
|
||||
val.resize(s + 2);
|
||||
val[0] = TypeEncoder::encode_type<express::Base>();
|
||||
val[0] = type_encoder::encode_type<express::base>();
|
||||
// 1 = entity - stored by id (entity name)
|
||||
// 2 = type - stored by identity (internal counter in class)
|
||||
val[1] = t.declaration().as_entity() ? 'i' : 't';
|
||||
@@ -304,7 +304,7 @@ bool impl::serialize(std::string& val, const enumeration_reference& v)
|
||||
{
|
||||
auto s = sizeof(size_t);
|
||||
val.resize(s * 2 + 1);
|
||||
val[0] = TypeEncoder::encode_type<enumeration_reference>();
|
||||
val[0] = type_encoder::encode_type<enumeration_reference>();
|
||||
size_t vv = v.enumeration()->index_in_schema();
|
||||
memcpy(val.data() + 1, &vv, sizeof(size_t));
|
||||
vv = v.index();
|
||||
@@ -312,11 +312,11 @@ bool impl::serialize(std::string& val, const enumeration_reference& v)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool impl::serialize(std::string& val, const std::vector<express::Base>& t)
|
||||
bool impl::serialize(std::string& val, const std::vector<express::base>& t)
|
||||
{
|
||||
// no attempt at alignment
|
||||
val.resize(t.size() * (sizeof(size_t) + 1) + 1);
|
||||
val[0] = TypeEncoder::encode_type<std::vector<express::Base>>();
|
||||
val[0] = type_encoder::encode_type<std::vector<express::base>>();
|
||||
char* ptr = val.data() + 1;
|
||||
for (auto& inst : t) {
|
||||
*ptr = inst.declaration().as_entity() ? 'i' : 't';
|
||||
@@ -328,10 +328,10 @@ bool impl::serialize(std::string& val, const std::vector<express::Base>& t)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool impl::serialize(std::string& val, const std::vector<std::vector<express::Base>>& t)
|
||||
bool impl::serialize(std::string& val, const std::vector<std::vector<express::base>>& t)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss.put(TypeEncoder::encode_type<std::vector<std::vector<express::Base>>>());
|
||||
oss.put(type_encoder::encode_type<std::vector<std::vector<express::base>>>());
|
||||
|
||||
auto write_size = [&oss](size_t sz) {
|
||||
std::string size_str;
|
||||
@@ -366,28 +366,28 @@ bool impl::serialize(std::string& val, const std::vector<std::vector<express::Ba
|
||||
bool impl::serialize(std::string& val, const blank&)
|
||||
{
|
||||
val.resize(1);
|
||||
val[0] = TypeEncoder::encode_type<blank>();
|
||||
val[0] = type_encoder::encode_type<blank>();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool impl::serialize(std::string& val, const derived&)
|
||||
{
|
||||
val.resize(1);
|
||||
val[0] = TypeEncoder::encode_type<derived>();
|
||||
val[0] = type_encoder::encode_type<derived>();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool impl::serialize(std::string& val, const empty_aggregate_t&)
|
||||
{
|
||||
val.resize(1);
|
||||
val[0] = TypeEncoder::encode_type<empty_aggregate_t>();
|
||||
val[0] = type_encoder::encode_type<empty_aggregate_t>();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool impl::serialize(std::string& val, const empty_aggregate_of_aggregate_t&)
|
||||
{
|
||||
val.resize(1);
|
||||
val[0] = TypeEncoder::encode_type<empty_aggregate_of_aggregate_t>();
|
||||
val[0] = type_encoder::encode_type<empty_aggregate_of_aggregate_t>();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ bool impl::serialize(std::string& val, const boost::logic::tribool& t)
|
||||
{
|
||||
char tt = t == boost::logic::indeterminate ? 2 : t ? 1 : 0;
|
||||
val.resize(sizeof(char) + 1);
|
||||
val[0] = TypeEncoder::encode_type<boost::logic::tribool>();
|
||||
val[0] = type_encoder::encode_type<boost::logic::tribool>();
|
||||
memcpy(val.data() + 1, &tt, sizeof(char));
|
||||
return true;
|
||||
}
|
||||
@@ -404,12 +404,12 @@ bool impl::serialize(std::string& val, const boost::dynamic_bitset<>& t)
|
||||
{
|
||||
std::string tmp;
|
||||
boost::to_string(t, tmp);
|
||||
val = std::string(TypeEncoder::encode_type<boost::dynamic_bitset<>>(), 1) + tmp;
|
||||
val = std::string(type_encoder::encode_type<boost::dynamic_bitset<>>(), 1) + tmp;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::logic::tribool& t) {
|
||||
if (val[0] != TypeEncoder::encode_type<boost::logic::tribool>()) {
|
||||
if (val[0] != type_encoder::encode_type<boost::logic::tribool>()) {
|
||||
return false;
|
||||
}
|
||||
if (val[1] == 0) {
|
||||
@@ -425,14 +425,14 @@ bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::st
|
||||
}
|
||||
|
||||
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::dynamic_bitset<>& t) {
|
||||
if (val[0] != TypeEncoder::encode_type<boost::dynamic_bitset<>>()) {
|
||||
if (val[0] != type_encoder::encode_type<boost::dynamic_bitset<>>()) {
|
||||
return false;
|
||||
}
|
||||
t = boost::dynamic_bitset<>(val.substr(1));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector<express::Base>& t) {
|
||||
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector<express::base>& t) {
|
||||
auto n = (val.size() - 1) / (sizeof(size_t) + 1);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
auto ptr = val.data() + 1 + (sizeof(size_t) + 1) * i;
|
||||
@@ -451,7 +451,7 @@ bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector<std::vector<express::Base>>& t) {
|
||||
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& val, std::vector<std::vector<express::base>>& t) {
|
||||
char const* ptr = val.data() + 1;
|
||||
|
||||
// size_t outer_size;
|
||||
@@ -505,7 +505,7 @@ bool rocks_db_attribute_storage::has(void* storage, const ifcopenshell::declarat
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return v.size() && v[0] == TypeEncoder::encode_type<T>();
|
||||
return v.size() && v[0] == type_encoder::encode_type<T>();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -530,15 +530,15 @@ template IFC_PARSE_API void rocks_db_attribute_storage::set<double>(void* storag
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<std::string>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::string& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<boost::dynamic_bitset<>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const boost::dynamic_bitset<>& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<enumeration_reference>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const enumeration_reference& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<express::Base>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, express::Base const& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<express::base>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, express::base const& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<std::vector<int64_t>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector<int64_t>& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<std::vector<double>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector<double>& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<std::vector<std::string>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector<std::string>& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<std::vector<boost::dynamic_bitset<>>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector<boost::dynamic_bitset<>>& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<std::vector<express::Base>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector<express::Base>& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<std::vector<express::base>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector<express::base>& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<std::vector<std::vector<int64_t>>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector<std::vector<int64_t>>& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<std::vector<std::vector<double>>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector<std::vector<double>>& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<std::vector<std::vector<express::Base>>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector<std::vector<express::Base>>& value);
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<std::vector<std::vector<express::base>>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const std::vector<std::vector<express::base>>& value);
|
||||
|
||||
// @todo why do these need to be included, but are not in BaseEntity::set()?
|
||||
template IFC_PARSE_API void rocks_db_attribute_storage::set<derived>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index, const derived& value);
|
||||
@@ -553,15 +553,15 @@ template IFC_PARSE_API bool rocks_db_attribute_storage::has<double>(void* storag
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<std::string>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<boost::dynamic_bitset<>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<enumeration_reference>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<express::Base>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<express::base>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<std::vector<int64_t>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<std::vector<double>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<std::vector<std::string>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<std::vector<boost::dynamic_bitset<>>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<std::vector<express::Base>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<std::vector<express::base>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<std::vector<std::vector<int64_t>>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<std::vector<std::vector<double>>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<std::vector<std::vector<express::Base>>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<std::vector<std::vector<express::base>>>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
|
||||
// @todo why do these need to be included, but are not in BaseEntity::set()?
|
||||
template IFC_PARSE_API bool rocks_db_attribute_storage::has<derived>(void* storage, const ifcopenshell::declaration* decl, std::size_t identity, size_t index) const;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "express.h"
|
||||
#include "instance_data.h"
|
||||
|
||||
const ifcopenshell::declaration& express::Base::declaration() const {
|
||||
const ifcopenshell::declaration& express::base::declaration() const {
|
||||
return *data()->declaration();
|
||||
}
|
||||
uint32_t express::Base::identity() const { return data()->identity(); }
|
||||
uint32_t express::base::identity() const { return data()->identity(); }
|
||||
|
||||
uint32_t express::Base::id() const { return data()->id(); }
|
||||
uint32_t express::base::id() const { return data()->id(); }
|
||||
|
||||
const instance_data* express::Base::data() const {
|
||||
const instance_data* express::base::data() const {
|
||||
#ifdef IFOPSH_SAFE_INSTANCE
|
||||
auto sp = data_.lock();
|
||||
if (sp) {
|
||||
@@ -21,7 +21,7 @@ const instance_data* express::Base::data() const {
|
||||
#endif
|
||||
}
|
||||
|
||||
instance_data* express::Base::data() {
|
||||
instance_data* express::base::data() {
|
||||
#ifdef IFOPSH_SAFE_INSTANCE
|
||||
auto sp = data_.lock();
|
||||
if (sp) {
|
||||
|
||||
+50
-43
@@ -59,12 +59,12 @@ class attribute_value;
|
||||
|
||||
namespace express {
|
||||
|
||||
class Base;
|
||||
class Select;
|
||||
class Entity;
|
||||
class DeclaredType;
|
||||
class base;
|
||||
class select;
|
||||
class entity;
|
||||
class declared_type;
|
||||
|
||||
class IFC_PARSE_API Base {
|
||||
class IFC_PARSE_API base {
|
||||
protected:
|
||||
ifcopenshell::pointer_type data_;
|
||||
const instance_data* data() const;
|
||||
@@ -78,25 +78,25 @@ class IFC_PARSE_API Base {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool operator<(const Base& other) const {
|
||||
bool operator<(const base& other) const {
|
||||
return data() < other.data();
|
||||
}
|
||||
|
||||
bool operator==(const Base& other) const {
|
||||
bool operator==(const base& other) const {
|
||||
return data() == other.data();
|
||||
}
|
||||
|
||||
bool operator!=(const Base& other) const {
|
||||
bool operator!=(const base& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
Base() {
|
||||
base() {
|
||||
#ifndef IFOPSH_SAFE_INSTANCE
|
||||
data_ = nullptr;
|
||||
#endif
|
||||
};
|
||||
Base(std::nullopt_t) noexcept : Base() {}
|
||||
Base(const ifcopenshell::pointer_type& data) : data_(data) {}
|
||||
base(std::nullopt_t) noexcept : base() {}
|
||||
base(const ifcopenshell::pointer_type& data) : data_(data) {}
|
||||
|
||||
// @todo try and make this private over time too
|
||||
const ifcopenshell::pointer_type& data_weak() const { return data_; }
|
||||
@@ -105,18 +105,18 @@ class IFC_PARSE_API Base {
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<
|
||||
(!std::is_base_of_v<express::Base, T> || std::is_same_v<express::Base, T>),
|
||||
(!std::is_base_of_v<express::base, T> || std::is_same_v<express::base, T>),
|
||||
void>::type
|
||||
set_attribute_value(size_t attribute_index, const T& value);
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<
|
||||
(!std::is_base_of_v<express::Base, T> || std::is_same_v<express::Base, T>),
|
||||
(!std::is_base_of_v<express::base, T> || std::is_same_v<express::base, T>),
|
||||
void>::type
|
||||
set_attribute_value(const std::string& attribute_name, const T& value);
|
||||
|
||||
void set_attribute_value(size_t attribute_index, const express::Base& value);
|
||||
void set_attribute_value(const std::string& attribute_name, const express::Base& value);
|
||||
void set_attribute_value(size_t attribute_index, const express::base& value);
|
||||
void set_attribute_value(const std::string& attribute_name, const express::base& value);
|
||||
|
||||
void unset_attribute_value(size_t attribute_index);
|
||||
|
||||
@@ -130,20 +130,20 @@ class IFC_PARSE_API Base {
|
||||
|
||||
template <class T>
|
||||
T as() const {
|
||||
if constexpr (std::is_same_v<Entity, T>) {
|
||||
if constexpr (std::is_same_v<entity, T>) {
|
||||
if (declaration().as_entity() != nullptr) {
|
||||
return T(data_weak());
|
||||
} else {
|
||||
return T{};
|
||||
}
|
||||
} else if constexpr (std::is_same_v<DeclaredType, T>) {
|
||||
} else if constexpr (std::is_same_v<declared_type, T>) {
|
||||
if (declaration().as_entity() == nullptr) {
|
||||
return T(data_weak());
|
||||
} else {
|
||||
return T{};
|
||||
}
|
||||
} else if constexpr (std::is_same_v<Select, T>) {
|
||||
static_assert(std::is_same_v<Select, T>, "Select is abstract");
|
||||
} else if constexpr (std::is_same_v<select, T>) {
|
||||
static_assert(std::is_same_v<select, T>, "select is abstract");
|
||||
} else {
|
||||
if (declaration().is(T::Class())) {
|
||||
return T(data_weak());
|
||||
@@ -156,9 +156,9 @@ class IFC_PARSE_API Base {
|
||||
ifcopenshell::file* file() const;
|
||||
};
|
||||
|
||||
class IFC_PARSE_API Entity : public Base {
|
||||
class IFC_PARSE_API entity : public base {
|
||||
public:
|
||||
using Base::Base;
|
||||
using base::base;
|
||||
|
||||
attribute_value get(const std::string& attribute_name) const;
|
||||
|
||||
@@ -168,44 +168,51 @@ class IFC_PARSE_API Entity : public Base {
|
||||
template <typename T>
|
||||
T get_value(const std::string& attribute_name, const T& default_value) const;
|
||||
|
||||
std::vector<express::Entity> get_inverse(const std::string& attribute_name) const;
|
||||
std::vector<express::entity> get_inverse(const std::string& attribute_name) const;
|
||||
};
|
||||
|
||||
class IFC_PARSE_API Select : public Base {
|
||||
class IFC_PARSE_API select : public base {
|
||||
public:
|
||||
Select() {}
|
||||
Select(std::nullopt_t) noexcept : Base() {}
|
||||
Select(const ifcopenshell::pointer_type& data) : Base(data) {}
|
||||
Select(const Base& base) : Base(base.data_weak()) {}
|
||||
select() {}
|
||||
select(std::nullopt_t) noexcept : base() {}
|
||||
select(const ifcopenshell::pointer_type& data) : base(data) {}
|
||||
select(const base& value) : base(value.data_weak()) {}
|
||||
|
||||
Base concrete() const {
|
||||
return Base(data_weak());
|
||||
base concrete() const {
|
||||
return base(data_weak());
|
||||
}
|
||||
};
|
||||
|
||||
// @todo Investigate whether these should be template classes instead
|
||||
// @todo currently this class doesn't do much, decide whether to keep
|
||||
// it or move certain functionality from Base downwards to
|
||||
// Entity and DeclaredType
|
||||
class IFC_PARSE_API DeclaredType : public Base {
|
||||
// it or move certain functionality from base downwards to
|
||||
// entity and declared_type
|
||||
class IFC_PARSE_API declared_type : public base {
|
||||
public:
|
||||
using Base::Base;
|
||||
using base::base;
|
||||
};
|
||||
|
||||
// Compatibility aliases for checked-in generated schema sources. New generated
|
||||
// sources use the snake_case names directly.
|
||||
using Base = base;
|
||||
using Entity = entity;
|
||||
using Select = select;
|
||||
using DeclaredType = declared_type;
|
||||
|
||||
} // namespace express
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
struct hash<express::Base> {
|
||||
std::size_t operator()(const express::Base& value) const noexcept {
|
||||
struct hash<express::base> {
|
||||
std::size_t operator()(const express::base& value) const noexcept {
|
||||
return std::hash<uint32_t>{}(value.identity());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<express::Entity> {
|
||||
std::size_t operator()(const express::Entity& value) const noexcept {
|
||||
struct hash<express::entity> {
|
||||
std::size_t operator()(const express::entity& value) const noexcept {
|
||||
return std::hash<uint32_t>{}(value.identity());
|
||||
}
|
||||
};
|
||||
@@ -215,15 +222,15 @@ struct hash<express::Entity> {
|
||||
namespace boost {
|
||||
|
||||
template <>
|
||||
struct hash<express::Base> {
|
||||
std::size_t operator()(const express::Base& value) const noexcept {
|
||||
struct hash<express::base> {
|
||||
std::size_t operator()(const express::base& value) const noexcept {
|
||||
return std::hash<uint32_t>{}(value.identity());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<express::Entity> {
|
||||
std::size_t operator()(const express::Entity& value) const noexcept {
|
||||
struct hash<express::entity> {
|
||||
std::size_t operator()(const express::entity& value) const noexcept {
|
||||
return std::hash<uint32_t>{}(value.identity());
|
||||
}
|
||||
};
|
||||
@@ -257,7 +264,7 @@ typename std::conditional_t<
|
||||
std::vector<T>>
|
||||
cast_vector(const std::vector<U>& values) {
|
||||
if constexpr (is_std_vector<U>::value) {
|
||||
using V = typename U::value_type;
|
||||
using value_type = typename U::value_type;
|
||||
std::vector<std::vector<T>> result;
|
||||
result.reserve(values.size());
|
||||
for (const auto& value : values) {
|
||||
@@ -270,7 +277,7 @@ cast_vector(const std::vector<U>& values) {
|
||||
if constexpr (std::is_base_of_v<T, U>) {
|
||||
// For a base or identity transform we can just rely on static cast
|
||||
result.push_back(value);
|
||||
} else if constexpr (std::is_base_of_v<express::Select, U> && std::is_same_v<T, express::Base>) {
|
||||
} else if constexpr (std::is_base_of_v<express::select, U> && std::is_same_v<T, express::base>) {
|
||||
// From a select to concrete we simply call the appropriate method
|
||||
result.push_back(value.concrete());
|
||||
} else {
|
||||
|
||||
+16
-16
@@ -32,19 +32,19 @@ ifcopenshell::impl::rocks_db_file_storage::rocksdb_types_iterator::value_type co
|
||||
return storage_->file->schema()->declarations()[*read_id_()];
|
||||
}
|
||||
|
||||
express::Base ifcopenshell::impl::rocks_db_file_storage::assert_existance(size_t number, instance_ref r) {
|
||||
express::base ifcopenshell::impl::rocks_db_file_storage::assert_existance(size_t number, instance_ref r) {
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
std::lock_guard<std::mutex> lock(instance_cache_mutex_);
|
||||
|
||||
if (r == ifcopenshell::impl::rocks_db_file_storage::entityinstance_ref) {
|
||||
auto it = instance_cache_.find(number);
|
||||
if (it != instance_cache_.end()) {
|
||||
return express::Base(it->second);
|
||||
return express::base(it->second);
|
||||
}
|
||||
} else {
|
||||
auto it = type_instance_cache_.find(number);
|
||||
if (it != type_instance_cache_.end()) {
|
||||
return express::Base(it->second);
|
||||
return express::base(it->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ express::Base ifcopenshell::impl::rocks_db_file_storage::assert_existance(size_t
|
||||
} else {
|
||||
type_instance_cache_.insert({number, data});
|
||||
}
|
||||
return express::Base(data);
|
||||
return express::base(data);
|
||||
} else {
|
||||
throw exception("Instance #" + boost::lexical_cast<std::string>(number) + " not found");
|
||||
}
|
||||
@@ -147,7 +147,7 @@ ifcopenshell::impl::rocks_db_file_storage::rocks_db_file_storage(const std::stri
|
||||
, db(init_db(filepath, readonly))
|
||||
// @todo streaming serializer does not populate the byguid map
|
||||
, byguid_internal_(db.get(), "g|"),
|
||||
byguid_(&byguid_internal_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }, [](const express::Base& v) { return v.identity(); })
|
||||
byguid_(&byguid_internal_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }, [](const express::base& v) { return v.identity(); })
|
||||
, instance_ids_(db.get(), "i|")
|
||||
, instance_by_name_(&instance_ids_, [this](size_t v) { return assert_existance(v, entityinstance_ref); })
|
||||
, bytype_(db.get(), "t|")
|
||||
@@ -183,14 +183,14 @@ ifcopenshell::impl::rocks_db_file_storage::~rocks_db_file_storage()
|
||||
}
|
||||
|
||||
|
||||
express::Base ifcopenshell::impl::rocks_db_file_storage::instance_by_id(int id)
|
||||
express::base ifcopenshell::impl::rocks_db_file_storage::instance_by_id(int id)
|
||||
{
|
||||
// @todo rename assert_existance() -> instance_by_id();
|
||||
// - no cannot be done, because it needs to differentiate between entity instances and typedecls
|
||||
return assert_existance(id, entityinstance_ref);
|
||||
}
|
||||
|
||||
void ifcopenshell::impl::rocks_db_file_storage::process_deletion_inverse(const express::Base& inst)
|
||||
void ifcopenshell::impl::rocks_db_file_storage::process_deletion_inverse(const express::base& inst)
|
||||
{
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
auto id = inst.id();
|
||||
@@ -248,13 +248,13 @@ void ifcopenshell::impl::rocks_db_file_storage::process_deletion_inverse(const e
|
||||
#endif
|
||||
}
|
||||
|
||||
express::Base ifcopenshell::impl::in_memory_file_storage::instance_by_id(int id)
|
||||
express::base ifcopenshell::impl::in_memory_file_storage::instance_by_id(int id)
|
||||
{
|
||||
auto it = byid_.find(id);
|
||||
if (it == byid_.end()) {
|
||||
throw exception("Instance #" + boost::lexical_cast<std::string>(id) + " not found");
|
||||
}
|
||||
return express::Base(it->second);
|
||||
return express::base(it->second);
|
||||
}
|
||||
|
||||
ifcopenshell::file::~file() {}
|
||||
@@ -336,8 +336,8 @@ ifcopenshell::filetype ifcopenshell::guess_file_type(const std::string& fn) {
|
||||
}
|
||||
}
|
||||
|
||||
express::Base ifcopenshell::impl::rocks_db_file_storage::create(const ifcopenshell::declaration* decl, int id) {
|
||||
return express::Base{};
|
||||
express::base ifcopenshell::impl::rocks_db_file_storage::create(const ifcopenshell::declaration* decl, int id) {
|
||||
return express::base{};
|
||||
/*
|
||||
if (decl->as_entity() || decl->as_type_declaration()) {
|
||||
auto* inst = file->schema()->instantiate(decl, rocks_db_attribute_storage{});
|
||||
@@ -350,7 +350,7 @@ express::Base ifcopenshell::impl::rocks_db_file_storage::create(const ifcopenshe
|
||||
*/
|
||||
}
|
||||
|
||||
express::Base ifcopenshell::impl::in_memory_file_storage::create(const ifcopenshell::declaration* decl, int id) {
|
||||
express::base ifcopenshell::impl::in_memory_file_storage::create(const ifcopenshell::declaration* decl, int id) {
|
||||
uint32_t instance_name;
|
||||
if (decl->as_entity() != nullptr) {
|
||||
instance_name = id == -1 ? (int)file->fresh_id() : id;
|
||||
@@ -366,13 +366,13 @@ express::Base ifcopenshell::impl::in_memory_file_storage::create(const ifcopensh
|
||||
tbyid_.insert({data->identity(), data});
|
||||
}
|
||||
|
||||
express::Base inst(data);
|
||||
express::base inst(data);
|
||||
add_type_ref(inst);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
express::Base ifcopenshell::file::create(const ifcopenshell::declaration* decl, int id) {
|
||||
express::base ifcopenshell::file::create(const ifcopenshell::declaration* decl, int id) {
|
||||
if (id != -1) {
|
||||
if (decl->as_entity() == nullptr) {
|
||||
throw ifcopenshell::exception("Assigning instance id during creation is only valid for entity declarations");
|
||||
@@ -393,12 +393,12 @@ express::Base ifcopenshell::file::create(const ifcopenshell::declaration* decl,
|
||||
}
|
||||
}
|
||||
|
||||
return std::visit([&](auto& m) -> express::Base {
|
||||
return std::visit([&](auto& m) -> express::base {
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(m)>, impl::in_memory_file_storage> ||
|
||||
std::is_same_v<std::decay_t<decltype(m)>, impl::rocks_db_file_storage>) {
|
||||
return m.create(decl, id);
|
||||
} else {
|
||||
return express::Base{};
|
||||
return express::base{};
|
||||
}
|
||||
}, storage_);
|
||||
}
|
||||
|
||||
+23
-23
@@ -184,7 +184,7 @@ class uninitialized_tag {};
|
||||
/// The file takes ownership of instances added to this file and deletes them when the file is deleted.
|
||||
class IFC_PARSE_API file {
|
||||
private:
|
||||
typedef std::map<uint32_t, express::Base> entity_entity_map_t;
|
||||
typedef std::map<uint32_t, express::base> entity_entity_map_t;
|
||||
|
||||
// @todo determine the constness of things (probably needs to be all const, we don't want to overwrite)
|
||||
// @todo we have variant_iterator and MapVariant, we probably need to retain only one?
|
||||
@@ -232,7 +232,7 @@ public:
|
||||
batch_deletion_ids_t;
|
||||
batch_deletion_ids_t batch_deletion_ids_;
|
||||
bool batch_mode_ = false;
|
||||
void process_deletion_(const express::Base& entity);
|
||||
void process_deletion_(const express::base& entity);
|
||||
|
||||
public:
|
||||
#ifdef USE_MMAP
|
||||
@@ -311,7 +311,7 @@ public:
|
||||
/// IfcWall will also return IfcWallStandardCase entities
|
||||
template <class T>
|
||||
typename std::vector<T> instances_by_type() {
|
||||
std::vector<express::Base> untyped_list = instances_by_type(&T::Class());
|
||||
std::vector<express::base> untyped_list = instances_by_type(&T::Class());
|
||||
std::vector<T> return_value;
|
||||
for (auto& untyped : untyped_list) {
|
||||
return_value.push_back(untyped.as<T>());
|
||||
@@ -321,7 +321,7 @@ public:
|
||||
|
||||
template <class T>
|
||||
typename std::vector<T> instances_by_type_excl_subtypes() {
|
||||
std::vector<express::Base> untyped_list = instances_by_type_excl_subtypes(&T::Class());
|
||||
std::vector<express::base> untyped_list = instances_by_type_excl_subtypes(&T::Class());
|
||||
std::vector<T> return_value;
|
||||
for (auto& untyped : untyped_list) {
|
||||
return_value.push_back(untyped.as<T>());
|
||||
@@ -332,36 +332,36 @@ public:
|
||||
/// Returns all entities in the file that match the positional argument.
|
||||
/// NOTE: This also returns subtypes of the requested type, for example:
|
||||
/// IfcWall will also return IfcWallStandardCase entities
|
||||
std::vector<express::Base> instances_by_type(const ifcopenshell::declaration* declaration);
|
||||
std::vector<express::base> instances_by_type(const ifcopenshell::declaration* declaration);
|
||||
|
||||
/// Returns all entities in the file that match the positional argument.
|
||||
std::vector<express::Base> instances_by_type_excl_subtypes(const ifcopenshell::declaration* declaration);
|
||||
std::vector<express::base> instances_by_type_excl_subtypes(const ifcopenshell::declaration* declaration);
|
||||
|
||||
/// Returns all entities in the file that match the positional argument.
|
||||
/// NOTE: This also returns subtypes of the requested type, for example:
|
||||
/// IfcWall will also return IfcWallStandardCase entities
|
||||
std::vector<express::Base> instances_by_type(const std::string& type_name);
|
||||
std::vector<express::base> instances_by_type(const std::string& type_name);
|
||||
|
||||
/// Returns all entities in the file that match the positional argument.
|
||||
std::vector<express::Base> instances_by_type_excl_subtypes(const std::string& type_name);
|
||||
std::vector<express::base> instances_by_type_excl_subtypes(const std::string& type_name);
|
||||
|
||||
/// Returns all entities in the file that reference the id
|
||||
std::vector<express::Base> instances_by_reference(int reference_id);
|
||||
std::vector<express::base> instances_by_reference(int reference_id);
|
||||
|
||||
/// Returns the entity with the specified id
|
||||
express::Base instance_by_id(int instance_id);
|
||||
express::base instance_by_id(int instance_id);
|
||||
|
||||
/// Returns the entity with the specified GlobalId
|
||||
express::Base instance_by_guid(const std::string& global_id);
|
||||
express::base instance_by_guid(const std::string& global_id);
|
||||
|
||||
/// Performs a depth-first traversal, returning all entity instance
|
||||
/// attributes as a flat list. NB: includes the root instance specified
|
||||
/// in the first function argument.
|
||||
static std::vector<express::Base> traverse(const express::Base& instance, int max_depth = -1);
|
||||
static std::vector<express::base> traverse(const express::base& instance, int max_depth = -1);
|
||||
|
||||
/// Same as traverse() but maintains topological order by using a
|
||||
/// breadth-first search
|
||||
static std::vector<express::Base> traverse_breadth_first(const express::Base& instance, int max_depth = -1);
|
||||
static std::vector<express::base> traverse_breadth_first(const express::base& instance, int max_depth = -1);
|
||||
|
||||
/// Get the attribute indices corresponding to the list of entity instances
|
||||
/// returned by get_inverse().
|
||||
@@ -372,7 +372,7 @@ public:
|
||||
return get_inverse(instance_id, &T::Class(), attribute_index)->template as<T>();
|
||||
}
|
||||
|
||||
std::vector<express::Entity> get_inverse(int instance_id, const ifcopenshell::declaration* declaration, int attribute_index);
|
||||
std::vector<express::entity> get_inverse(int instance_id, const ifcopenshell::declaration* declaration, int attribute_index);
|
||||
|
||||
size_t get_total_inverses(int instance_id);
|
||||
|
||||
@@ -384,7 +384,7 @@ public:
|
||||
|
||||
void recalculate_id_counter();
|
||||
|
||||
express::Base add_entity(const express::Base& entity, int instance_id = -1);
|
||||
express::base add_entity(const express::base& entity, int instance_id = -1);
|
||||
|
||||
/// Removes entity instance from file and unsets references.
|
||||
///
|
||||
@@ -395,7 +395,7 @@ public:
|
||||
/// ifcopenshell::IfcBaseClass *const inst = *it;
|
||||
/// model->remove_entity(inst);
|
||||
/// }
|
||||
void remove_entity(const express::Base& entity);
|
||||
void remove_entity(const express::base& entity);
|
||||
|
||||
const spf_header& header() const { return *header_; }
|
||||
spf_header& header() { return *header_; }
|
||||
@@ -404,27 +404,27 @@ public:
|
||||
|
||||
const ifcopenshell::schema_definition* schema() const;
|
||||
|
||||
std::pair<express::Base, double> get_unit(const std::string& unit_type);
|
||||
std::pair<express::base, double> get_unit(const std::string& unit_type);
|
||||
|
||||
void build_inverses();
|
||||
|
||||
void register_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, int instance_id, int attribute_index);
|
||||
void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::Base& entity, int attribute_index);
|
||||
void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::base& entity, int attribute_index);
|
||||
|
||||
entity_instance_by_guid_t internal_guid_map() { return byguid_; };
|
||||
|
||||
void add_type_ref(const express::Base& new_entity);
|
||||
void remove_type_ref(const express::Base& new_entity);
|
||||
void process_deletion_inverse(const express::Base& entity);
|
||||
void add_type_ref(const express::base& new_entity);
|
||||
void remove_type_ref(const express::base& new_entity);
|
||||
void process_deletion_inverse(const express::base& entity);
|
||||
|
||||
void build_inverses_(const express::Base& entity);
|
||||
void build_inverses_(const express::base& entity);
|
||||
|
||||
template <typename T>
|
||||
T create(int instance_id = -1) {
|
||||
return create(&T::Class(), instance_id).template as<T>();
|
||||
}
|
||||
|
||||
express::Base create(const ifcopenshell::declaration* declaration, int instance_id = -1);
|
||||
express::base create(const ifcopenshell::declaration* declaration, int instance_id = -1);
|
||||
|
||||
void batch() {
|
||||
batch_mode_ = true;
|
||||
|
||||
@@ -218,12 +218,12 @@ const file_reader_page& paged_file_impl::fetchPage_(size_t idx) const {
|
||||
}
|
||||
lru_.push_front(idx);
|
||||
auto lit = lru_.begin();
|
||||
auto [emplaced_it, ok] = map_.emplace(idx, Entry{std::move(pg), lit});
|
||||
auto [emplaced_it, ok] = map_.emplace(idx, entry{std::move(pg), lit});
|
||||
(void)ok;
|
||||
return emplaced_it->second.page;
|
||||
}
|
||||
|
||||
void paged_file_impl::touch_(std::unordered_map<size_t, Entry>::iterator it) const {
|
||||
void paged_file_impl::touch_(std::unordered_map<size_t, entry>::iterator it) const {
|
||||
lru_.erase(it->second.it);
|
||||
lru_.push_front(it->first);
|
||||
it->second.it = lru_.begin();
|
||||
|
||||
@@ -68,7 +68,7 @@ template <typename Impl>
|
||||
class file_reader {
|
||||
public:
|
||||
using impl_type = Impl;
|
||||
using Page = file_reader_page;
|
||||
using page = file_reader_page;
|
||||
|
||||
file_reader() = default;
|
||||
|
||||
@@ -215,7 +215,7 @@ private:
|
||||
|
||||
class IFC_PARSE_API paged_file_impl {
|
||||
public:
|
||||
struct Entry {
|
||||
struct entry {
|
||||
file_reader_page page;
|
||||
std::list<size_t>::iterator it;
|
||||
};
|
||||
@@ -232,7 +232,7 @@ public:
|
||||
|
||||
private:
|
||||
const file_reader_page& fetchPage_(size_t page_index) const;
|
||||
void touch_(std::unordered_map<size_t, Entry>::iterator entry_it) const;
|
||||
void touch_(std::unordered_map<size_t, entry>::iterator entry_it) const;
|
||||
void evict_() const;
|
||||
|
||||
std::string fn_;
|
||||
@@ -241,7 +241,7 @@ private:
|
||||
size_t page_size_ = 4096;
|
||||
size_t capacity_ = 8;
|
||||
mutable std::list<size_t> lru_;
|
||||
mutable std::unordered_map<size_t, Entry> map_;
|
||||
mutable std::unordered_map<size_t, entry> map_;
|
||||
};
|
||||
|
||||
#ifdef USE_MMAP
|
||||
|
||||
@@ -49,17 +49,17 @@ inline const char* children_attribute_name(const ifcopenshell::declaration& decl
|
||||
}
|
||||
|
||||
template <typename Relation>
|
||||
express::Base get_parent_of_relation(const Relation& relation) {
|
||||
return relation.template as<express::Entity>().get(parent_attribute_name(relation.declaration()));
|
||||
express::base get_parent_of_relation(const Relation& relation) {
|
||||
return relation.template as<express::entity>().get(parent_attribute_name(relation.declaration()));
|
||||
}
|
||||
|
||||
template <typename Relation>
|
||||
std::vector<express::Base> get_children_of_relation(const Relation& relation) {
|
||||
return relation.template as<express::Entity>().get(children_attribute_name(relation.declaration()));
|
||||
std::vector<express::base> get_children_of_relation(const Relation& relation) {
|
||||
return relation.template as<express::entity>().get(children_attribute_name(relation.declaration()));
|
||||
}
|
||||
|
||||
template <typename Relation>
|
||||
void set_children_of_relation(Relation& relation, std::vector<express::Base>& children) {
|
||||
void set_children_of_relation(Relation& relation, std::vector<express::base>& children) {
|
||||
relation.set_attribute_value(children_attribute_name(relation.declaration()), children);
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ class IFC_SCHEMA_API hierarchy_helper : public ifcopenshell::file {
|
||||
owner_history = addOwnerHistory();
|
||||
}
|
||||
|
||||
std::vector<express::Base> related_objects;
|
||||
std::vector<express::base> related_objects;
|
||||
related_objects.push_back(related_object);
|
||||
|
||||
T t = create<T>();
|
||||
|
||||
@@ -75,72 +75,72 @@ class IFC_PARSE_API empty_aggregate_of_aggregate_t {};
|
||||
|
||||
namespace impl {
|
||||
template <>
|
||||
struct VariantTypeName<blank> {
|
||||
struct variant_type_name<blank> {
|
||||
static std::string get() { return "null"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<derived> {
|
||||
struct variant_type_name<derived> {
|
||||
static std::string get() { return "derived"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<int> {
|
||||
struct variant_type_name<int> {
|
||||
static std::string get() { return "int"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<int64_t> {
|
||||
struct variant_type_name<int64_t> {
|
||||
static std::string get() { return "int"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<bool> {
|
||||
struct variant_type_name<bool> {
|
||||
static std::string get() { return "bool"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<boost::logic::tribool> {
|
||||
struct variant_type_name<boost::logic::tribool> {
|
||||
static std::string get() { return "logical"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<double> {
|
||||
struct variant_type_name<double> {
|
||||
static std::string get() { return "real"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<std::string> {
|
||||
struct variant_type_name<std::string> {
|
||||
static std::string get() { return "string"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<boost::dynamic_bitset<>> {
|
||||
struct variant_type_name<boost::dynamic_bitset<>> {
|
||||
static std::string get() { return "binary"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<enumeration_reference> {
|
||||
struct variant_type_name<enumeration_reference> {
|
||||
static std::string get() { return "enumeration"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<express::Base> {
|
||||
struct variant_type_name<express::base> {
|
||||
static std::string get() { return "instance"; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<empty_aggregate_t> {
|
||||
struct variant_type_name<empty_aggregate_t> {
|
||||
static std::string get() { return "aggregate"; }
|
||||
};
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
struct VariantTypeName<std::vector<T, Allocator>> {
|
||||
static std::string get() { return "aggregate of " + VariantTypeName<T>::get(); }
|
||||
struct variant_type_name<std::vector<T, Allocator>> {
|
||||
static std::string get() { return "aggregate of " + variant_type_name<T>::get(); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct VariantTypeName<empty_aggregate_of_aggregate_t> {
|
||||
struct variant_type_name<empty_aggregate_of_aggregate_t> {
|
||||
static std::string get() { return "aggregate of aggregate"; }
|
||||
};
|
||||
}
|
||||
@@ -182,7 +182,7 @@ typedef parameter_pack <
|
||||
// An entity instance argument. It will either serialize to
|
||||
// e.g. #123 or datatype identifier for simple types, e.g.
|
||||
// IFCREAL(12.3)
|
||||
express::Base,
|
||||
express::base,
|
||||
|
||||
// AGGREGATES:
|
||||
empty_aggregate_t,
|
||||
@@ -198,7 +198,7 @@ typedef parameter_pack <
|
||||
// An aggregate of entity instances. It will either serialize to
|
||||
// e.g. (#1,#2,#3) or datatype identifier for simple types,
|
||||
// e.g. (IFCREAL(1.2),IFCINTEGER(3.))
|
||||
std::vector<express::Base>,
|
||||
std::vector<express::base>,
|
||||
|
||||
// AGGREGATES OF AGGREGATES:
|
||||
empty_aggregate_of_aggregate_t,
|
||||
@@ -207,7 +207,7 @@ typedef parameter_pack <
|
||||
// An aggregate of an aggregate of floats. E.g. ((1., 2.3), (4.))
|
||||
std::vector<std::vector<double>>,
|
||||
// An aggregate of an aggregate of entities. E.g. ((#1, #2), (#3))
|
||||
std::vector<std::vector<express::Base>>>
|
||||
std::vector<std::vector<express::base>>>
|
||||
type_variant_parameter_pack;
|
||||
|
||||
template<typename Pack>
|
||||
@@ -221,17 +221,17 @@ struct pack_to_variant_array<parameter_pack<Args...>> {
|
||||
using in_memory_attribute_storage = pack_to_variant_array<type_variant_parameter_pack>::type;
|
||||
|
||||
template <typename Pack>
|
||||
struct TypeEncoder_t;
|
||||
struct type_encoder_t;
|
||||
|
||||
template <typename... Types>
|
||||
struct TypeEncoder_t<parameter_pack<Types...>> {
|
||||
struct type_encoder_t<parameter_pack<Types...>> {
|
||||
template <typename U>
|
||||
static char encode_type() {
|
||||
return 'A' + ::impl::TypeIndex_v<U, Types...>;
|
||||
}
|
||||
};
|
||||
|
||||
using TypeEncoder = TypeEncoder_t<type_variant_parameter_pack>;
|
||||
using type_encoder = type_encoder_t<type_variant_parameter_pack>;
|
||||
|
||||
class IFC_PARSE_API mutable_attribute_value {
|
||||
public:
|
||||
@@ -261,14 +261,14 @@ namespace impl {
|
||||
bool serialize(std::string& buffer, const T& value) {
|
||||
auto byte_count = sizeof(typename T::value_type) * value.size();
|
||||
buffer.resize(byte_count + 1);
|
||||
buffer[0] = TypeEncoder::encode_type<T>();
|
||||
buffer[0] = type_encoder::encode_type<T>();
|
||||
memcpy(buffer.data() + 1, value.data(), byte_count);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T, typename std::enable_if<is_contiguous_container<T>::value&& is_contiguous_container<typename T::value_type>::value, int>::type = 0>
|
||||
bool serialize(std::string& buffer, const T& value) {
|
||||
buffer = std::string(1, TypeEncoder::encode_type<T>());
|
||||
buffer = std::string(1, type_encoder::encode_type<T>());
|
||||
for (auto& nested_value : value) {
|
||||
std::string nested_buffer;
|
||||
serialize(nested_buffer, nested_value);
|
||||
@@ -285,7 +285,7 @@ namespace impl {
|
||||
template <typename T, typename std::enable_if<std::is_integral_v<T> || std::is_floating_point_v<T>, int>::type = 0>
|
||||
bool serialize(std::string& buffer, const T& value) {
|
||||
buffer.resize(sizeof(T) + 1);
|
||||
buffer[0] = TypeEncoder::encode_type<T>();
|
||||
buffer[0] = type_encoder::encode_type<T>();
|
||||
memcpy(buffer.data() + 1, &value, sizeof(T));
|
||||
return true;
|
||||
}
|
||||
@@ -300,18 +300,18 @@ namespace impl {
|
||||
|
||||
bool serialize(std::string& buffer, const boost::dynamic_bitset<>& value);
|
||||
|
||||
bool serialize(std::string& buffer, const express::Base& value);
|
||||
bool serialize(std::string& buffer, const express::base& value);
|
||||
|
||||
bool serialize(std::string& buffer, const enumeration_reference& value);
|
||||
|
||||
bool serialize(std::string& buffer, const std::vector<express::Base>& value);
|
||||
bool serialize(std::string& buffer, const std::vector<express::base>& value);
|
||||
|
||||
bool serialize(std::string& buffer, const std::vector<std::vector<express::Base>>& value);
|
||||
bool serialize(std::string& buffer, const std::vector<std::vector<express::base>>& value);
|
||||
|
||||
template <typename T, typename std::enable_if<is_contiguous_container<T>::value && !is_contiguous_container<typename T::value_type>::value, int>::type = 0>
|
||||
bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, T& value, bool has_type_prefix = true) {
|
||||
static_cast<void>(storage);
|
||||
if (has_type_prefix && buffer[0] != TypeEncoder::encode_type<T>()) {
|
||||
if (has_type_prefix && buffer[0] != type_encoder::encode_type<T>()) {
|
||||
return false;
|
||||
}
|
||||
auto element_count = (buffer.size() - (has_type_prefix ? 1 : 0)) / sizeof(typename T::value_type);
|
||||
@@ -324,7 +324,7 @@ namespace impl {
|
||||
bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, T& value) {
|
||||
// @todo
|
||||
auto ptr = buffer.data();
|
||||
if (*ptr != TypeEncoder::encode_type<T>()) {
|
||||
if (*ptr != type_encoder::encode_type<T>()) {
|
||||
return false;
|
||||
}
|
||||
ptr++;
|
||||
@@ -345,7 +345,7 @@ namespace impl {
|
||||
template <typename T, typename std::enable_if<std::is_integral_v<T> || std::is_floating_point_v<T>, int>::type = 0>
|
||||
bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, T& value) {
|
||||
static_cast<void>(storage);
|
||||
if (buffer[0] != TypeEncoder::encode_type<T>()) {
|
||||
if (buffer[0] != type_encoder::encode_type<T>()) {
|
||||
return false;
|
||||
}
|
||||
memcpy(&value, buffer.data() + 1, sizeof(T));
|
||||
@@ -356,9 +356,9 @@ namespace impl {
|
||||
|
||||
bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, boost::dynamic_bitset<>& value);
|
||||
|
||||
bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, std::vector<express::Base>& value);
|
||||
bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, std::vector<express::base>& value);
|
||||
|
||||
bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, std::vector<std::vector<express::Base>>& value);
|
||||
bool deserialize(ifcopenshell::impl::rocks_db_file_storage* storage, const std::string& buffer, std::vector<std::vector<express::base>>& value);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -408,17 +408,17 @@ public:
|
||||
operator double() const;
|
||||
operator std::string() const;
|
||||
operator boost::dynamic_bitset<>() const;
|
||||
operator express::Base() const;
|
||||
operator express::base() const;
|
||||
|
||||
operator std::vector<int64_t>() const;
|
||||
operator std::vector<double>() const;
|
||||
operator std::vector<std::string>() const;
|
||||
operator std::vector<boost::dynamic_bitset<>>() const;
|
||||
operator std::vector<express::Base>() const;
|
||||
operator std::vector<express::base>() const;
|
||||
|
||||
operator std::vector<std::vector<int64_t>>() const;
|
||||
operator std::vector<std::vector<double>>() const;
|
||||
operator std::vector<std::vector<express::Base>>() const;
|
||||
operator std::vector<std::vector<express::base>>() const;
|
||||
|
||||
operator enumeration_reference() const;
|
||||
|
||||
@@ -449,7 +449,7 @@ public:
|
||||
case ifcopenshell::Argument_ENUMERATION:
|
||||
return visitor((enumeration_reference)*this);
|
||||
case ifcopenshell::Argument_ENTITY_INSTANCE:
|
||||
return visitor((express::Base) * this);
|
||||
return visitor((express::base) * this);
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_INT:
|
||||
return visitor((std::vector<int64_t>)*this);
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_DOUBLE:
|
||||
@@ -459,13 +459,13 @@ public:
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_BINARY:
|
||||
return visitor((std::vector<boost::dynamic_bitset<>>)*this);
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_ENTITY_INSTANCE:
|
||||
return visitor((std::vector<express::Base>)*this);
|
||||
return visitor((std::vector<express::base>)*this);
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_INT:
|
||||
return visitor((std::vector<std::vector<int64_t>>)*this);
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE:
|
||||
return visitor((std::vector<std::vector<double>>)*this);
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE:
|
||||
return visitor((std::vector<std::vector<express::Base>>)*this);
|
||||
return visitor((std::vector<std::vector<express::base>>)*this);
|
||||
case ifcopenshell::Argument_EMPTY_AGGREGATE:
|
||||
return visitor(empty_aggregate_t{});
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_EMPTY_AGGREGATE:
|
||||
|
||||
+19
-19
@@ -73,12 +73,12 @@ void write_code(T& out, const std::string& code) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void plain_text_message(T& out, const express::Base& current_product, logger::Severity type, const std::string& code, const std::string& message, const express::Base& instance) {
|
||||
void plain_text_message(T& out, const express::base& current_product, logger::severity type, const std::string& code, const std::string& message, const express::base& instance) {
|
||||
out << "[" << severity_strings<typename T::char_type>::value[type] << "] ";
|
||||
write_code(out, code);
|
||||
out << "[" << get_time(type <= logger::LOG_PERF).c_str() << "] ";
|
||||
if (current_product) {
|
||||
express::Entity entity = current_product.as<express::Entity>();
|
||||
express::entity entity = current_product.as<express::entity>();
|
||||
if (entity) {
|
||||
std::string global_id = entity.get("GlobalId");
|
||||
out << "{" << global_id.c_str() << "} ";
|
||||
@@ -104,7 +104,7 @@ std::basic_string<T> string_as(const std::string& string) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void json_message(T& out, const express::Base& current_product, logger::Severity type, const std::string& code, const std::string& message, const express::Base& instance) {
|
||||
void json_message(T& out, const express::base& current_product, logger::severity type, const std::string& code, const std::string& message, const express::base& instance) {
|
||||
boost::property_tree::basic_ptree<std::basic_string<typename T::char_type>, std::basic_string<typename T::char_type>> property_tree;
|
||||
|
||||
static const typename T::char_type time_string[] = {'t', 'i', 'm', 'e', 0};
|
||||
@@ -146,8 +146,8 @@ log_message::log_message(
|
||||
const std::string& code,
|
||||
const std::string& timestamp,
|
||||
const std::string& message,
|
||||
const express::Base& instance,
|
||||
const express::Base& current_product)
|
||||
const express::base& instance,
|
||||
const express::base& current_product)
|
||||
: severity(severity)
|
||||
, timestamp(timestamp)
|
||||
, message(message)
|
||||
@@ -170,15 +170,15 @@ logger& logger::root() {
|
||||
return root_logger;
|
||||
}
|
||||
|
||||
const express::Base& logger::current_product() const {
|
||||
const express::base& logger::current_product() const {
|
||||
return current_product_;
|
||||
}
|
||||
|
||||
void logger::current_product(const express::Base& product) {
|
||||
void logger::current_product(const express::base& product) {
|
||||
current_product_ = product;
|
||||
}
|
||||
|
||||
void logger::set_product(std::optional<express::Base> product) {
|
||||
void logger::set_product(std::optional<express::base> product) {
|
||||
if (verbosity_ <= LOG_DEBUG && product) {
|
||||
message(LOG_DEBUG, "SYS", 3, "Begin processing", *product);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ void logger::set_product(std::optional<express::Base> product) {
|
||||
print_performance_stats();
|
||||
performance_statistics_.clear();
|
||||
}
|
||||
current_product(product.value_or(express::Base{}));
|
||||
current_product(product.value_or(express::base{}));
|
||||
}
|
||||
|
||||
void logger::set_output(std::ostream* stream1, std::ostream* stream2) {
|
||||
@@ -204,23 +204,23 @@ void logger::set_output(std::wostream* stream1, std::wostream* stream2) {
|
||||
wlog2_ = stream2;
|
||||
}
|
||||
|
||||
void logger::message(logger::Severity type, const std::string& text, const express::Base& instance) {
|
||||
void logger::message(logger::severity type, const std::string& text, const express::base& instance) {
|
||||
message(type, std::string(), text, instance);
|
||||
}
|
||||
|
||||
void logger::message(logger::Severity type, const std::exception& exception, const express::Base& instance) {
|
||||
void logger::message(logger::severity type, const std::exception& exception, const express::base& instance) {
|
||||
message(type, std::string(exception.what()), instance);
|
||||
}
|
||||
|
||||
void logger::message(logger::Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& text, const express::Base& instance) {
|
||||
void logger::message(logger::severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& text, const express::base& instance) {
|
||||
message(type, format_code(code_prefix, code_number), text, instance);
|
||||
}
|
||||
|
||||
void logger::message(logger::Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance) {
|
||||
void logger::message(logger::severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::base& instance) {
|
||||
message(type, code_prefix, code_number, std::string(exception.what()), instance);
|
||||
}
|
||||
|
||||
void logger::message(logger::Severity type, const std::string& code, const std::string& text, const express::Base& instance) {
|
||||
void logger::message(logger::severity type, const std::string& code, const std::string& text, const express::base& instance) {
|
||||
if (type < verbosity_) {
|
||||
return;
|
||||
}
|
||||
@@ -359,22 +359,22 @@ void logger::print_performance_stats() {
|
||||
}
|
||||
}
|
||||
|
||||
void logger::verbosity(logger::Severity severity) {
|
||||
void logger::verbosity(logger::severity severity) {
|
||||
verbosity_ = severity;
|
||||
}
|
||||
|
||||
logger::Severity logger::verbosity() const {
|
||||
logger::severity logger::verbosity() const {
|
||||
return verbosity_;
|
||||
}
|
||||
|
||||
logger::Severity logger::max_severity() const {
|
||||
logger::severity logger::max_severity() const {
|
||||
return max_severity_;
|
||||
}
|
||||
|
||||
void logger::output_format(Format format) {
|
||||
void logger::output_format(format format) {
|
||||
format_ = format;
|
||||
}
|
||||
|
||||
logger::Format logger::output_format() const {
|
||||
logger::format logger::output_format() const {
|
||||
return format_;
|
||||
}
|
||||
|
||||
+34
-34
@@ -45,8 +45,8 @@ class IFC_PARSE_API log_message {
|
||||
const std::string& code,
|
||||
const std::string& timestamp,
|
||||
const std::string& message,
|
||||
const express::Base& instance = express::Base(),
|
||||
const express::Base& current_product = express::Base());
|
||||
const express::base& instance = express::base(),
|
||||
const express::base& current_product = express::base());
|
||||
};
|
||||
|
||||
class IFC_PARSE_API logger {
|
||||
@@ -57,13 +57,13 @@ class IFC_PARSE_API logger {
|
||||
LOG_NOTICE,
|
||||
LOG_WARNING,
|
||||
LOG_ERROR
|
||||
} Severity;
|
||||
} severity;
|
||||
|
||||
typedef enum {
|
||||
FMT_PLAIN,
|
||||
FMT_JSON,
|
||||
FMT_INMEMORY
|
||||
} Format;
|
||||
} format;
|
||||
|
||||
private:
|
||||
std::vector<log_message> log_messages_;
|
||||
@@ -75,11 +75,11 @@ class IFC_PARSE_API logger {
|
||||
std::wostream* wlog2_ = nullptr;
|
||||
|
||||
std::stringstream log_stream_;
|
||||
express::Base current_product_;
|
||||
express::base current_product_;
|
||||
|
||||
Severity verbosity_ = LOG_NOTICE;
|
||||
Format format_ = FMT_PLAIN;
|
||||
Severity max_severity_ = LOG_NOTICE;
|
||||
severity verbosity_ = LOG_NOTICE;
|
||||
format format_ = FMT_PLAIN;
|
||||
severity max_severity_ = LOG_NOTICE;
|
||||
|
||||
std::optional<long long> first_timepoint_;
|
||||
std::map<std::string, double> performance_statistics_;
|
||||
@@ -88,9 +88,9 @@ class IFC_PARSE_API logger {
|
||||
bool print_perf_stats_on_element_ = false;
|
||||
std::mutex mutex_;
|
||||
|
||||
const express::Base& current_product() const;
|
||||
void current_product(const express::Base& product);
|
||||
void message(Severity type, const std::string& code, const std::string& message, const express::Base& instance);
|
||||
const express::base& current_product() const;
|
||||
void current_product(const express::base& product);
|
||||
void message(severity type, const std::string& code, const std::string& message, const express::base& instance);
|
||||
|
||||
public:
|
||||
logger() = default;
|
||||
@@ -99,39 +99,39 @@ class IFC_PARSE_API logger {
|
||||
|
||||
static logger& root();
|
||||
|
||||
void set_product(std::optional<express::Base> product);
|
||||
void set_product(const express::Base& product) { set_product(std::optional<express::Base>(product)); }
|
||||
void set_product(std::optional<express::base> product);
|
||||
void set_product(const express::base& product) { set_product(std::optional<express::base>(product)); }
|
||||
|
||||
void set_output(std::wostream* stream1, std::wostream* stream2);
|
||||
void set_output(std::ostream* stream1, std::ostream* stream2);
|
||||
|
||||
void verbosity(Severity severity);
|
||||
Severity verbosity() const;
|
||||
Severity max_severity() const;
|
||||
void verbosity(severity severity);
|
||||
severity verbosity() const;
|
||||
severity max_severity() const;
|
||||
|
||||
void output_format(Format format);
|
||||
Format output_format() const;
|
||||
void output_format(format format);
|
||||
format output_format() const;
|
||||
|
||||
void message(Severity type, const std::string& message, const express::Base& instance = express::Base());
|
||||
void message(Severity type, const std::exception& exception, const express::Base& instance = express::Base());
|
||||
void message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base());
|
||||
void message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base());
|
||||
void message(severity type, const std::string& message, const express::base& instance = express::base());
|
||||
void message(severity type, const std::exception& exception, const express::base& instance = express::base());
|
||||
void message(severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::base& instance = express::base());
|
||||
void message(severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::base& instance = express::base());
|
||||
|
||||
void notice(const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_NOTICE, message, instance); }
|
||||
void warning(const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_WARNING, message, instance); }
|
||||
void error(const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_ERROR, message, instance); }
|
||||
void notice(const std::string& message, const express::base& instance = express::base()) { this->message(LOG_NOTICE, message, instance); }
|
||||
void warning(const std::string& message, const express::base& instance = express::base()) { this->message(LOG_WARNING, message, instance); }
|
||||
void error(const std::string& message, const express::base& instance = express::base()) { this->message(LOG_ERROR, message, instance); }
|
||||
|
||||
void notice(const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_NOTICE, exception, instance); }
|
||||
void warning(const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_WARNING, exception, instance); }
|
||||
void error(const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_ERROR, exception, instance); }
|
||||
void notice(const std::exception& exception, const express::base& instance = express::base()) { message(LOG_NOTICE, exception, instance); }
|
||||
void warning(const std::exception& exception, const express::base& instance = express::base()) { message(LOG_WARNING, exception, instance); }
|
||||
void error(const std::exception& exception, const express::base& instance = express::base()) { message(LOG_ERROR, exception, instance); }
|
||||
|
||||
void notice(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_NOTICE, code_prefix, code_number, message, instance); }
|
||||
void warning(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_WARNING, code_prefix, code_number, message, instance); }
|
||||
void error(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::Base& instance = express::Base()) { this->message(LOG_ERROR, code_prefix, code_number, message, instance); }
|
||||
void notice(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::base& instance = express::base()) { this->message(LOG_NOTICE, code_prefix, code_number, message, instance); }
|
||||
void warning(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::base& instance = express::base()) { this->message(LOG_WARNING, code_prefix, code_number, message, instance); }
|
||||
void error(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const express::base& instance = express::base()) { this->message(LOG_ERROR, code_prefix, code_number, message, instance); }
|
||||
|
||||
void notice(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_NOTICE, code_prefix, code_number, exception, instance); }
|
||||
void warning(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_WARNING, code_prefix, code_number, exception, instance); }
|
||||
void error(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::Base& instance = express::Base()) { message(LOG_ERROR, code_prefix, code_number, exception, instance); }
|
||||
void notice(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::base& instance = express::base()) { message(LOG_NOTICE, code_prefix, code_number, exception, instance); }
|
||||
void warning(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::base& instance = express::base()) { message(LOG_WARNING, code_prefix, code_number, exception, instance); }
|
||||
void error(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const express::base& instance = express::base()) { message(LOG_ERROR, code_prefix, code_number, exception, instance); }
|
||||
|
||||
void status(const std::string& message, bool new_line = true);
|
||||
|
||||
|
||||
+208
-208
@@ -940,7 +940,7 @@ direct_aggregate read_direct_aggregate(
|
||||
tokens->next();
|
||||
auto data = storage.load(tokens, entity_instance_name, declaration, entity, attribute_index);
|
||||
storage.read_simple_type_instances.push_back(data);
|
||||
aggregate.append(ifcopenshell::reference_or_simple_type{express::Base(data)});
|
||||
aggregate.append(ifcopenshell::reference_or_simple_type{express::base(data)});
|
||||
} catch (exception& e) {
|
||||
logger.error("SYN", 123, std::string(e.what()) + " at offset " + std::to_string(next.start_pos));
|
||||
}
|
||||
@@ -1016,7 +1016,7 @@ shared_pointer_type ifcopenshell::impl::in_memory_file_storage::load(
|
||||
if (retain_value) {
|
||||
auto data = load(tokens, entity_instance_name, simple_declaration, entity, reference_attribute_index);
|
||||
read_simple_type_instances.push_back(data);
|
||||
storage.set(attribute_index_within_data, express::Base(data));
|
||||
storage.set(attribute_index_within_data, express::base(data));
|
||||
} else {
|
||||
skip_aggregate(tokens);
|
||||
}
|
||||
@@ -1056,7 +1056,7 @@ void ifcopenshell::impl::in_memory_file_storage::register_inverse(unsigned id_fr
|
||||
byref_excl_.add((uint32_t)inst_id, (uint32_t)id_from, (uint16_t)from_entity->index_in_schema(), attribute_index);
|
||||
}
|
||||
|
||||
void ifcopenshell::impl::in_memory_file_storage::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::Base& inst, int attribute_index) {
|
||||
void ifcopenshell::impl::in_memory_file_storage::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::base& inst, int attribute_index) {
|
||||
if (!byref_excl_.remove((uint32_t)inst.id(), (uint32_t)id_from, (uint16_t)from_entity->index_in_schema(), attribute_index)) {
|
||||
// @todo inverses also need to be populated when multiple instances are added to a new file.
|
||||
// throw ifcopenshell::exception("Instance not found among inverses");
|
||||
@@ -1095,7 +1095,7 @@ void ifcopenshell::impl::rocks_db_file_storage::register_inverse(unsigned id_fro
|
||||
#endif
|
||||
}
|
||||
|
||||
void ifcopenshell::impl::rocks_db_file_storage::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::Base& inst, int attribute_index) {
|
||||
void ifcopenshell::impl::rocks_db_file_storage::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::base& inst, int attribute_index) {
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
static std::string s;
|
||||
auto inst_id = inst.id();
|
||||
@@ -1116,7 +1116,7 @@ void ifcopenshell::impl::rocks_db_file_storage::unregister_inverse(unsigned id_f
|
||||
#endif
|
||||
}
|
||||
|
||||
void ifcopenshell::impl::rocks_db_file_storage::add_type_ref(const express::Base& new_entity)
|
||||
void ifcopenshell::impl::rocks_db_file_storage::add_type_ref(const express::base& new_entity)
|
||||
{
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
size_t v;
|
||||
@@ -1146,7 +1146,7 @@ void ifcopenshell::impl::rocks_db_file_storage::add_type_ref(const express::Base
|
||||
#endif
|
||||
}
|
||||
|
||||
void ifcopenshell::impl::rocks_db_file_storage::remove_type_ref(const express::Base& new_entity)
|
||||
void ifcopenshell::impl::rocks_db_file_storage::remove_type_ref(const express::base& new_entity)
|
||||
{
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
if (new_entity.declaration().as_entity()) {
|
||||
@@ -1167,10 +1167,10 @@ void ifcopenshell::impl::rocks_db_file_storage::remove_type_ref(const express::B
|
||||
}
|
||||
|
||||
namespace {
|
||||
class StringBuilderVisitor : public boost::static_visitor<void> {
|
||||
class string_builder_visitor : public boost::static_visitor<void> {
|
||||
private:
|
||||
StringBuilderVisitor(const StringBuilderVisitor&); //N/A
|
||||
StringBuilderVisitor& operator=(const StringBuilderVisitor&); //N/A
|
||||
string_builder_visitor(const string_builder_visitor&); //N/A
|
||||
string_builder_visitor& operator=(const string_builder_visitor&); //N/A
|
||||
|
||||
std::ostream& data_;
|
||||
template <typename T>
|
||||
@@ -1269,7 +1269,7 @@ namespace {
|
||||
bool upper_;
|
||||
|
||||
public:
|
||||
StringBuilderVisitor(std::ostream& stream, bool upper = false)
|
||||
string_builder_visitor(std::ostream& stream, bool upper = false)
|
||||
: data_(stream),
|
||||
upper_(upper) {}
|
||||
void operator()(const blank& /*i*/) { data_ << "$"; }
|
||||
@@ -1294,14 +1294,14 @@ namespace {
|
||||
void operator()(const enumeration_reference& i) {
|
||||
data_ << "." << i.value() << ".";
|
||||
}
|
||||
void operator()(const express::Base& i) {
|
||||
void operator()(const express::base& i) {
|
||||
if (i.declaration().as_entity() == nullptr || i.declaration().schema() == &Header_section_schema::get_schema()) {
|
||||
i.to_string(data_, upper_);
|
||||
} else {
|
||||
data_ << "#" << i.id();
|
||||
}
|
||||
}
|
||||
void operator()(const std::vector<express::Base>& i) {
|
||||
void operator()(const std::vector<express::base>& i) {
|
||||
data_ << "(";
|
||||
for (auto it = i.begin(); it != i.end(); ++it) {
|
||||
if (it != i.begin()) {
|
||||
@@ -1313,7 +1313,7 @@ namespace {
|
||||
}
|
||||
void operator()(const std::vector<std::vector<int64_t>>& i);
|
||||
void operator()(const std::vector<std::vector<double>>& i);
|
||||
void operator()(const std::vector<std::vector<express::Base>>& i) {
|
||||
void operator()(const std::vector<std::vector<express::base>>& i) {
|
||||
data_ << "(";
|
||||
for (auto outer_it = i.begin(); outer_it != i.end(); ++outer_it) {
|
||||
if (outer_it != i.begin()) {
|
||||
@@ -1335,7 +1335,7 @@ namespace {
|
||||
};
|
||||
|
||||
template <>
|
||||
void StringBuilderVisitor::serialize(const std::vector<std::string>& i) {
|
||||
void string_builder_visitor::serialize(const std::vector<std::string>& i) {
|
||||
data_ << "(";
|
||||
for (std::vector<std::string>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
||||
if (it != i.begin()) {
|
||||
@@ -1348,7 +1348,7 @@ namespace {
|
||||
}
|
||||
|
||||
template <>
|
||||
void StringBuilderVisitor::serialize(const std::vector<double>& i) {
|
||||
void string_builder_visitor::serialize(const std::vector<double>& i) {
|
||||
data_ << "(";
|
||||
for (std::vector<double>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
||||
if (it != i.begin()) {
|
||||
@@ -1360,7 +1360,7 @@ namespace {
|
||||
}
|
||||
|
||||
template <>
|
||||
void StringBuilderVisitor::serialize(const std::vector<boost::dynamic_bitset<>>& i) {
|
||||
void string_builder_visitor::serialize(const std::vector<boost::dynamic_bitset<>>& i) {
|
||||
data_ << "(";
|
||||
for (std::vector<boost::dynamic_bitset<>>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
||||
if (it != i.begin()) {
|
||||
@@ -1371,11 +1371,11 @@ namespace {
|
||||
data_ << ")";
|
||||
}
|
||||
|
||||
void StringBuilderVisitor::operator()(const std::vector<int64_t>& i) { serialize(i); }
|
||||
void StringBuilderVisitor::operator()(const std::vector<double>& i) { serialize(i); }
|
||||
void StringBuilderVisitor::operator()(const std::vector<std::string>& i) { serialize(i); }
|
||||
void StringBuilderVisitor::operator()(const std::vector<boost::dynamic_bitset<>>& i) { serialize(i); }
|
||||
void StringBuilderVisitor::operator()(const std::vector<std::vector<int64_t>>& i) {
|
||||
void string_builder_visitor::operator()(const std::vector<int64_t>& i) { serialize(i); }
|
||||
void string_builder_visitor::operator()(const std::vector<double>& i) { serialize(i); }
|
||||
void string_builder_visitor::operator()(const std::vector<std::string>& i) { serialize(i); }
|
||||
void string_builder_visitor::operator()(const std::vector<boost::dynamic_bitset<>>& i) { serialize(i); }
|
||||
void string_builder_visitor::operator()(const std::vector<std::vector<int64_t>>& i) {
|
||||
data_ << "(";
|
||||
for (std::vector<std::vector<int64_t>>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
||||
if (it != i.begin()) {
|
||||
@@ -1385,7 +1385,7 @@ namespace {
|
||||
}
|
||||
data_ << ")";
|
||||
}
|
||||
void StringBuilderVisitor::operator()(const std::vector<std::vector<double>>& i) {
|
||||
void string_builder_visitor::operator()(const std::vector<std::vector<double>>& i) {
|
||||
data_ << "(";
|
||||
for (std::vector<std::vector<double>>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
||||
if (it != i.begin()) {
|
||||
@@ -1406,7 +1406,7 @@ void instance_data::to_string(std::ostream& ss, bool upper) const {
|
||||
|
||||
ss << "(";
|
||||
|
||||
StringBuilderVisitor vis(ss, upper);
|
||||
string_builder_visitor vis(ss, upper);
|
||||
|
||||
// In almost all cases, storage is initialized with the size of the schema declaration,
|
||||
// apparently except in case of header entities and invalid in-line type declarations.
|
||||
@@ -1467,14 +1467,14 @@ ifcopenshell::argument_type get_argument_type(const ifcopenshell::declaration* d
|
||||
class unregister_inverse_visitor {
|
||||
private:
|
||||
file& file_;
|
||||
const express::Base data_;
|
||||
const express::base data_;
|
||||
|
||||
public:
|
||||
unregister_inverse_visitor(file& file, const express::Base& data)
|
||||
unregister_inverse_visitor(file& file, const express::base& data)
|
||||
: file_(file),
|
||||
data_(data) {}
|
||||
|
||||
void operator()(const express::Base& inst, int index) {
|
||||
void operator()(const express::base& inst, int index) {
|
||||
file_.unregister_inverse(data_.id(), data_.declaration().as_entity(), inst, index);
|
||||
}
|
||||
};
|
||||
@@ -1482,27 +1482,27 @@ class unregister_inverse_visitor {
|
||||
class register_inverse_visitor {
|
||||
private:
|
||||
file& file_;
|
||||
const express::Base data_;
|
||||
const express::base data_;
|
||||
|
||||
public:
|
||||
register_inverse_visitor(file& file, const express::Base& data)
|
||||
register_inverse_visitor(file& file, const express::base& data)
|
||||
: file_(file),
|
||||
data_(data) {}
|
||||
|
||||
void operator()(const express::Base& inst, int index) {
|
||||
void operator()(const express::base& inst, int index) {
|
||||
file_.register_inverse(data_.id(), data_.declaration().as_entity(), inst.id(), index);
|
||||
}
|
||||
};
|
||||
|
||||
class add_to_instance_list_visitor {
|
||||
private:
|
||||
std::vector<express::Base>* list_;
|
||||
std::vector<express::base>* list_;
|
||||
|
||||
public:
|
||||
add_to_instance_list_visitor(std::vector<express::Base>* list)
|
||||
add_to_instance_list_visitor(std::vector<express::base>* list)
|
||||
: list_(list) {}
|
||||
|
||||
void operator()(const express::Base& inst) {
|
||||
void operator()(const express::base& inst) {
|
||||
list_->push_back(inst);
|
||||
}
|
||||
};
|
||||
@@ -1512,26 +1512,26 @@ class apply_individual_instance_visitor {
|
||||
std::optional<attribute_value> attribute_;
|
||||
int attribute_index_;
|
||||
|
||||
const express::Base inst_;
|
||||
const express::base inst_;
|
||||
|
||||
|
||||
template <typename T>
|
||||
void apply_attribute_(T& t, const attribute_value& attr, int index) const {
|
||||
switch (attr.type()) {
|
||||
case ifcopenshell::Argument_ENTITY_INSTANCE: {
|
||||
express::Base inst = attr;
|
||||
express::base inst = attr;
|
||||
t(inst, index);
|
||||
break;
|
||||
}
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_ENTITY_INSTANCE: {
|
||||
std::vector<express::Base> entity_list_attribute = attr;
|
||||
std::vector<express::base> entity_list_attribute = attr;
|
||||
for (auto& inst : entity_list_attribute) {
|
||||
t(inst, index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: {
|
||||
std::vector<std::vector<express::Base>> nested_list_attr = attr;
|
||||
std::vector<std::vector<express::base>> nested_list_attr = attr;
|
||||
for (auto& vec : nested_list_attr) {
|
||||
for (auto& inst : vec) {
|
||||
t(inst, index);
|
||||
@@ -1549,7 +1549,7 @@ class apply_individual_instance_visitor {
|
||||
, attribute_index_(idx)
|
||||
{}
|
||||
|
||||
apply_individual_instance_visitor(const express::Base& data)
|
||||
apply_individual_instance_visitor(const express::base& data)
|
||||
: inst_(data)
|
||||
{}
|
||||
|
||||
@@ -1569,9 +1569,9 @@ class apply_individual_instance_visitor {
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<
|
||||
(!std::is_base_of_v<express::Base, T> || std::is_same_v<express::Base, T>),
|
||||
(!std::is_base_of_v<express::base, T> || std::is_same_v<express::base, T>),
|
||||
void>::type
|
||||
express::Base::set_attribute_value(size_t i, const T& t) {
|
||||
express::base::set_attribute_value(size_t i, const T& t) {
|
||||
if constexpr (std::is_same_v<std::decay_t<T>, double>) {
|
||||
if (!std::isfinite(t)) {
|
||||
throw ifcopenshell::exception("Only finite values are allowed");
|
||||
@@ -1597,7 +1597,7 @@ express::Base::set_attribute_value(size_t i, const T& t) {
|
||||
auto guid = (std::string) current_attribute;
|
||||
auto it = file()->internal_guid_map().find(guid);
|
||||
if (it != file()->internal_guid_map().end()) {
|
||||
const std::pair<const std::string, express::Base>& p = *it;
|
||||
const std::pair<const std::string, express::base>& p = *it;
|
||||
if (p.second == *this) {
|
||||
file()->internal_guid_map().erase(it);
|
||||
}
|
||||
@@ -1607,7 +1607,7 @@ express::Base::set_attribute_value(size_t i, const T& t) {
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<T, express::Base> || std::is_same_v<T, std::vector<express::Base>> || std::is_same_v<T, std::vector<std::vector<express::Base>>> || std::is_same_v<T, blank>) {
|
||||
if constexpr (std::is_same_v<T, express::base> || std::is_same_v<T, std::vector<express::base>> || std::is_same_v<T, std::vector<std::vector<express::base>>> || std::is_same_v<T, blank>) {
|
||||
// Deregister inverse indices in file
|
||||
unregister_inverse_visitor visitor(*file(), *this);
|
||||
apply_individual_instance_visitor(current_attribute, (int)i).apply(visitor);
|
||||
@@ -1620,7 +1620,7 @@ express::Base::set_attribute_value(size_t i, const T& t) {
|
||||
auto new_attribute = get_attribute_value(i);
|
||||
|
||||
// Register inverse indices in file
|
||||
if constexpr (std::is_same_v<T, express::Base> || std::is_same_v<T, std::vector<express::Base>> || std::is_same_v<T, std::vector<std::vector<express::Base>>>) {
|
||||
if constexpr (std::is_same_v<T, express::base> || std::is_same_v<T, std::vector<express::base>> || std::is_same_v<T, std::vector<std::vector<express::base>>>) {
|
||||
register_inverse_visitor visitor(*file(), *this);
|
||||
apply_individual_instance_visitor(new_attribute, (int)i).apply(visitor);
|
||||
}
|
||||
@@ -1642,9 +1642,9 @@ express::Base::set_attribute_value(size_t i, const T& t) {
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<
|
||||
(!std::is_base_of_v<express::Base, T> || std::is_same_v<express::Base, T>),
|
||||
(!std::is_base_of_v<express::base, T> || std::is_same_v<express::base, T>),
|
||||
void>::type
|
||||
express::Base::set_attribute_value(const std::string& s, const T& t)
|
||||
express::base::set_attribute_value(const std::string& s, const T& t)
|
||||
{
|
||||
set_attribute_value(declaration().as_entity()->attribute_index(s), t);
|
||||
}
|
||||
@@ -2285,7 +2285,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con
|
||||
}
|
||||
|
||||
auto current_id = std::get<0>(*inst);
|
||||
express::Base instance(std::get<2>(*inst));
|
||||
express::base instance(std::get<2>(*inst));
|
||||
|
||||
if (instance.declaration().is(*ifcroot_type_)) {
|
||||
try {
|
||||
@@ -2350,8 +2350,8 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con
|
||||
auto& storage = owner;
|
||||
auto attr_index = p.first.index_;
|
||||
|
||||
if (storage->template has_attribute_value<express::Base>(attr_index)) {
|
||||
express::Base inst = storage->get_attribute_value(attr_index);
|
||||
if (storage->template has_attribute_value<express::base>(attr_index)) {
|
||||
express::base inst = storage->get_attribute_value(attr_index);
|
||||
if (inst && !inst.declaration().as_entity()) {
|
||||
// Probably a case of IfcPropertySetDefinitionSet, divert storage of reference to the simply type instance
|
||||
#ifdef IFOPSH_SAFE_INSTANCE
|
||||
@@ -2364,16 +2364,16 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con
|
||||
}
|
||||
|
||||
if (storage->template has_attribute_value<blank>(attr_index)) {
|
||||
storage->set_attribute_value(attr_index, express::Base(it->second));
|
||||
storage->set_attribute_value(attr_index, express::base(it->second));
|
||||
} else {
|
||||
logger_.get().error("Duplicate definition for instance reference");
|
||||
}
|
||||
}
|
||||
} else if (auto inst = std::get_if<express::Base>(v)) {
|
||||
} else if (auto inst = std::get_if<express::base>(v)) {
|
||||
owner->set_attribute_value(p.first.index_, *inst);
|
||||
}
|
||||
} else if (auto* vv = std::get_if<std::vector<reference_or_simple_type>>(&p.second)) {
|
||||
std::vector<express::Base> instances;
|
||||
std::vector<express::base> instances;
|
||||
instances.reserve(vv->size());
|
||||
for (const auto& vi : *vv) {
|
||||
if (auto* name = std::get_if<instance_reference>(&vi)) {
|
||||
@@ -2384,9 +2384,9 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con
|
||||
if (it == byid_.end()) {
|
||||
logger_.get().error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
|
||||
} else {
|
||||
instances.push_back(express::Base(it->second));
|
||||
instances.push_back(express::base(it->second));
|
||||
}
|
||||
} else if (auto* inst = std::get_if<express::Base>(&vi)) {
|
||||
} else if (auto* inst = std::get_if<express::base>(&vi)) {
|
||||
instances.push_back(*inst);
|
||||
}
|
||||
}
|
||||
@@ -2394,8 +2394,8 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con
|
||||
auto& storage = owner;
|
||||
auto attr_index = p.first.index_;
|
||||
|
||||
if (storage->template has_attribute_value<express::Base>(attr_index)) {
|
||||
express::Base inst = storage->get_attribute_value(attr_index);
|
||||
if (storage->template has_attribute_value<express::base>(attr_index)) {
|
||||
express::base inst = storage->get_attribute_value(attr_index);
|
||||
if (inst && !inst.declaration().as_entity()) {
|
||||
// Probably a case of IfcPropertySetDefinitionSet, divert storage of reference to the simply type instance
|
||||
#ifdef IFOPSH_SAFE_INSTANCE
|
||||
@@ -2413,7 +2413,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con
|
||||
logger_.get().error("Duplicate definition for instance reference");
|
||||
}
|
||||
} else if (auto* vvv = std::get_if<std::vector<std::vector<reference_or_simple_type>>>(&p.second)) {
|
||||
std::vector<std::vector<express::Base>> instances;
|
||||
std::vector<std::vector<express::base>> instances;
|
||||
for (const auto& vi : *vvv) {
|
||||
auto& inner = instances.emplace_back();
|
||||
for (const auto& vii : vi) {
|
||||
@@ -2425,9 +2425,9 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con
|
||||
if (it == byid_.end()) {
|
||||
logger_.get().error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
|
||||
} else {
|
||||
inner.push_back(express::Base(it->second));
|
||||
inner.push_back(express::base(it->second));
|
||||
}
|
||||
} else if (auto* inst = std::get_if<express::Base>(&vii)) {
|
||||
} else if (auto* inst = std::get_if<express::base>(&vii)) {
|
||||
inner.push_back(*inst);
|
||||
}
|
||||
}
|
||||
@@ -2436,8 +2436,8 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con
|
||||
auto& storage = owner;
|
||||
auto attr_index = p.first.index_;
|
||||
|
||||
if (storage->template has_attribute_value<express::Base>(attr_index)) {
|
||||
express::Base inst = storage->get_attribute_value(attr_index);
|
||||
if (storage->template has_attribute_value<express::base>(attr_index)) {
|
||||
express::base inst = storage->get_attribute_value(attr_index);
|
||||
if (inst && !inst.declaration().as_entity()) {
|
||||
// Probably a case of IfcPropertySetDefinitionSet, divert storage of reference to the simply type instance
|
||||
#ifdef IFOPSH_SAFE_INSTANCE
|
||||
@@ -2480,15 +2480,15 @@ void file::recalculate_id_counter() {
|
||||
}
|
||||
|
||||
class traversal_recorder {
|
||||
std::vector<express::Base> list_;
|
||||
std::map<int, std::vector<express::Base>> instances_by_level_;
|
||||
std::vector<express::base> list_;
|
||||
std::map<int, std::vector<express::base>> instances_by_level_;
|
||||
int mode_;
|
||||
|
||||
public:
|
||||
traversal_recorder(int mode) : mode_(mode) {
|
||||
};
|
||||
|
||||
void push_back(int level, const express::Base& instance) {
|
||||
void push_back(int level, const express::base& instance) {
|
||||
if (mode_ == 0) {
|
||||
list_.push_back(instance);
|
||||
} else {
|
||||
@@ -2497,11 +2497,11 @@ class traversal_recorder {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<express::Base> get_list() const {
|
||||
std::vector<express::base> get_list() const {
|
||||
if (mode_ == 0) {
|
||||
return list_;
|
||||
}
|
||||
std::vector<express::Base> l;
|
||||
std::vector<express::base> l;
|
||||
for (const auto& p : instances_by_level_) {
|
||||
l.insert(l.end(), p.second.begin(), p.second.end());
|
||||
}
|
||||
@@ -2511,22 +2511,22 @@ class traversal_recorder {
|
||||
|
||||
class traversal_visitor {
|
||||
private:
|
||||
std::set<express::Base>& visited_;
|
||||
std::set<express::base>& visited_;
|
||||
traversal_recorder& list_;
|
||||
int level_;
|
||||
int max_level_;
|
||||
|
||||
public:
|
||||
traversal_visitor(std::set<express::Base>& visited, traversal_recorder& list, int level, int max_level)
|
||||
traversal_visitor(std::set<express::base>& visited, traversal_recorder& list, int level, int max_level)
|
||||
: visited_(visited),
|
||||
list_(list),
|
||||
level_(level),
|
||||
max_level_(max_level) {}
|
||||
|
||||
void operator()(const express::Base& inst, int index);
|
||||
void operator()(const express::base& inst, int index);
|
||||
};
|
||||
|
||||
void traverse_(const express::Base& instance, std::set<express::Base>& visited, traversal_recorder& list, int level, int max_level) {
|
||||
void traverse_(const express::base& instance, std::set<express::base>& visited, traversal_recorder& list, int level, int max_level) {
|
||||
if (visited.find(instance) != visited.end()) {
|
||||
return;
|
||||
}
|
||||
@@ -2541,12 +2541,12 @@ void traverse_(const express::Base& instance, std::set<express::Base>& visited,
|
||||
apply_individual_instance_visitor(instance).apply(visit);
|
||||
}
|
||||
|
||||
void traversal_visitor::operator()(const express::Base& inst, int /* index */) {
|
||||
void traversal_visitor::operator()(const express::base& inst, int /* index */) {
|
||||
traverse_(inst, visited_, list_, level_, max_level_);
|
||||
}
|
||||
|
||||
std::vector<express::Base> ifcopenshell::traverse(const express::Base& instance, int max_level) {
|
||||
std::set<express::Base> visited;
|
||||
std::vector<express::base> ifcopenshell::traverse(const express::base& instance, int max_level) {
|
||||
std::set<express::base> visited;
|
||||
traversal_recorder recorder(0);
|
||||
traverse_(instance, visited, recorder, 0, max_level);
|
||||
return recorder.get_list();
|
||||
@@ -2554,24 +2554,24 @@ std::vector<express::Base> ifcopenshell::traverse(const express::Base& instance,
|
||||
|
||||
// I'm cheating this isn't breadth-first, but rather we record visited instances
|
||||
// keeping track of their rank and return a list ordered by rank. Is this equivalent?
|
||||
std::vector<express::Base> ifcopenshell::traverse_breadth_first(const express::Base& instance, int max_level) {
|
||||
std::set<express::Base> visited;
|
||||
std::vector<express::base> ifcopenshell::traverse_breadth_first(const express::base& instance, int max_level) {
|
||||
std::set<express::base> visited;
|
||||
traversal_recorder recorder(1);
|
||||
traverse_(instance, visited, recorder, 0, max_level);
|
||||
return recorder.get_list();
|
||||
}
|
||||
|
||||
/// @note: for backwards compatibility
|
||||
std::vector<express::Base> file::traverse(const express::Base& instance, int max_level) {
|
||||
std::vector<express::base> file::traverse(const express::base& instance, int max_level) {
|
||||
return ifcopenshell::traverse(instance, max_level);
|
||||
}
|
||||
|
||||
/// @note: for backwards compatibility
|
||||
std::vector<express::Base> file::traverse_breadth_first(const express::Base& instance, int max_level) {
|
||||
std::vector<express::base> file::traverse_breadth_first(const express::base& instance, int max_level) {
|
||||
return ifcopenshell::traverse_breadth_first(instance, max_level);
|
||||
}
|
||||
|
||||
express::Base file::add_entity(const express::Base& entity, int id) {
|
||||
express::base file::add_entity(const express::base& entity, int id) {
|
||||
if (entity.file() == this) {
|
||||
return entity;
|
||||
}
|
||||
@@ -2613,13 +2613,13 @@ express::Base file::add_entity(const express::Base& entity, int id) {
|
||||
auto num_attributes = (decl->as_entity() ? decl->as_entity()->attribute_count() : 1);
|
||||
for (size_t i = 0; i < num_attributes; ++i) {
|
||||
entity.get_attribute_value(i).apply_visitor([this, i, decl, &new_entity](const auto& v) {
|
||||
using U = std::decay_t<decltype(v)>;
|
||||
using u = std::decay_t<decltype(v)>;
|
||||
// only need to copy non-instance attribute values, others are assigned below after mapping
|
||||
if constexpr (std::is_same_v<U, express::Base>) {
|
||||
} else if constexpr (std::is_same_v<U, std::vector<express::Base>>) {
|
||||
} else if constexpr (std::is_same_v<U, std::vector<std::vector<express::Base>>>) {
|
||||
} else if constexpr (std::is_same_v<U, empty_aggregate_t>) {
|
||||
} else if constexpr (std::is_same_v<U, empty_aggregate_of_aggregate_t>) {
|
||||
if constexpr (std::is_same_v<u, express::base>) {
|
||||
} else if constexpr (std::is_same_v<u, std::vector<express::base>>) {
|
||||
} else if constexpr (std::is_same_v<u, std::vector<std::vector<express::base>>>) {
|
||||
} else if constexpr (std::is_same_v<u, empty_aggregate_t>) {
|
||||
} else if constexpr (std::is_same_v<u, empty_aggregate_of_aggregate_t>) {
|
||||
} else {
|
||||
new_entity.set_attribute_value(i, v);
|
||||
}
|
||||
@@ -2648,15 +2648,15 @@ express::Base file::add_entity(const express::Base& entity, int id) {
|
||||
}
|
||||
|
||||
if (attr_type == ifcopenshell::Argument_ENTITY_INSTANCE) {
|
||||
entity_entity_map_t::const_iterator eit = entity_file_map_.find(((express::Base)(attr)).identity());
|
||||
entity_entity_map_t::const_iterator eit = entity_file_map_.find(((express::base)(attr)).identity());
|
||||
if (eit == entity_file_map_.end()) {
|
||||
throw ifcopenshell::exception("Unable to map instance to file");
|
||||
}
|
||||
// @todo previously, we directly use storage::set() not to trigger inverse recalculation which happens at the end
|
||||
new_entity.set_attribute_value(i, eit->second);
|
||||
} else if (attr_type == ifcopenshell::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
|
||||
std::vector<express::Base> instances = attr;
|
||||
std::vector<express::Base> new_instances;
|
||||
std::vector<express::base> instances = attr;
|
||||
std::vector<express::base> new_instances;
|
||||
for (auto& i : instances) {
|
||||
entity_entity_map_t::const_iterator eit = entity_file_map_.find(i.identity());
|
||||
if (eit == entity_file_map_.end()) {
|
||||
@@ -2666,8 +2666,8 @@ express::Base file::add_entity(const express::Base& entity, int id) {
|
||||
}
|
||||
new_entity.set_attribute_value(i, new_instances);
|
||||
} else if (attr_type == ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE) {
|
||||
std::vector<std::vector<express::Base>> instances = attr;
|
||||
std::vector<std::vector<express::Base>> new_instances;
|
||||
std::vector<std::vector<express::base>> instances = attr;
|
||||
std::vector<std::vector<express::base>> new_instances;
|
||||
|
||||
for (auto& v : instances) {
|
||||
new_instances.emplace_back();
|
||||
@@ -2683,8 +2683,8 @@ express::Base file::add_entity(const express::Base& entity, int id) {
|
||||
new_entity.set_attribute_value(i, new_instances);
|
||||
} else if ((potentially_length_measure_decl != nullptr) && potentially_length_measure_decl->is(*schema()->declaration_by_name("IfcLengthMeasure"))) {
|
||||
if (boost::math::isnan(conversion_factor)) {
|
||||
std::pair<express::Base, double> this_file_unit = {express::Base{}, 1.0};
|
||||
std::pair<express::Base, double> other_file_unit = {express::Base{}, 1.0};
|
||||
std::pair<express::base, double> this_file_unit = {express::base{}, 1.0};
|
||||
std::pair<express::base, double> other_file_unit = {express::base{}, 1.0};
|
||||
try {
|
||||
this_file_unit = get_unit("LENGTHUNIT");
|
||||
other_file_unit = other_file->get_unit("LENGTHUNIT");
|
||||
@@ -2743,7 +2743,7 @@ express::Base file::add_entity(const express::Base& entity, int id) {
|
||||
return new_entity;
|
||||
}
|
||||
|
||||
void file::remove_entity(const express::Base& entity) {
|
||||
void file::remove_entity(const express::base& entity) {
|
||||
auto id = entity.id();
|
||||
|
||||
auto file_entity = instance_by_id(id);
|
||||
@@ -2752,7 +2752,7 @@ void file::remove_entity(const express::Base& entity) {
|
||||
// This invalidates the iterator. A workaround is to reverse the loop:
|
||||
// boost::shared_ptr<aggregate_of_instance> entities = ...;
|
||||
// for (auto it = entities->end() - 1; it >= entities->begin(); --it) {
|
||||
// express::Base *const inst = *it;
|
||||
// express::base *const inst = *it;
|
||||
// model->remove_entity(inst);
|
||||
// }
|
||||
|
||||
@@ -2775,7 +2775,7 @@ void file::remove_entity(const express::Base& entity) {
|
||||
}
|
||||
}
|
||||
|
||||
void file::process_deletion_(const express::Base& entity) {
|
||||
void file::process_deletion_(const express::base& entity) {
|
||||
|
||||
auto references = instances_by_reference(entity.id());
|
||||
|
||||
@@ -2800,13 +2800,13 @@ void file::process_deletion_(const express::Base& entity) {
|
||||
ifcopenshell::argument_type attr_type = attr.type();
|
||||
switch (attr_type) {
|
||||
case ifcopenshell::Argument_ENTITY_INSTANCE: {
|
||||
express::Base instance_attribute = attr;
|
||||
express::base instance_attribute = attr;
|
||||
if (instance_attribute == entity) {
|
||||
related_instance.set_attribute_value(i, blank{});
|
||||
}
|
||||
} break;
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_ENTITY_INSTANCE: {
|
||||
std::vector<express::Base> instance_list = attr;
|
||||
std::vector<express::base> instance_list = attr;
|
||||
auto it = std::remove(instance_list.begin(), instance_list.end(), entity);
|
||||
if (it != instance_list.end()) {
|
||||
instance_list.erase(it, instance_list.end());
|
||||
@@ -2819,7 +2819,7 @@ void file::process_deletion_(const express::Base& entity) {
|
||||
}
|
||||
} break;
|
||||
case ifcopenshell::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: {
|
||||
std::vector<std::vector<express::Base>> instance_list_list = attr;
|
||||
std::vector<std::vector<express::base>> instance_list_list = attr;
|
||||
bool updated = false;
|
||||
for (auto& li : instance_list_list) {
|
||||
auto it = std::remove(li.begin(), li.end(), entity);
|
||||
@@ -2864,7 +2864,7 @@ void file::process_deletion_(const express::Base& entity) {
|
||||
}
|
||||
}
|
||||
|
||||
void ifcopenshell::impl::in_memory_file_storage::process_deletion_inverse(const express::Base& entity) {
|
||||
void ifcopenshell::impl::in_memory_file_storage::process_deletion_inverse(const express::base& entity) {
|
||||
auto id = entity.id();
|
||||
|
||||
// Delete inverses into entity
|
||||
@@ -2890,8 +2890,8 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<express::Base> file::instances_by_type(const ifcopenshell::declaration* t) {
|
||||
std::vector<express::Base> insts;
|
||||
std::vector<express::base> file::instances_by_type(const ifcopenshell::declaration* t) {
|
||||
std::vector<express::base> insts;
|
||||
if (t->as_entity() != nullptr) {
|
||||
visit_subtypes(t->as_entity(), [this, &insts](const ifcopenshell::entity* ent) {
|
||||
auto subtype_insts = instances_by_type_excl_subtypes(ent);
|
||||
@@ -2901,13 +2901,13 @@ std::vector<express::Base> file::instances_by_type(const ifcopenshell::declarati
|
||||
return insts;
|
||||
}
|
||||
|
||||
std::vector<express::Base> file::instances_by_type_excl_subtypes(const ifcopenshell::declaration* t) {
|
||||
std::vector<express::base> file::instances_by_type_excl_subtypes(const ifcopenshell::declaration* t) {
|
||||
return std::visit([t](auto& x) {
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(x)>, impl::in_memory_file_storage>) {
|
||||
auto it = x.bytype_excl_.find(t);
|
||||
return (it == x.bytype_excl_.end()) ? std::vector<express::Base>{} : it->second;
|
||||
return (it == x.bytype_excl_.end()) ? std::vector<express::base>{} : it->second;
|
||||
} else if constexpr (std::is_same_v<std::decay_t<decltype(x)>, impl::rocks_db_file_storage>) {
|
||||
std::vector<express::Base> ret;
|
||||
std::vector<express::base> ret;
|
||||
auto it = x.bytype_.find(t->index_in_schema());
|
||||
if (it != x.bytype_.end()) {
|
||||
const auto& s = it->second;
|
||||
@@ -2921,22 +2921,22 @@ std::vector<express::Base> file::instances_by_type_excl_subtypes(const ifcopensh
|
||||
return ret;
|
||||
} else {
|
||||
throw std::runtime_error("Storage not initialized");
|
||||
std::vector<express::Base> ret;
|
||||
std::vector<express::base> ret;
|
||||
return ret;
|
||||
}
|
||||
}, storage_);
|
||||
}
|
||||
|
||||
std::vector<express::Base> file::instances_by_type(const std::string& t) {
|
||||
std::vector<express::base> file::instances_by_type(const std::string& t) {
|
||||
return instances_by_type(schema()->declaration_by_name(t));
|
||||
}
|
||||
|
||||
std::vector<express::Base> file::instances_by_type_excl_subtypes(const std::string& t) {
|
||||
std::vector<express::base> file::instances_by_type_excl_subtypes(const std::string& t) {
|
||||
return instances_by_type_excl_subtypes(schema()->declaration_by_name(t));
|
||||
}
|
||||
|
||||
std::vector<express::Base> file::instances_by_reference(int t) {
|
||||
std::vector<express::Base> ret;
|
||||
std::vector<express::base> file::instances_by_reference(int t) {
|
||||
std::vector<express::base> ret;
|
||||
std::visit([this, t, &ret](auto& x) {
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(x)>, impl::in_memory_file_storage>) {
|
||||
auto range = x.byref_excl_.equal_range((uint32_t)t);
|
||||
@@ -2968,18 +2968,18 @@ std::vector<express::Base> file::instances_by_reference(int t) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
express::Base file::instance_by_id(int id) {
|
||||
express::base file::instance_by_id(int id) {
|
||||
return std::visit([id](auto& x) {
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(x)>, std::monostate>) {
|
||||
throw std::runtime_error("Storage not initialized");
|
||||
return express::Base{};
|
||||
return express::base{};
|
||||
} else {
|
||||
return x.instance_by_id(id);
|
||||
}
|
||||
}, storage_);
|
||||
}
|
||||
|
||||
void ifcopenshell::file::add_type_ref(const express::Base& new_entity)
|
||||
void ifcopenshell::file::add_type_ref(const express::base& new_entity)
|
||||
{
|
||||
std::visit([new_entity](auto& x) {
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(x)>, std::monostate>) {
|
||||
@@ -2991,7 +2991,7 @@ void ifcopenshell::file::add_type_ref(const express::Base& new_entity)
|
||||
}
|
||||
|
||||
|
||||
void ifcopenshell::file::remove_type_ref(const express::Base& new_entity) {
|
||||
void ifcopenshell::file::remove_type_ref(const express::base& new_entity) {
|
||||
std::visit([new_entity](auto& x) {
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(x)>, std::monostate>) {
|
||||
throw std::runtime_error("Storage not initialized");
|
||||
@@ -3001,7 +3001,7 @@ void ifcopenshell::file::remove_type_ref(const express::Base& new_entity) {
|
||||
}, storage_);
|
||||
}
|
||||
|
||||
void ifcopenshell::file::process_deletion_inverse(const express::Base& inst) {
|
||||
void ifcopenshell::file::process_deletion_inverse(const express::base& inst) {
|
||||
std::visit([inst](auto& x) {
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(x)>, std::monostate>) {
|
||||
throw std::runtime_error("Storage not initialized");
|
||||
@@ -3011,7 +3011,7 @@ void ifcopenshell::file::process_deletion_inverse(const express::Base& inst) {
|
||||
}, storage_);
|
||||
}
|
||||
|
||||
express::Base file::instance_by_guid(const std::string& guid) {
|
||||
express::base file::instance_by_guid(const std::string& guid) {
|
||||
auto it = byguid_.find(guid);
|
||||
if (it == byguid_.end()) {
|
||||
throw exception("Instance with GlobalId '" + guid + "' not found");
|
||||
@@ -3046,7 +3046,7 @@ file::type_iterator file::types_end() const {
|
||||
std::ostream& operator<<(std::ostream& out, const ifcopenshell::file& file) {
|
||||
file.header().write(out);
|
||||
|
||||
typedef std::vector<express::Base> vector_t;
|
||||
typedef std::vector<express::base> vector_t;
|
||||
vector_t sorted;
|
||||
std::transform(file.begin(), file.end(), std::back_inserter(sorted), [&file](const auto& x) { return x.second; });
|
||||
std::sort(sorted.begin(), sorted.end(), [](const auto& a, const auto& b) { return a.id() < b.id(); });
|
||||
@@ -3149,14 +3149,14 @@ std::vector<int> file::get_inverse_indices_by_id(int instance_id) {
|
||||
return return_value;
|
||||
}
|
||||
|
||||
std::vector<express::Entity> file::get_inverse(int instance_id, const ifcopenshell::declaration* type, int attribute_index) {
|
||||
std::vector<express::Entity> return_value;
|
||||
std::vector<express::entity> file::get_inverse(int instance_id, const ifcopenshell::declaration* type, int attribute_index) {
|
||||
std::vector<express::entity> return_value;
|
||||
|
||||
if (type == nullptr && attribute_index == -1) {
|
||||
// @todo this is silly.
|
||||
auto r = instances_by_reference(instance_id);
|
||||
for (auto& i : r) {
|
||||
return_value.push_back(i.as<express::Entity>());
|
||||
return_value.push_back(i.as<express::entity>());
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
@@ -3172,7 +3172,7 @@ std::vector<express::Entity> file::get_inverse(int instance_id, const ifcopenshe
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
if (it->source_entity < source_types.size() && source_types[it->source_entity] &&
|
||||
(attribute_index == -1 || it->attribute_index == attribute_index)) {
|
||||
return_value.push_back(instance_by_id(it->source_id).template as<express::Entity>());
|
||||
return_value.push_back(instance_by_id(it->source_id).template as<express::entity>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3188,7 +3188,7 @@ std::vector<express::Entity> file::get_inverse(int instance_id, const ifcopenshe
|
||||
std::vector<uint32_t> vals(it->value().size() / sizeof(uint32_t));
|
||||
memcpy(vals.data(), it->value().data(), it->value().size());
|
||||
for (auto& v : vals) {
|
||||
return_value.push_back(instance_by_id(v).template as<express::Entity>());
|
||||
return_value.push_back(instance_by_id(v).template as<express::entity>());
|
||||
}
|
||||
it->Next();
|
||||
}
|
||||
@@ -3196,7 +3196,7 @@ std::vector<express::Entity> file::get_inverse(int instance_id, const ifcopenshe
|
||||
auto it = x.byref_excl_.find({instance_id, ent->index_in_schema(), attribute_index});
|
||||
if (it != x.byref_excl_.end()) {
|
||||
for (auto& i : it->second) {
|
||||
return_value.push_back(instance_by_id(i).template as<express::Entity>());
|
||||
return_value.push_back(instance_by_id(i).template as<express::entity>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3251,8 +3251,8 @@ void file::set_default_header_values() {
|
||||
header().file_schema().setschema_identifiers(schema_identifiers);
|
||||
}
|
||||
|
||||
std::pair<express::Base, double> file::get_unit(const std::string& unit_type) {
|
||||
std::pair<express::Base, double> return_value(express::Base{}, 1.);
|
||||
std::pair<express::base, double> file::get_unit(const std::string& unit_type) {
|
||||
std::pair<express::base, double> return_value(express::base{}, 1.);
|
||||
|
||||
auto projects = instances_by_type(schema()->declaration_by_name("IfcProject"));
|
||||
if (projects.empty()) {
|
||||
@@ -3265,23 +3265,23 @@ std::pair<express::Base, double> file::get_unit(const std::string& unit_type) {
|
||||
if (!projects.empty()) {
|
||||
auto project = *projects.begin();
|
||||
|
||||
express::Base unit_assignment = project.as<express::Entity>().get("UnitsInContext");
|
||||
express::base unit_assignment = project.as<express::entity>().get("UnitsInContext");
|
||||
|
||||
std::vector<express::Base> units = unit_assignment.as<express::Entity>().get("Units");
|
||||
std::vector<express::base> units = unit_assignment.as<express::entity>().get("Units");
|
||||
|
||||
for (auto& unit : units) {
|
||||
if (unit.declaration().is("IfcNamedUnit")) {
|
||||
const std::string file_unit_type = unit.as<express::Entity>().get("UnitType");
|
||||
const std::string file_unit_type = unit.as<express::entity>().get("UnitType");
|
||||
|
||||
if (file_unit_type != unit_type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
express::Base siunit;
|
||||
express::base siunit;
|
||||
if (unit.declaration().is("IfcConversionBasedUnit")) {
|
||||
express::Base mu = unit.as<express::Entity>().get("ConversionFactor");
|
||||
express::Base vlc = mu.as<express::Entity>().get("ValueComponent");
|
||||
express::Base unc = mu.as<express::Entity>().get("UnitComponent");
|
||||
express::base mu = unit.as<express::entity>().get("ConversionFactor");
|
||||
express::base vlc = mu.as<express::entity>().get("ValueComponent");
|
||||
express::base unc = mu.as<express::entity>().get("UnitComponent");
|
||||
return_value.second *= static_cast<double>(vlc.get_attribute_value(0));
|
||||
return_value.first = unit;
|
||||
|
||||
@@ -3294,7 +3294,7 @@ std::pair<express::Base, double> file::get_unit(const std::string& unit_type) {
|
||||
}
|
||||
|
||||
if (siunit) {
|
||||
attribute_value prefix = siunit.as<express::Entity>().get("Prefix");
|
||||
attribute_value prefix = siunit.as<express::entity>().get("Prefix");
|
||||
if (!prefix.isNull()) {
|
||||
return_value.second *= si_prefix_to_value(prefix);
|
||||
}
|
||||
@@ -3306,8 +3306,8 @@ std::pair<express::Base, double> file::get_unit(const std::string& unit_type) {
|
||||
return return_value;
|
||||
}
|
||||
|
||||
void ifcopenshell::file::build_inverses_(const express::Base& inst) {
|
||||
std::function<void(const express::Base&, int)> fn = [this, inst](const express::Base& attr, int idx) {
|
||||
void ifcopenshell::file::build_inverses_(const express::base& inst) {
|
||||
std::function<void(const express::base&, int)> fn = [this, inst](const express::base& attr, int idx) {
|
||||
if (attr.declaration().as_entity() != nullptr) {
|
||||
unsigned entity_attribute_id = attr.id();
|
||||
const auto* decl = inst.declaration().as_entity();
|
||||
@@ -3350,7 +3350,7 @@ void ifcopenshell::file::reset_identity_cache() {
|
||||
|
||||
void ifcopenshell::file::build_inverses() {
|
||||
for (const auto& pair : *this) {
|
||||
build_inverses_(express::Base(pair.second));
|
||||
build_inverses_(express::base(pair.second));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3365,7 +3365,7 @@ void ifcopenshell::file::register_inverse(unsigned id_from, const ifcopenshell::
|
||||
}, storage_);
|
||||
}
|
||||
|
||||
void ifcopenshell::file::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::Base& inst, int attribute_index)
|
||||
void ifcopenshell::file::unregister_inverse(unsigned id_from, const ifcopenshell::entity* from_entity, const express::base& inst, int attribute_index)
|
||||
{
|
||||
std::visit([id_from, from_entity, inst, attribute_index](auto& x) {
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(x)>, std::monostate>) {
|
||||
@@ -3380,15 +3380,15 @@ std::atomic_uint32_t instance_data::counter_(0);
|
||||
|
||||
// bool ifcopenshell::file::guid_map_ = true;
|
||||
|
||||
void express::Base::unset_attribute_value(size_t index) {
|
||||
void express::base::unset_attribute_value(size_t index) {
|
||||
data()->set_attribute_value(index, blank{});
|
||||
}
|
||||
|
||||
attribute_value express::Base::get_attribute_value(size_t index) const {
|
||||
attribute_value express::base::get_attribute_value(size_t index) const {
|
||||
return data()->get_attribute_value(index);
|
||||
}
|
||||
|
||||
void express::Base::to_string(std::ostream& out, bool upper) const
|
||||
void express::base::to_string(std::ostream& out, bool upper) const
|
||||
{
|
||||
const auto *ent = declaration().as_entity();
|
||||
if (ent != nullptr && declaration().schema() != &Header_section_schema::get_schema()) {
|
||||
@@ -3402,7 +3402,7 @@ void express::Base::to_string(std::ostream& out, bool upper) const
|
||||
data()->to_string(out, upper);
|
||||
}
|
||||
|
||||
ifcopenshell::file* express::Base::file() const {
|
||||
ifcopenshell::file* express::base::file() const {
|
||||
return data()->file();
|
||||
}
|
||||
|
||||
@@ -3450,7 +3450,7 @@ bool ifcopenshell::impl::rocks_db_file_storage::read_schema(const ifcopenshell::
|
||||
}
|
||||
|
||||
/*
|
||||
express::Base::IfcBaseClass(instance_data&& data)
|
||||
express::base::IfcBaseClass(instance_data&& data)
|
||||
: identity_(counter_++)
|
||||
, id_(0)
|
||||
, file_(nullptr)
|
||||
@@ -3465,48 +3465,48 @@ express::Base::IfcBaseClass(instance_data&& data)
|
||||
}
|
||||
*/
|
||||
|
||||
void express::Base::set_attribute_value(size_t i, const express::Base& p) {
|
||||
set_attribute_value<express::Base>(i, p);
|
||||
void express::base::set_attribute_value(size_t i, const express::base& p) {
|
||||
set_attribute_value<express::base>(i, p);
|
||||
}
|
||||
void express::Base::set_attribute_value(const std::string& name, const express::Base& p) {
|
||||
set_attribute_value<express::Base>(name, p);
|
||||
void express::base::set_attribute_value(const std::string& name, const express::base& p) {
|
||||
set_attribute_value<express::base>(name, p);
|
||||
}
|
||||
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<blank>(size_t index, const blank& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<derived>(size_t index, const derived& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<int64_t>(size_t index, const int64_t& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<bool>(size_t index, const bool& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<boost::logic::tribool>(size_t index, const boost::logic::tribool& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<double>(size_t index, const double& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::string>(size_t index, const std::string& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<boost::dynamic_bitset<>>(size_t index, const boost::dynamic_bitset<>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<enumeration_reference>(size_t index, const enumeration_reference& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<int64_t>>(size_t index, const std::vector<int64_t>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<double>>(size_t index, const std::vector<double>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<std::string>>(size_t index, const std::vector<std::string>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<boost::dynamic_bitset<>>>(size_t index, const std::vector<boost::dynamic_bitset<>>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<express::Base>>(size_t index, const std::vector<express::Base>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<std::vector<int64_t>>>(size_t index, const std::vector<std::vector<int64_t>>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<std::vector<double>>>(size_t index, const std::vector<std::vector<double>>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<std::vector<express::Base>>>(size_t index, const std::vector<std::vector<express::Base>>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<blank>(size_t index, const blank& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<derived>(size_t index, const derived& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<int64_t>(size_t index, const int64_t& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<bool>(size_t index, const bool& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<boost::logic::tribool>(size_t index, const boost::logic::tribool& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<double>(size_t index, const double& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::string>(size_t index, const std::string& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<boost::dynamic_bitset<>>(size_t index, const boost::dynamic_bitset<>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<enumeration_reference>(size_t index, const enumeration_reference& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<int64_t>>(size_t index, const std::vector<int64_t>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<double>>(size_t index, const std::vector<double>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<std::string>>(size_t index, const std::vector<std::string>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<boost::dynamic_bitset<>>>(size_t index, const std::vector<boost::dynamic_bitset<>>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<express::base>>(size_t index, const std::vector<express::base>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<std::vector<int64_t>>>(size_t index, const std::vector<std::vector<int64_t>>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<std::vector<double>>>(size_t index, const std::vector<std::vector<double>>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<std::vector<express::base>>>(size_t index, const std::vector<std::vector<express::base>>& value);
|
||||
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<blank>(const std::string& name, const blank& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<derived>(const std::string& name, const derived& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<int64_t>(const std::string& name, const int64_t& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<bool>(const std::string& name, const bool& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<boost::logic::tribool>(const std::string& name, const boost::logic::tribool& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<double>(const std::string& name, const double& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::string>(const std::string& name, const std::string& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<boost::dynamic_bitset<>>(const std::string& name, const boost::dynamic_bitset<>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<enumeration_reference>(const std::string& name, const enumeration_reference& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<int64_t>>(const std::string& name, const std::vector<int64_t>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<double>>(const std::string& name, const std::vector<double>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<std::string>>(const std::string& name, const std::vector<std::string>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<boost::dynamic_bitset<>>>(const std::string& name, const std::vector<boost::dynamic_bitset<>>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<express::Base>>(const std::string& name, const std::vector<express::Base>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<std::vector<int64_t>>>(const std::string& name, const std::vector<std::vector<int64_t>>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<std::vector<double>>>(const std::string& name, const std::vector<std::vector<double>>& value);
|
||||
template void IFC_PARSE_API express::Base::set_attribute_value<std::vector<std::vector<express::Base>>>(const std::string& name, const std::vector<std::vector<express::Base>>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<blank>(const std::string& name, const blank& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<derived>(const std::string& name, const derived& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<int64_t>(const std::string& name, const int64_t& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<bool>(const std::string& name, const bool& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<boost::logic::tribool>(const std::string& name, const boost::logic::tribool& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<double>(const std::string& name, const double& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::string>(const std::string& name, const std::string& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<boost::dynamic_bitset<>>(const std::string& name, const boost::dynamic_bitset<>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<enumeration_reference>(const std::string& name, const enumeration_reference& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<int64_t>>(const std::string& name, const std::vector<int64_t>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<double>>(const std::string& name, const std::vector<double>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<std::string>>(const std::string& name, const std::vector<std::string>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<boost::dynamic_bitset<>>>(const std::string& name, const std::vector<boost::dynamic_bitset<>>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<express::base>>(const std::string& name, const std::vector<express::base>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<std::vector<int64_t>>>(const std::string& name, const std::vector<std::vector<int64_t>>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<std::vector<double>>>(const std::string& name, const std::vector<std::vector<double>>& value);
|
||||
template void IFC_PARSE_API express::base::set_attribute_value<std::vector<std::vector<express::base>>>(const std::string& name, const std::vector<std::vector<express::base>>& value);
|
||||
|
||||
namespace express {
|
||||
template <typename T>
|
||||
@@ -3527,36 +3527,36 @@ T Entity::get_value(const std::string& name, const T& default_value) const {
|
||||
}
|
||||
} // namespace express
|
||||
|
||||
template int64_t IFC_PARSE_API express::Entity::get_value<int64_t>(const std::string&) const;
|
||||
template bool IFC_PARSE_API express::Entity::get_value<bool>(const std::string&) const;
|
||||
template boost::logic::tribool IFC_PARSE_API express::Entity::get_value<boost::logic::tribool>(const std::string&) const;
|
||||
template double IFC_PARSE_API express::Entity::get_value<double>(const std::string&) const;
|
||||
template std::string IFC_PARSE_API express::Entity::get_value<std::string>(const std::string&) const;
|
||||
template express::Base IFC_PARSE_API express::Entity::get_value<express::Base>(const std::string&) const;
|
||||
template boost::dynamic_bitset<> IFC_PARSE_API express::Entity::get_value<boost::dynamic_bitset<>>(const std::string&) const;
|
||||
template enumeration_reference IFC_PARSE_API express::Entity::get_value<enumeration_reference>(const std::string&) const;
|
||||
template std::vector<int64_t> IFC_PARSE_API express::Entity::get_value<std::vector<int64_t>>(const std::string&) const;
|
||||
template std::vector<double> IFC_PARSE_API express::Entity::get_value<std::vector<double>>(const std::string&) const;
|
||||
template std::vector<std::string> IFC_PARSE_API express::Entity::get_value<std::vector<std::string>>(const std::string&) const;
|
||||
template std::vector<boost::dynamic_bitset<>> IFC_PARSE_API express::Entity::get_value<std::vector<boost::dynamic_bitset<>>>(const std::string&) const;
|
||||
template std::vector<express::Base> IFC_PARSE_API express::Entity::get_value<std::vector<express::Base>>(const std::string&) const;
|
||||
template std::vector<std::vector<int64_t>> IFC_PARSE_API express::Entity::get_value<std::vector<std::vector<int64_t>>>(const std::string&) const;
|
||||
template std::vector<std::vector<double>> IFC_PARSE_API express::Entity::get_value<std::vector<std::vector<double>>>(const std::string&) const;
|
||||
template std::vector<std::vector<express::Base>> IFC_PARSE_API express::Entity::get_value<std::vector<std::vector<express::Base>>>(const std::string&) const;
|
||||
template int64_t IFC_PARSE_API express::entity::get_value<int64_t>(const std::string&) const;
|
||||
template bool IFC_PARSE_API express::entity::get_value<bool>(const std::string&) const;
|
||||
template boost::logic::tribool IFC_PARSE_API express::entity::get_value<boost::logic::tribool>(const std::string&) const;
|
||||
template double IFC_PARSE_API express::entity::get_value<double>(const std::string&) const;
|
||||
template std::string IFC_PARSE_API express::entity::get_value<std::string>(const std::string&) const;
|
||||
template express::base IFC_PARSE_API express::entity::get_value<express::base>(const std::string&) const;
|
||||
template boost::dynamic_bitset<> IFC_PARSE_API express::entity::get_value<boost::dynamic_bitset<>>(const std::string&) const;
|
||||
template enumeration_reference IFC_PARSE_API express::entity::get_value<enumeration_reference>(const std::string&) const;
|
||||
template std::vector<int64_t> IFC_PARSE_API express::entity::get_value<std::vector<int64_t>>(const std::string&) const;
|
||||
template std::vector<double> IFC_PARSE_API express::entity::get_value<std::vector<double>>(const std::string&) const;
|
||||
template std::vector<std::string> IFC_PARSE_API express::entity::get_value<std::vector<std::string>>(const std::string&) const;
|
||||
template std::vector<boost::dynamic_bitset<>> IFC_PARSE_API express::entity::get_value<std::vector<boost::dynamic_bitset<>>>(const std::string&) const;
|
||||
template std::vector<express::base> IFC_PARSE_API express::entity::get_value<std::vector<express::base>>(const std::string&) const;
|
||||
template std::vector<std::vector<int64_t>> IFC_PARSE_API express::entity::get_value<std::vector<std::vector<int64_t>>>(const std::string&) const;
|
||||
template std::vector<std::vector<double>> IFC_PARSE_API express::entity::get_value<std::vector<std::vector<double>>>(const std::string&) const;
|
||||
template std::vector<std::vector<express::base>> IFC_PARSE_API express::entity::get_value<std::vector<std::vector<express::base>>>(const std::string&) const;
|
||||
|
||||
template int64_t IFC_PARSE_API express::Entity::get_value<int64_t>(const std::string&, const int64_t&) const;
|
||||
template bool IFC_PARSE_API express::Entity::get_value<bool>(const std::string&, const bool&) const;
|
||||
template boost::logic::tribool IFC_PARSE_API express::Entity::get_value<boost::logic::tribool>(const std::string&, const boost::logic::tribool&) const;
|
||||
template double IFC_PARSE_API express::Entity::get_value<double>(const std::string&, const double&) const;
|
||||
template std::string IFC_PARSE_API express::Entity::get_value<std::string>(const std::string&, const std::string&) const;
|
||||
template express::Base IFC_PARSE_API express::Entity::get_value<express::Base>(const std::string&, const express::Base&) const;
|
||||
template boost::dynamic_bitset<> IFC_PARSE_API express::Entity::get_value<boost::dynamic_bitset<>>(const std::string&, const boost::dynamic_bitset<>&) const;
|
||||
template enumeration_reference IFC_PARSE_API express::Entity::get_value<enumeration_reference>(const std::string&, const enumeration_reference&) const;
|
||||
template std::vector<int64_t> IFC_PARSE_API express::Entity::get_value<std::vector<int64_t>>(const std::string&, const std::vector<int64_t>&) const;
|
||||
template std::vector<double> IFC_PARSE_API express::Entity::get_value<std::vector<double>>(const std::string&, const std::vector<double>&) const;
|
||||
template std::vector<std::string> IFC_PARSE_API express::Entity::get_value<std::vector<std::string>>(const std::string&, const std::vector<std::string>&) const;
|
||||
template std::vector<boost::dynamic_bitset<>> IFC_PARSE_API express::Entity::get_value<std::vector<boost::dynamic_bitset<>>>(const std::string&, const std::vector<boost::dynamic_bitset<>>&) const;
|
||||
template std::vector<express::Base> IFC_PARSE_API express::Entity::get_value<std::vector<express::Base>>(const std::string&, const std::vector<express::Base>&) const;
|
||||
template std::vector<std::vector<int64_t>> IFC_PARSE_API express::Entity::get_value<std::vector<std::vector<int64_t>>>(const std::string&, const std::vector<std::vector<int64_t>>&) const;
|
||||
template std::vector<std::vector<double>> IFC_PARSE_API express::Entity::get_value<std::vector<std::vector<double>>>(const std::string&, const std::vector<std::vector<double>>&) const;
|
||||
template std::vector<std::vector<express::Base>> IFC_PARSE_API express::Entity::get_value<std::vector<std::vector<express::Base>>>(const std::string&, const std::vector<std::vector<express::Base>>&) const;
|
||||
template int64_t IFC_PARSE_API express::entity::get_value<int64_t>(const std::string&, const int64_t&) const;
|
||||
template bool IFC_PARSE_API express::entity::get_value<bool>(const std::string&, const bool&) const;
|
||||
template boost::logic::tribool IFC_PARSE_API express::entity::get_value<boost::logic::tribool>(const std::string&, const boost::logic::tribool&) const;
|
||||
template double IFC_PARSE_API express::entity::get_value<double>(const std::string&, const double&) const;
|
||||
template std::string IFC_PARSE_API express::entity::get_value<std::string>(const std::string&, const std::string&) const;
|
||||
template express::base IFC_PARSE_API express::entity::get_value<express::base>(const std::string&, const express::base&) const;
|
||||
template boost::dynamic_bitset<> IFC_PARSE_API express::entity::get_value<boost::dynamic_bitset<>>(const std::string&, const boost::dynamic_bitset<>&) const;
|
||||
template enumeration_reference IFC_PARSE_API express::entity::get_value<enumeration_reference>(const std::string&, const enumeration_reference&) const;
|
||||
template std::vector<int64_t> IFC_PARSE_API express::entity::get_value<std::vector<int64_t>>(const std::string&, const std::vector<int64_t>&) const;
|
||||
template std::vector<double> IFC_PARSE_API express::entity::get_value<std::vector<double>>(const std::string&, const std::vector<double>&) const;
|
||||
template std::vector<std::string> IFC_PARSE_API express::entity::get_value<std::vector<std::string>>(const std::string&, const std::vector<std::string>&) const;
|
||||
template std::vector<boost::dynamic_bitset<>> IFC_PARSE_API express::entity::get_value<std::vector<boost::dynamic_bitset<>>>(const std::string&, const std::vector<boost::dynamic_bitset<>>&) const;
|
||||
template std::vector<express::base> IFC_PARSE_API express::entity::get_value<std::vector<express::base>>(const std::string&, const std::vector<express::base>&) const;
|
||||
template std::vector<std::vector<int64_t>> IFC_PARSE_API express::entity::get_value<std::vector<std::vector<int64_t>>>(const std::string&, const std::vector<std::vector<int64_t>>&) const;
|
||||
template std::vector<std::vector<double>> IFC_PARSE_API express::entity::get_value<std::vector<std::vector<double>>>(const std::string&, const std::vector<std::vector<double>>&) const;
|
||||
template std::vector<std::vector<express::base>> IFC_PARSE_API express::entity::get_value<std::vector<std::vector<express::base>>>(const std::string&, const std::vector<std::vector<express::base>>&) const;
|
||||
|
||||
@@ -83,9 +83,9 @@ class IFC_PARSE_API spf_lexer {
|
||||
// void TokenString(size_t offset, std::string& result);
|
||||
};
|
||||
|
||||
IFC_PARSE_API std::vector<express::Base> traverse(const express::Base& instance, int max_depth = -1);
|
||||
IFC_PARSE_API std::vector<express::base> traverse(const express::base& instance, int max_depth = -1);
|
||||
|
||||
IFC_PARSE_API std::vector<express::Base> traverse_breadth_first(const express::Base& instance, int max_depth = -1);
|
||||
IFC_PARSE_API std::vector<express::base> traverse_breadth_first(const express::base& instance, int max_depth = -1);
|
||||
} // namespace ifcopenshell
|
||||
|
||||
IFC_PARSE_API std::ostream& operator<<(std::ostream& stream, const ifcopenshell::file& file);
|
||||
|
||||
@@ -101,15 +101,15 @@ Header_section_schema::file_schema ifcopenshell::spf_header::file_schema() {
|
||||
|
||||
void ifcopenshell::spf_header::assign(const spf_header& other) {
|
||||
if (this != &other) {
|
||||
auto copy_inst = [](express::Entity& new_entity, const express::Entity& entity) {
|
||||
auto copy_inst = [](express::entity& new_entity, const express::entity& entity) {
|
||||
for (size_t i = 0; i < entity.declaration().as_entity()->attribute_count(); ++i) {
|
||||
entity.get_attribute_value(i).apply_visitor([i, &entity, &new_entity](const auto& v) {
|
||||
using U = std::decay_t<decltype(v)>;
|
||||
if constexpr (std::is_same_v<U, express::Base>) {
|
||||
} else if constexpr (std::is_same_v<U, std::vector<express::Base>>) {
|
||||
} else if constexpr (std::is_same_v<U, std::vector<std::vector<express::Base>>>) {
|
||||
} else if constexpr (std::is_same_v<U, empty_aggregate_t>) {
|
||||
} else if constexpr (std::is_same_v<U, empty_aggregate_of_aggregate_t>) {
|
||||
using u = std::decay_t<decltype(v)>;
|
||||
if constexpr (std::is_same_v<u, express::base>) {
|
||||
} else if constexpr (std::is_same_v<u, std::vector<express::base>>) {
|
||||
} else if constexpr (std::is_same_v<u, std::vector<std::vector<express::base>>>) {
|
||||
} else if constexpr (std::is_same_v<u, empty_aggregate_t>) {
|
||||
} else if constexpr (std::is_same_v<u, empty_aggregate_of_aggregate_t>) {
|
||||
} else {
|
||||
new_entity.set_attribute_value(i, v);
|
||||
}
|
||||
@@ -118,8 +118,8 @@ void ifcopenshell::spf_header::assign(const spf_header& other) {
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < header_entities_.size(); ++i) {
|
||||
express::Entity tmp(header_entities_[i]);
|
||||
copy_inst(tmp, express::Entity(other.header_entities_[i]));
|
||||
express::entity tmp(header_entities_[i]);
|
||||
copy_inst(tmp, express::entity(other.header_entities_[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-20
@@ -135,7 +135,7 @@ namespace ifcopenshell {
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::variant<instance_reference, express::Base> reference_or_simple_type;
|
||||
typedef std::variant<instance_reference, express::base> reference_or_simple_type;
|
||||
typedef std::vector<std::pair<mutable_attribute_value, std::variant<reference_or_simple_type, std::vector<reference_or_simple_type>, std::vector<std::vector<reference_or_simple_type>>>>> unresolved_references;
|
||||
|
||||
class file;
|
||||
@@ -421,15 +421,15 @@ namespace ifcopenshell {
|
||||
|
||||
unresolved_references* references_to_resolve = nullptr;
|
||||
|
||||
typedef std::map<const ifcopenshell::declaration*, std::vector<express::Base>> entities_by_type_t;
|
||||
typedef std::map<const ifcopenshell::declaration*, std::vector<express::base>> entities_by_type_t;
|
||||
typedef std::unordered_map<uint32_t, shared_pointer_type> entity_instance_by_name_storage_t;
|
||||
typedef map_transformer<entity_instance_by_name_storage_t, std::function<express::Base(shared_pointer_type)>> entity_instance_by_name_t;
|
||||
typedef map_transformer<entity_instance_by_name_storage_t, std::function<express::base(shared_pointer_type)>> entity_instance_by_name_t;
|
||||
typedef std::unordered_map<uint32_t, shared_pointer_type> type_instance_by_name_t;
|
||||
typedef std::map<std::string, express::Base> entity_instance_by_guid_t;
|
||||
typedef std::map<std::string, express::base> entity_instance_by_guid_t;
|
||||
typedef inverse_index entities_by_ref_t;
|
||||
typedef entity_instance_by_name_t::iterator iterator;
|
||||
|
||||
in_memory_file_storage(ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()) : logger_(logger), file(owner_file), schema(nullptr), byid_read_(&byid_, [this](const shared_pointer_type& data) { return express::Base(data); }) {};
|
||||
in_memory_file_storage(ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root()) : logger_(logger), file(owner_file), schema(nullptr), byid_read_(&byid_, [this](const shared_pointer_type& data) { return express::base(data); }) {};
|
||||
in_memory_file_storage(const in_memory_file_storage& other) = delete;
|
||||
in_memory_file_storage(const in_memory_file_storage&& other) = delete;
|
||||
|
||||
@@ -480,21 +480,21 @@ namespace ifcopenshell {
|
||||
void try_read_semicolon(ifcopenshell::spf_lexer<Reader>* tokens) const;
|
||||
|
||||
void register_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, int instance_id, int attribute_index);
|
||||
void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::Base& entity, int attribute_index);
|
||||
void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::base& entity, int attribute_index);
|
||||
|
||||
template <typename Reader>
|
||||
void read_from_stream(Reader* stream, const ifcopenshell::schema_definition*& schema, unsigned int& max_id, const std::set<std::string>& types_to_bypass);
|
||||
|
||||
file_open_status good_ = file_open_status::SUCCESS;
|
||||
|
||||
express::Base instance_by_id(int instance_id);
|
||||
express::base instance_by_id(int instance_id);
|
||||
|
||||
void add_type_ref(const express::Base& new_entity) {
|
||||
void add_type_ref(const express::base& new_entity) {
|
||||
if (auto* ty = new_entity.declaration().as_entity()) {
|
||||
bytype_excl_[ty].push_back(new_entity);
|
||||
}
|
||||
}
|
||||
void remove_type_ref(const express::Base& new_entity) {
|
||||
void remove_type_ref(const express::base& new_entity) {
|
||||
if (auto* ty = new_entity.declaration().as_entity()) {
|
||||
auto it = bytype_excl_.find(ty);
|
||||
if (it != bytype_excl_.end()) {
|
||||
@@ -506,12 +506,12 @@ namespace ifcopenshell {
|
||||
}
|
||||
}
|
||||
|
||||
void process_deletion_inverse(const express::Base& entity);
|
||||
void process_deletion_inverse(const express::base& entity);
|
||||
|
||||
template <typename T>
|
||||
T create(int instance_id = -1);
|
||||
|
||||
express::Base create(const ifcopenshell::declaration* declaration, int instance_id = -1);
|
||||
express::base create(const ifcopenshell::declaration* declaration, int instance_id = -1);
|
||||
};
|
||||
|
||||
class IFC_PARSE_API rocks_db_file_storage {
|
||||
@@ -540,7 +540,7 @@ namespace ifcopenshell {
|
||||
// identity_by_id_t byid_;
|
||||
typedef rocksdb_set_view<size_t> instance_name_view_t;
|
||||
instance_name_view_t instance_ids_;
|
||||
typedef set_to_map_transformer<instance_name_view_t, std::function<express::Base(size_t)>> entity_instance_by_name_t;
|
||||
typedef set_to_map_transformer<instance_name_view_t, std::function<express::base(size_t)>> entity_instance_by_name_t;
|
||||
entity_instance_by_name_t instance_by_name_;
|
||||
|
||||
// typedef map_transformer<rocksdb_map_adapter<size_t, size_t>, std::function<ifcopenshell::IfcBaseClass*(size_t)>, std::function<size_t(ifcopenshell::IfcBaseClass*)>> entity_by_id_t;
|
||||
@@ -556,7 +556,7 @@ namespace ifcopenshell {
|
||||
instance_id_by_guid_str_t byguid_internal_;
|
||||
|
||||
// guid -> id -> instance
|
||||
typedef map_transformer<rocksdb_map_adapter<std::string, size_t>, std::function<express::Base(size_t)>, std::function<size_t(const express::Base&)>> entity_instance_by_guid_t;
|
||||
typedef map_transformer<rocksdb_map_adapter<std::string, size_t>, std::function<express::base(size_t)>, std::function<size_t(const express::base&)>> entity_instance_by_guid_t;
|
||||
entity_instance_by_guid_t byguid_;
|
||||
|
||||
typedef std::tuple<int, int, int> inverse_attr_record;
|
||||
@@ -576,7 +576,7 @@ namespace ifcopenshell {
|
||||
|
||||
bool read_schema(const ifcopenshell::schema_definition*& schema);
|
||||
|
||||
express::Base assert_existance(size_t instance_id, instance_ref reference_type);
|
||||
express::base assert_existance(size_t instance_id, instance_ref reference_type);
|
||||
|
||||
// @todo merge iterators (template?)
|
||||
class IFC_PARSE_API rocksdb_types_iterator {
|
||||
@@ -678,20 +678,20 @@ namespace ifcopenshell {
|
||||
using const_iterator = entity_instance_by_name_t::iterator;
|
||||
|
||||
void register_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, int instance_id, int attribute_index);
|
||||
void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::Base& entity, int attribute_index);
|
||||
void unregister_inverse(unsigned referenced_id, const ifcopenshell::entity* from_entity, const express::base& entity, int attribute_index);
|
||||
|
||||
// @todo a bit hard as a map because of value_type being an aggregate
|
||||
void add_type_ref(const express::Base& new_entity);
|
||||
void remove_type_ref(const express::Base& new_entity);
|
||||
void add_type_ref(const express::base& new_entity);
|
||||
void remove_type_ref(const express::base& new_entity);
|
||||
|
||||
express::Base instance_by_id(int instance_id);
|
||||
express::base instance_by_id(int instance_id);
|
||||
|
||||
void process_deletion_inverse(const express::Base& entity);
|
||||
void process_deletion_inverse(const express::base& entity);
|
||||
|
||||
template <typename T>
|
||||
T create(int instance_id = -1);
|
||||
|
||||
express::Base create(const ifcopenshell::declaration* declaration, int instance_id = -1);
|
||||
express::base create(const ifcopenshell::declaration* declaration, int instance_id = -1);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ void instance_data::populate_derived_() {
|
||||
}
|
||||
}
|
||||
|
||||
attribute_value express::Entity::get(const std::string& name) const {
|
||||
attribute_value express::entity::get(const std::string& name) const {
|
||||
auto attrs = declaration().as_entity()->all_attributes();
|
||||
auto iter = attrs.begin();
|
||||
size_t idx = 0;
|
||||
@@ -155,7 +155,7 @@ attribute_value express::Entity::get(const std::string& name) const {
|
||||
throw ifcopenshell::exception(name + " not found on " + declaration().name());
|
||||
}
|
||||
|
||||
std::vector<express::Entity> express::Entity::get_inverse(const std::string& name) const {
|
||||
std::vector<express::entity> express::entity::get_inverse(const std::string& name) const {
|
||||
const std::vector<const ifcopenshell::inverse_attribute*> attrs = declaration().as_entity()->all_inverse_attributes();
|
||||
std::vector<const ifcopenshell::inverse_attribute*>::const_iterator iter = attrs.begin();
|
||||
for (; iter != attrs.end(); ++iter) {
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace impl {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct VariantTypeName;
|
||||
struct variant_type_name;
|
||||
|
||||
// Trait to detect unique_ptr
|
||||
template <typename...> struct is_unique_ptr : std::false_type {};
|
||||
@@ -66,23 +66,23 @@ namespace impl {
|
||||
|
||||
// Trait to find index of type in parameter pack considering inheritance
|
||||
template <typename T, typename... Ts>
|
||||
struct TypeIndex;
|
||||
struct type_index;
|
||||
|
||||
// Base case: When the first type in the pack is the type we're looking for, or is a base class of it
|
||||
template <typename T, typename U, typename... Ts>
|
||||
struct TypeIndex<T, U, Ts...>
|
||||
struct type_index<T, U, Ts...>
|
||||
: std::integral_constant<std::size_t, (std::is_pointer_v<T> ? std::is_base_of_v<std::remove_pointer_t<U>, std::remove_pointer_t<T>> : std::is_same_v<T, U>) ? 0 :
|
||||
(TypeIndex<T, Ts...>::value == std::numeric_limits<std::size_t>::max()
|
||||
(type_index<T, Ts...>::value == std::numeric_limits<std::size_t>::max()
|
||||
? std::numeric_limits<std::size_t>::max()
|
||||
: 1 + TypeIndex<T, Ts...>::value)> {};
|
||||
: 1 + type_index<T, Ts...>::value)> {};
|
||||
|
||||
// Recursion termination: When the parameter pack is empty
|
||||
template <typename T>
|
||||
struct TypeIndex<T> : std::integral_constant<std::size_t, std::numeric_limits<std::size_t>::max()> {};
|
||||
struct type_index<T> : std::integral_constant<std::size_t, std::numeric_limits<std::size_t>::max()> {};
|
||||
|
||||
// Helper variable template
|
||||
template <typename T, typename... Ts>
|
||||
constexpr std::size_t TypeIndex_v = TypeIndex<T, Ts...>::value;
|
||||
constexpr std::size_t TypeIndex_v = type_index<T, Ts...>::value;
|
||||
|
||||
// Trait to determine if a type is small enough to be stored directly
|
||||
template <typename T>
|
||||
@@ -92,7 +92,7 @@ namespace impl {
|
||||
|
||||
// Metafunction to transform T to unique_ptr<T> based on size
|
||||
template <typename T>
|
||||
struct TransformType {
|
||||
struct transform_type {
|
||||
using type = typename std::conditional<
|
||||
is_small_object<T>::value,
|
||||
T,
|
||||
@@ -102,28 +102,28 @@ namespace impl {
|
||||
|
||||
// Helper to prepend a type to a tuple
|
||||
template <typename T, typename Tuple>
|
||||
struct TuplePrepend;
|
||||
struct tuple_prepend;
|
||||
template <typename T, typename... Types>
|
||||
struct TuplePrepend<T, std::tuple<Types...>> {
|
||||
struct tuple_prepend<T, std::tuple<Types...>> {
|
||||
using type = std::tuple<T, Types...>;
|
||||
};
|
||||
|
||||
// Map types based on above size transform
|
||||
template <typename... Types>
|
||||
struct MapTypes;
|
||||
struct map_types;
|
||||
template <typename FirstType, typename... RestTypes>
|
||||
struct MapTypes<FirstType, RestTypes...> {
|
||||
using type = typename TuplePrepend<
|
||||
typename TransformType<FirstType>::type,
|
||||
typename MapTypes<RestTypes...>::type
|
||||
struct map_types<FirstType, RestTypes...> {
|
||||
using type = typename tuple_prepend<
|
||||
typename transform_type<FirstType>::type,
|
||||
typename map_types<RestTypes...>::type
|
||||
>::type;
|
||||
};
|
||||
template <>
|
||||
struct MapTypes<> {
|
||||
struct map_types<> {
|
||||
using type = std::tuple<>;
|
||||
};
|
||||
template <typename... Types>
|
||||
using MapTypes_t = typename MapTypes<Types...>::type;
|
||||
using map_types_t = typename map_types<Types...>::type;
|
||||
|
||||
// Create aligned_union from paramater pack stored in tuple for storage in variant
|
||||
template <typename T>
|
||||
@@ -138,11 +138,11 @@ namespace impl {
|
||||
template<typename... Types>
|
||||
class variant_array {
|
||||
public:
|
||||
using TypesTuple = ::impl::MapTypes_t<Types...>;
|
||||
using types_tuple = ::impl::map_types_t<Types...>;
|
||||
|
||||
variant_array(size_t size)
|
||||
: size_and_indices_(size ? new uint8_t[size + 1] : nullptr)
|
||||
, storage_(size ? new StorageType[size] : nullptr)
|
||||
, storage_(size ? new storage_type[size] : nullptr)
|
||||
{
|
||||
if (size) {
|
||||
size_and_indices_[0] = (uint8_t)size;
|
||||
@@ -181,20 +181,20 @@ public:
|
||||
|
||||
template<typename T, typename = std::enable_if_t<!std::is_same_v<std::decay_t<T>, variant_array>>>
|
||||
void set(std::size_t index, T&& value) {
|
||||
using U = std::decay_t<T>;
|
||||
static_assert(::impl::TypeIndex_v<U, Types...> < sizeof...(Types), "Type not supported by variant");
|
||||
using u = std::decay_t<T>;
|
||||
static_assert(::impl::TypeIndex_v<u, Types...> < sizeof...(Types), "Type not supported by variant");
|
||||
if (index >= size()) {
|
||||
throw std::out_of_range("Index " + std::to_string(index) + " is out of range for storage of size " + std::to_string(size()));
|
||||
}
|
||||
|
||||
destroy_at_index(index);
|
||||
|
||||
size_and_indices_[index + 1] = ::impl::TypeIndex_v<U, Types...>;
|
||||
using V = typename std::tuple_element<::impl::TypeIndex_v<U, Types...>, ::impl::MapTypes_t<Types... >>::type;
|
||||
if constexpr (::impl::is_unique_ptr<V>::value) {
|
||||
new(&storage_[index]) V(new U(value));
|
||||
size_and_indices_[index + 1] = ::impl::TypeIndex_v<u, Types...>;
|
||||
using v = typename std::tuple_element<::impl::TypeIndex_v<u, Types...>, ::impl::map_types_t<Types... >>::type;
|
||||
if constexpr (::impl::is_unique_ptr<v>::value) {
|
||||
new(&storage_[index]) v(new u(value));
|
||||
} else {
|
||||
new(&storage_[index]) U(std::forward<T>(value));
|
||||
new(&storage_[index]) u(std::forward<T>(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,17 +221,17 @@ public:
|
||||
if (!has<T>(index)) {
|
||||
throw std::bad_cast();
|
||||
}
|
||||
using V = typename std::tuple_element<::impl::TypeIndex_v<T, Types...>, ::impl::MapTypes_t<Types... >>::type;
|
||||
if constexpr (::impl::is_unique_ptr<V>::value) {
|
||||
return **reinterpret_cast<V*>(&storage_[index]);
|
||||
using v = typename std::tuple_element<::impl::TypeIndex_v<T, Types...>, ::impl::map_types_t<Types... >>::type;
|
||||
if constexpr (::impl::is_unique_ptr<v>::value) {
|
||||
return **reinterpret_cast<v*>(&storage_[index]);
|
||||
} else {
|
||||
return *reinterpret_cast<V*>(&storage_[index]);
|
||||
return *reinterpret_cast<v*>(&storage_[index]);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool has(std::size_t index) const {
|
||||
return index < size() && size_and_indices_[index + 1] == ::impl::TypeIndex<T, Types...>::value;
|
||||
return index < size() && size_and_indices_[index + 1] == ::impl::type_index<T, Types...>::value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -241,19 +241,19 @@ public:
|
||||
"Index " + std::to_string(index) + " is out of range for storage of size " + std::to_string(size())
|
||||
);
|
||||
}
|
||||
if (size_and_indices_[index + 1] != ::impl::TypeIndex<T, Types...>::value) {
|
||||
if (size_and_indices_[index + 1] != ::impl::type_index<T, Types...>::value) {
|
||||
// @todo this exception is silly. Figure out what
|
||||
// to do, but at the moment it is specifically caught
|
||||
// in various places.
|
||||
throw impl::storage_type_mismatch(
|
||||
::impl::VariantTypeName<T>::get(), get_type_name(size_and_indices_[index + 1])
|
||||
::impl::variant_type_name<T>::get(), get_type_name(size_and_indices_[index + 1])
|
||||
);
|
||||
}
|
||||
using V = typename std::tuple_element<::impl::TypeIndex_v<T, Types...>, ::impl::MapTypes_t<Types... >>::type;
|
||||
if constexpr (::impl::is_unique_ptr<V>::value) {
|
||||
return **reinterpret_cast<const V*>(&storage_[index]);
|
||||
using v = typename std::tuple_element<::impl::TypeIndex_v<T, Types...>, ::impl::map_types_t<Types... >>::type;
|
||||
if constexpr (::impl::is_unique_ptr<v>::value) {
|
||||
return **reinterpret_cast<const v*>(&storage_[index]);
|
||||
} else {
|
||||
return *reinterpret_cast<const V*>(&storage_[index]);
|
||||
return *reinterpret_cast<const v*>(&storage_[index]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,10 +272,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
using StorageType = typename ::impl::make_union_from_tuple<::impl::MapTypes_t<Types...>>::type;
|
||||
using storage_type = typename ::impl::make_union_from_tuple<::impl::map_types_t<Types...>>::type;
|
||||
|
||||
uint8_t* size_and_indices_;
|
||||
StorageType* storage_;
|
||||
storage_type* storage_;
|
||||
|
||||
void destroy_at_index(std::size_t index) {
|
||||
destroy_type_at_index(index, std::integral_constant<std::size_t, sizeof...(Types)>{});
|
||||
@@ -294,9 +294,9 @@ private:
|
||||
template<std::size_t Index>
|
||||
void destroy_type_at_index(std::size_t index, std::integral_constant<std::size_t, Index>) {
|
||||
if (size_and_indices_[index + 1] == Index - 1) {
|
||||
using T = typename std::tuple_element_t<Index - 1, ::impl::MapTypes_t<Types...>>;
|
||||
if constexpr (!std::is_trivially_destructible<T>::value) {
|
||||
reinterpret_cast<T*>(&storage_[index])->~T();
|
||||
using t = typename std::tuple_element_t<Index - 1, ::impl::map_types_t<Types...>>;
|
||||
if constexpr (!std::is_trivially_destructible<t>::value) {
|
||||
reinterpret_cast<t*>(&storage_[index])->~t();
|
||||
}
|
||||
size_and_indices_[index + 1] = sizeof...(Types);
|
||||
} else {
|
||||
@@ -311,11 +311,11 @@ private:
|
||||
template<typename Visitor, std::size_t Index>
|
||||
auto apply_visitor_impl(Visitor&& visitor, std::size_t index, std::integral_constant<std::size_t, Index>) const {
|
||||
if (size_and_indices_[index + 1] == Index - 1) {
|
||||
using T = typename std::tuple_element_t<Index - 1, ::impl::MapTypes_t<Types...>>;
|
||||
if constexpr (::impl::is_unique_ptr<T>::value) {
|
||||
return visitor(**reinterpret_cast<T*>(&storage_[index]));
|
||||
using t = typename std::tuple_element_t<Index - 1, ::impl::map_types_t<Types...>>;
|
||||
if constexpr (::impl::is_unique_ptr<t>::value) {
|
||||
return visitor(**reinterpret_cast<t*>(&storage_[index]));
|
||||
} else {
|
||||
return visitor(*reinterpret_cast<T*>(&storage_[index]));
|
||||
return visitor(*reinterpret_cast<t*>(&storage_[index]));
|
||||
}
|
||||
}
|
||||
return apply_visitor_impl(std::forward<Visitor>(visitor), index, std::integral_constant<std::size_t, Index - 1>{});
|
||||
@@ -326,8 +326,8 @@ private:
|
||||
static_cast<void>(visitor);
|
||||
static_cast<void>(index);
|
||||
throw std::runtime_error("Invalid variant index");
|
||||
if constexpr (!std::is_void_v<decltype(std::declval<Visitor>()(std::declval<typename std::tuple_element_t<0, ::impl::MapTypes_t<Types...>> &>()))>) {
|
||||
return decltype(std::declval<Visitor>()(std::declval<typename std::tuple_element_t<0, ::impl::MapTypes_t<Types...>> &>())){};
|
||||
if constexpr (!std::is_void_v<decltype(std::declval<Visitor>()(std::declval<typename std::tuple_element_t<0, ::impl::map_types_t<Types...>> &>()))>) {
|
||||
return decltype(std::declval<Visitor>()(std::declval<typename std::tuple_element_t<0, ::impl::map_types_t<Types...>> &>())){};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ private:
|
||||
return "";
|
||||
} else {
|
||||
if (type_index == I - 1) {
|
||||
return ::impl::VariantTypeName<std::tuple_element_t<I - 1, std::tuple<Types...>>>::get();
|
||||
return ::impl::variant_type_name<std::tuple_element_t<I - 1, std::tuple<Types...>>>::get();
|
||||
} else {
|
||||
return get_type_name_impl<I - 1>(type_index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user