Wrap more classes into ifcopenshell:: namespace

This commit is contained in:
Thomas Krijnen
2026-08-08 13:58:39 +02:00
parent 2c47c9d4fa
commit 02481b3247
149 changed files with 678 additions and 627 deletions
+4 -4
View File
@@ -488,7 +488,7 @@ Ifc4x3_add2::IfcAlignment addAlignment(hierarchy_helper<Ifc4x3_add2>& file, cons
return alignment;
}
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentSegment& segment, logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentSegment& segment, ifcopenshell::logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result;
auto design_parameters = segment.DesignParameters();
auto horizontal = design_parameters.as<Ifc4x3_add2::IfcAlignmentHorizontalSegment>();
@@ -514,7 +514,7 @@ Ifc4x3_add2::IfcLengthMeasure create_length(hierarchy_helper<Ifc4x3_add2>& file,
}
}
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentHorizontalSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment, logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentHorizontalSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment, ifcopenshell::logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result;
auto start_point = segment.StartPoint();
auto start_direction = segment.StartDirection();
@@ -770,7 +770,7 @@ std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignme
return result;
}
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentVerticalSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment, logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentVerticalSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment, ifcopenshell::logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result;
auto start_distance_along = segment.StartDistAlong();
auto horizontal_length = segment.HorizontalLength();
@@ -862,7 +862,7 @@ std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignme
return result;
}
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentCantSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentCantSegment(hierarchy_helper<Ifc4x3_add2>& file, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, ifcopenshell::logger& logger) {
std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> result;
auto type = segment.PredefinedType();
if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_BLOSSCURVE) {
+4 -4
View File
@@ -45,10 +45,10 @@ IFC_SCHEMA_API Ifc4x3_add2::IfcAlignment addAlignment(hierarchy_helper<Ifc4x3_ad
// Maps horizontal alignment business logic to geometry.
// Bloss curves have two geometry elements for one horizontal alignment segment. That is the reason for returning a pair.
// Typically the first element of the pair will have the geometry and the second element will be nullptr
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentSegment& segment, logger& logger = ::logger::root());
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentHorizontalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment, logger& logger = ::logger::root());
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentVerticalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment, logger& logger = ::logger::root());
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentCantSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, logger& logger = ::logger::root());
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentSegment& segment, ifcopenshell::logger& logger = ifcopenshell::logger::root());
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentHorizontalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentHorizontalSegment& segment, ifcopenshell::logger& logger = ifcopenshell::logger::root());
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentVerticalSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentVerticalSegment& segment, ifcopenshell::logger& logger = ifcopenshell::logger::root());
IFC_SCHEMA_API std::pair<Ifc4x3_add2::IfcCurveSegment, Ifc4x3_add2::IfcCurveSegment> mapAlignmentCantSegment(hierarchy_helper<Ifc4x3_add2>& model, const Ifc4x3_add2::IfcAlignmentCantSegment& segment, ifcopenshell::logger& logger = ifcopenshell::logger::root());
#endif
+1 -1
View File
@@ -57,7 +57,7 @@ class IFC_PARSE_API character_decoder {
inline static ConversionMode mode = UTF8;
inline static char substitution_character = '_';
character_decoder(Reader* stream, logger& logger = ::logger::root());
character_decoder(Reader* stream, logger& logger = ifcopenshell::logger::root());
~character_decoder();
// Gets a decoded string representation at the token stream
// read pointer and advances the underlying token stream.
+19 -17
View File
@@ -3,6 +3,8 @@
#include "exception.h"
#include "file.h"
using namespace ifcopenshell;
// @todo is size() still needed?
class size_visitor {
public:
@@ -37,7 +39,7 @@ namespace {
if (storage_model_ == 0) {
try {
return array_.storage_ptr->get<T>(index_);
} catch (const impl::storage_type_mismatch& e) {
} catch (const ::impl::storage_type_mismatch& e) {
throw ifcopenshell::exception(
// entity_or_type not passed, but in v0.9 this is beginning to make sense
(entity_or_type
@@ -66,7 +68,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);
impl::deserialize(array_.db_ptr, str, val);
::impl::deserialize(array_.db_ptr, str, val);
} else {
static_assert(
std::is_same_v<T, enumeration_reference> ||
@@ -287,7 +289,7 @@ 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);
@@ -300,7 +302,7 @@ bool impl::serialize(std::string& val, const express::base& t)
return true;
}
bool impl::serialize(std::string& val, const enumeration_reference& v)
bool ::impl::serialize(std::string& val, const enumeration_reference& v)
{
auto s = sizeof(size_t);
val.resize(s * 2 + 1);
@@ -312,7 +314,7 @@ 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);
@@ -328,7 +330,7 @@ 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(type_encoder::encode_type<std::vector<std::vector<express::base>>>());
@@ -363,35 +365,35 @@ bool impl::serialize(std::string& val, const std::vector<std::vector<express::ba
return true;
}
bool impl::serialize(std::string& val, const blank&)
bool ::impl::serialize(std::string& val, const blank&)
{
val.resize(1);
val[0] = type_encoder::encode_type<blank>();
return true;
}
bool impl::serialize(std::string& val, const derived&)
bool ::impl::serialize(std::string& val, const derived&)
{
val.resize(1);
val[0] = type_encoder::encode_type<derived>();
return true;
}
bool impl::serialize(std::string& val, const empty_aggregate_t&)
bool ::impl::serialize(std::string& val, const empty_aggregate_t&)
{
val.resize(1);
val[0] = type_encoder::encode_type<empty_aggregate_t>();
return true;
}
bool impl::serialize(std::string& val, const empty_aggregate_of_aggregate_t&)
bool ::impl::serialize(std::string& val, const empty_aggregate_of_aggregate_t&)
{
val.resize(1);
val[0] = type_encoder::encode_type<empty_aggregate_of_aggregate_t>();
return true;
}
bool impl::serialize(std::string& val, const boost::logic::tribool& t)
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);
@@ -400,7 +402,7 @@ bool impl::serialize(std::string& val, const boost::logic::tribool& t)
return true;
}
bool impl::serialize(std::string& val, const boost::dynamic_bitset<>& t)
bool ::impl::serialize(std::string& val, const boost::dynamic_bitset<>& t)
{
std::string tmp;
boost::to_string(t, tmp);
@@ -408,7 +410,7 @@ bool impl::serialize(std::string& val, const boost::dynamic_bitset<>& t)
return true;
}
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::logic::tribool& t) {
bool ::impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::logic::tribool& t) {
if (val[0] != type_encoder::encode_type<boost::logic::tribool>()) {
return false;
}
@@ -424,7 +426,7 @@ bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::st
return true;
}
bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::dynamic_bitset<>& t) {
bool ::impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::string& val, boost::dynamic_bitset<>& t) {
if (val[0] != type_encoder::encode_type<boost::dynamic_bitset<>>()) {
return false;
}
@@ -432,7 +434,7 @@ bool impl::deserialize(ifcopenshell::impl::rocks_db_file_storage*, const std::st
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 +453,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;
@@ -514,7 +516,7 @@ void rocks_db_attribute_storage::set(void* storage, const ifcopenshell::declarat
const bool is_header = decl->schema() == &Header_section_schema::get_schema();
ifcopenshell::impl::rocks_db_file_storage* rdb_storage = (ifcopenshell::impl::rocks_db_file_storage*)storage;
std::string v;
impl::serialize(v, value);
::impl::serialize(v, value);
rdb_storage->db->Put(
rdb_storage->wopts,
(is_header ? "h|" : (decl->as_entity() ? "i|" : "t|")) +
+2 -2
View File
@@ -8,7 +8,7 @@ uint32_t express::base::identity() const { return data()->identity(); }
uint32_t express::base::id() const { return data()->id(); }
const instance_data* express::base::data() const {
const ifcopenshell::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() {
ifcopenshell::instance_data* express::base::data() {
#ifdef IFOPSH_SAFE_INSTANCE
auto sp = data_.lock();
if (sp) {
+6 -4
View File
@@ -54,8 +54,10 @@ struct in_memory_file_storage;
}
} // namespace ifcopenshell
namespace ifcopenshell {
class instance_data;
class attribute_value;
}
namespace express {
@@ -67,8 +69,8 @@ class declared_type;
class IFC_PARSE_API base {
protected:
ifcopenshell::pointer_type data_;
const instance_data* data() const;
instance_data* data();
const ifcopenshell::instance_data* data() const;
ifcopenshell::instance_data* data();
public:
operator bool() const {
#ifdef IFOPSH_SAFE_INSTANCE
@@ -120,7 +122,7 @@ class IFC_PARSE_API base {
void unset_attribute_value(size_t attribute_index);
attribute_value get_attribute_value(size_t attribute_index) const;
ifcopenshell::attribute_value get_attribute_value(size_t attribute_index) const;
uint32_t identity() const;
@@ -160,7 +162,7 @@ class IFC_PARSE_API entity : public base {
public:
using base::base;
attribute_value get(const std::string& attribute_name) const;
ifcopenshell::attribute_value get(const std::string& attribute_name) const;
template <typename T>
T get_value(const std::string& attribute_name) const;
+13 -13
View File
@@ -102,7 +102,7 @@ private:
const ifcopenshell::schema_definition* schema_;
ifcopenshell::impl::in_memory_file_storage storage_;
ifcopenshell::file_open_status good_ = ifcopenshell::file_open_status::SUCCESS;
std::reference_wrapper<::logger> logger_;
std::reference_wrapper<ifcopenshell::logger> logger_;
int progress_;
ifcopenshell::unresolved_references references_to_resolve_;
int yielded_header_instances_ = 0;
@@ -156,13 +156,13 @@ private:
void push_page(const std::string& page_data);
instance_streamer(ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root());
instance_streamer(ifcopenshell::file* owner_file = nullptr, ifcopenshell::logger& logger = ifcopenshell::logger::root());
instance_streamer(const std::string& path, bool use_mmap = false, ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root());
instance_streamer(const std::string& path, bool use_mmap = false, ifcopenshell::file* owner_file = nullptr, ifcopenshell::logger& logger = ifcopenshell::logger::root());
instance_streamer(void* data, int data_size, ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root());
instance_streamer(void* data, int data_size, ifcopenshell::file* owner_file = nullptr, ifcopenshell::logger& logger = ifcopenshell::logger::root());
instance_streamer(Reader* stream, ifcopenshell::file* owner_file = nullptr, ::logger& logger = ::logger::root());
instance_streamer(Reader* stream, ifcopenshell::file* owner_file = nullptr, ifcopenshell::logger& logger = ifcopenshell::logger::root());
void bypass_types(const std::set<std::string>& type_names);
@@ -210,7 +210,7 @@ public:
private:
file_open_status good_ = file_open_status::SUCCESS;
std::reference_wrapper<::logger> logger_;
std::reference_wrapper<ifcopenshell::logger> logger_;
const ifcopenshell::schema_definition* schema_;
const ifcopenshell::declaration* ifcroot_type_;
@@ -241,7 +241,7 @@ public:
/// </summary>
/// <param name="path">UTF-8 file path to an IFC-SPF file</param>
/// <param name="mmap">Whether to use memory-mapped I/O</param>
file(const std::string& path, bool use_mmap, ::logger& logger = ::logger::root());
file(const std::string& path, bool use_mmap, ifcopenshell::logger& logger = ifcopenshell::logger::root());
#endif
/// <summary>
/// Constructs an file object from a file path, supports IFC-SPF and the IfcOpenShell-specific RocksDB format.
@@ -250,17 +250,17 @@ public:
/// <param name="type">File type of the path</param>
/// <param name="read_only">Whether to open in read-only mode, only supported on RocksDB databases</param>
/// <param name="logger">Logger used while opening the file</param>
file(const std::string& path, filetype type = FT_AUTODETECT, bool read_only = false, ::logger& logger = ::logger::root());
file(const std::string& path, filetype type = FT_AUTODETECT, bool read_only = false, ifcopenshell::logger& logger = ifcopenshell::logger::root());
/// <summary>
/// Constructs an file object from a stream containing IFC-SPF data.
/// </summary>
file(std::istream& stream, int data_size, ::logger& logger = ::logger::root());
file(std::istream& stream, int data_size, ifcopenshell::logger& logger = ifcopenshell::logger::root());
/// <summary>
/// Constructs an file object from a memory buffer containing IFC-SPF data.
/// </summary>
file(void* data, int data_size, ::logger& logger = ::logger::root());
file(void* data, int data_size, ifcopenshell::logger& logger = ifcopenshell::logger::root());
/// <summary>
/// Constructs an file object with the specified schema, file type, and file path.
@@ -270,12 +270,12 @@ public:
/// <param name="type">The file type to use for the file. Defaults to FT_AUTODETECT.</param>
/// <param name="path">The file system path to the IFC file. Defaults to an empty string.</param>
/// <param name="logger">Logger used while creating the file.</param>
file(const ifcopenshell::schema_definition* schema = ifcopenshell::schema_by_name("IFC4"), filetype type = FT_AUTODETECT, const std::string& path = "", ::logger& logger = ::logger::root());
file(const ifcopenshell::schema_definition* schema = ifcopenshell::schema_by_name("IFC4"), filetype type = FT_AUTODETECT, const std::string& path = "", ifcopenshell::logger& logger = ifcopenshell::logger::root());
/// <summary>
/// Constructs an unitialized file object. Call initialize() later on. Allows to specify which types to bypass during load.
/// </summary>
file(const uninitialized_tag& tag, ::logger& logger = ::logger::root());
file(const uninitialized_tag& tag, ifcopenshell::logger& logger = ifcopenshell::logger::root());
bool initialize(const std::string& path, filetype type = FT_AUTODETECT, bool read_only = false);
#ifdef USE_MMAP
@@ -289,7 +289,7 @@ public:
~file();
ifcopenshell::file_open_status good() const { return good_; }
::logger& logger() const { return logger_.get(); }
ifcopenshell::logger& logger() const { return logger_.get(); }
/// Returns the first entity in the range of instances contained in the model,
/// in arbitrary order
+2 -2
View File
@@ -111,7 +111,7 @@ ifcopenshell::global_id::global_id(logger& logger) {
boost::uuids::uuid test_uuid;
std::copy(test_vector.begin(), test_vector.end(), test_uuid.begin());
if (uuid_data_ != test_uuid) {
logger.message(::logger::LOG_ERROR, "SYS", 34, "Internal error generating GlobalId");
logger.message(ifcopenshell::logger::LOG_ERROR, "SYS", 34, "Internal error generating GlobalId");
}
#endif
}
@@ -130,7 +130,7 @@ ifcopenshell::global_id::global_id(const std::string& string, logger& logger)
#ifndef NDEBUG
const std::string test_string = compress(&uuid_data_.data[0]);
if (string_data_ != test_string) {
logger.message(::logger::LOG_ERROR, "SYS", 35, "Internal error generating GlobalId");
logger.message(ifcopenshell::logger::LOG_ERROR, "SYS", 35, "Internal error generating GlobalId");
}
#endif
}
+2 -2
View File
@@ -37,8 +37,8 @@ class IFC_PARSE_API global_id {
public:
static const unsigned int length = 22;
global_id(logger& logger = ::logger::root());
global_id(const std::string& value, logger& logger = ::logger::root());
global_id(logger& logger = ifcopenshell::logger::root());
global_id(const std::string& value, logger& logger = ifcopenshell::logger::root());
operator const std::string&() const;
operator const boost::uuids::uuid&() const;
const std::string& formatted() const;
+2 -2
View File
@@ -180,9 +180,9 @@ class IFC_SCHEMA_API hierarchy_helper : public ifcopenshell::file {
break;
}
} catch (std::exception& e) {
::logger::root().error(e);
ifcopenshell::logger::root().error(e);
} catch (...) {
::logger::root().error("Unknown error in addRelatedObject()");
ifcopenshell::logger::root().error("Unknown error in addRelatedObject()");
}
}
if (!found) {
+1 -1
View File
@@ -174,7 +174,7 @@ void hierarchy_helper<Schema>::relatePlacements(typename Schema::IfcProduct pare
if (local_place != parent.ObjectPlacement()) {
local_place.setPlacementRelTo(parent.ObjectPlacement());
} else {
::logger::root().notice("Placement cannot be relative to self");
ifcopenshell::logger::root().notice("Placement cannot be relative to self");
}
}
}
+30 -20
View File
@@ -45,6 +45,8 @@
#include <boost/logic/tribool.hpp>
#include <boost/dynamic_bitset.hpp>
namespace ifcopenshell {
class IFC_PARSE_API enumeration_reference {
private:
const ifcopenshell::enumeration_type* enumeration_;
@@ -73,14 +75,16 @@ class IFC_PARSE_API derived {};
class IFC_PARSE_API empty_aggregate_t {};
class IFC_PARSE_API empty_aggregate_of_aggregate_t {};
} // namespace ifcopenshell
namespace impl {
template <>
struct variant_type_name<blank> {
struct variant_type_name<ifcopenshell::blank> {
static std::string get() { return "null"; }
};
template <>
struct variant_type_name<derived> {
struct variant_type_name<ifcopenshell::derived> {
static std::string get() { return "derived"; }
};
@@ -120,7 +124,7 @@ namespace impl {
};
template <>
struct variant_type_name<enumeration_reference> {
struct variant_type_name<ifcopenshell::enumeration_reference> {
static std::string get() { return "enumeration"; }
};
@@ -130,7 +134,7 @@ namespace impl {
};
template <>
struct variant_type_name<empty_aggregate_t> {
struct variant_type_name<ifcopenshell::empty_aggregate_t> {
static std::string get() { return "aggregate"; }
};
@@ -140,11 +144,13 @@ namespace impl {
};
template <>
struct variant_type_name<empty_aggregate_of_aggregate_t> {
struct variant_type_name<ifcopenshell::empty_aggregate_of_aggregate_t> {
static std::string get() { return "aggregate of aggregate"; }
};
}
namespace ifcopenshell {
template<typename... Args>
struct parameter_pack {
static constexpr size_t size = sizeof...(Args);
@@ -239,12 +245,12 @@ class IFC_PARSE_API mutable_attribute_value {
uint8_t index_;
};
namespace ifcopenshell {
namespace impl {
class IFC_PARSE_API rocks_db_file_storage;
}
namespace impl {
class IFC_PARSE_API rocks_db_file_storage;
}
} // namespace ifcopenshell
#ifdef IFOPSH_WITH_ROCKSDB
namespace impl {
@@ -261,14 +267,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] = type_encoder::encode_type<T>();
buffer[0] = ifcopenshell::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, type_encoder::encode_type<T>());
buffer = std::string(1, ifcopenshell::type_encoder::encode_type<T>());
for (auto& nested_value : value) {
std::string nested_buffer;
serialize(nested_buffer, nested_value);
@@ -285,16 +291,16 @@ 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] = type_encoder::encode_type<T>();
buffer[0] = ifcopenshell::type_encoder::encode_type<T>();
memcpy(buffer.data() + 1, &value, sizeof(T));
return true;
}
bool serialize(std::string& buffer, const blank& value);
bool serialize(std::string& buffer, const ifcopenshell::blank& value);
bool serialize(std::string& buffer, const derived& value);
bool serialize(std::string& buffer, const empty_aggregate_t& value);
bool serialize(std::string& buffer, const empty_aggregate_of_aggregate_t& value);
bool serialize(std::string& buffer, const ifcopenshell::derived& value);
bool serialize(std::string& buffer, const ifcopenshell::empty_aggregate_t& value);
bool serialize(std::string& buffer, const ifcopenshell::empty_aggregate_of_aggregate_t& value);
bool serialize(std::string& buffer, const boost::logic::tribool& value);
@@ -302,7 +308,7 @@ namespace impl {
bool serialize(std::string& buffer, const express::base& value);
bool serialize(std::string& buffer, const enumeration_reference& value);
bool serialize(std::string& buffer, const ifcopenshell::enumeration_reference& value);
bool serialize(std::string& buffer, const std::vector<express::base>& value);
@@ -311,7 +317,7 @@ namespace impl {
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] != type_encoder::encode_type<T>()) {
if (has_type_prefix && buffer[0] != ifcopenshell::type_encoder::encode_type<T>()) {
return false;
}
auto element_count = (buffer.size() - (has_type_prefix ? 1 : 0)) / sizeof(typename T::value_type);
@@ -324,7 +330,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 != type_encoder::encode_type<T>()) {
if (*ptr != ifcopenshell::type_encoder::encode_type<T>()) {
return false;
}
ptr++;
@@ -345,7 +351,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] != type_encoder::encode_type<T>()) {
if (buffer[0] != ifcopenshell::type_encoder::encode_type<T>()) {
return false;
}
memcpy(&value, buffer.data() + 1, sizeof(T));
@@ -363,6 +369,8 @@ namespace impl {
#endif
namespace ifcopenshell {
// short lived
class IFC_PARSE_API attribute_value {
uint8_t index_;
@@ -594,4 +602,6 @@ class IFC_PARSE_API instance_data {
void to_string(std::ostream& stream, bool uppercase = false) const;
};
} // namespace ifcopenshell
#endif
+6
View File
@@ -32,6 +32,8 @@
#include <iomanip>
#include <iostream>
using ifcopenshell::logger;
namespace {
std::string get_time(bool with_milliseconds = false) {
@@ -141,6 +143,8 @@ void json_message(T& out, const express::base& current_product, logger::severity
} // namespace
namespace ifcopenshell {
log_message::log_message(
int severity,
const std::string& code,
@@ -378,3 +382,5 @@ void logger::output_format(format format) {
logger::format logger::output_format() const {
return format_;
}
} // namespace ifcopenshell
+7 -3
View File
@@ -34,6 +34,8 @@
#include <string>
#include <vector>
namespace ifcopenshell {
class IFC_PARSE_API log_message {
public:
char code[7];
@@ -152,14 +154,16 @@ class IFC_PARSE_API logger {
// Using `logger* = nullptr` instead of `logger& = logger::root()` helps,
// since `nullptr` is convertable Python's `None`.
// `logger_or_root` is just covering the boilerplate for this pattern.
inline logger& logger_or_root(logger* logger) { return logger ? *logger : ::logger::root(); }
inline logger& logger_or_root(logger* logger) { return logger ? *logger : logger::root(); }
} // namespace ifcopenshell
#define PERF(x) \
\
::logger::root().message(::logger::LOG_PERF, x); \
::ifcopenshell::logger::root().message(::ifcopenshell::logger::LOG_PERF, x); \
\
BOOST_SCOPE_EXIT(void) { \
::logger::root().message(::logger::LOG_PERF, "done " + std::string(x)); \
::ifcopenshell::logger::root().message(::ifcopenshell::logger::LOG_PERF, "done " + std::string(x)); \
} \
BOOST_SCOPE_EXIT_END
+28 -28
View File
@@ -61,7 +61,7 @@
using namespace ifcopenshell;
template <typename Reader>
spf_lexer<Reader>::spf_lexer(Reader* stream_, ::logger& log)
spf_lexer<Reader>::spf_lexer(Reader* stream_, ifcopenshell::logger& log)
: decoder_(nullptr)
, logger_(log) {
stream = stream_;
@@ -638,7 +638,7 @@ void warn_attribute_count(
std::optional<size_t> instance_name,
size_t expected_size,
size_t actual_size,
::logger& logger
ifcopenshell::logger& logger
) {
if (!declaration || expected_size == actual_size) {
return;
@@ -700,9 +700,9 @@ struct direct_aggregate {
direct_aggregate_storage storage;
size_t pending_empty_aggregates = 0;
size_t values = 0;
::logger& logger_;
ifcopenshell::logger& logger_;
explicit direct_aggregate(::logger& logger)
explicit direct_aggregate(ifcopenshell::logger& logger)
: logger_(logger) {}
template <typename T>
@@ -873,7 +873,7 @@ void set_direct_attribute(
if constexpr (std::is_same_v<std::decay_t<T>, ifcopenshell::reference_or_simple_type>) {
if (instance_name && references_to_resolve) {
references_to_resolve->push_back(std::make_pair(
mutable_attribute_value{(uint32_t) *instance_name, resolve_reference_index == -1 ? (uint8_t) attribute_index : (uint8_t) resolve_reference_index},
ifcopenshell::mutable_attribute_value{(uint32_t) *instance_name, resolve_reference_index == -1 ? (uint8_t) attribute_index : (uint8_t) resolve_reference_index},
value
));
}
@@ -914,7 +914,7 @@ direct_aggregate read_direct_aggregate(
const ifcopenshell::entity* entity,
int attribute_index,
const ifcopenshell::aggregation_type* aggregate_type,
::logger& logger
ifcopenshell::logger& logger
) {
direct_aggregate aggregate(logger);
token next = tokens->next();
@@ -1021,7 +1021,7 @@ shared_pointer_type ifcopenshell::impl::in_memory_file_storage::load(
skip_aggregate(tokens);
}
} catch (exception& e) {
logger_.get().message(::logger::LOG_ERROR, std::string(e.what()) + " at offset " + std::to_string(next.start_pos));
logger_.get().message(ifcopenshell::logger::LOG_ERROR, std::string(e.what()) + " at offset " + std::to_string(next.start_pos));
--values_read;
}
} else {
@@ -1654,7 +1654,7 @@ express::base::set_attribute_value(const std::string& s, const T& t)
// Creates the maps
//
#ifdef USE_MMAP
file::file(const std::string& fn, bool mmap, ::logger& log)
file::file(const std::string& fn, bool mmap, ifcopenshell::logger& log)
: logger_(log)
, schema_(nullptr)
, ifcroot_type_(nullptr)
@@ -1687,7 +1687,7 @@ bool ifcopenshell::file::initialize(const std::string& fn, bool mmap) {
}
#endif
file::file(const uninitialized_tag&, ::logger& log)
file::file(const uninitialized_tag&, ifcopenshell::logger& log)
: good_(file_open_status::UNKNOWN), logger_(log), schema_(nullptr), ifcroot_type_(nullptr), max_id_(0), header_(nullptr) {}
bool ifcopenshell::file::initialize(const std::string& path, filetype ty, bool readonly) {
@@ -1744,7 +1744,7 @@ void ifcopenshell::file::bypass_type(const std::string& type_name) {
types_to_bypass_loading_.insert(type_name);
}
file::file(const std::string& path, filetype ty, bool readonly, ::logger& log)
file::file(const std::string& path, filetype ty, bool readonly, ifcopenshell::logger& log)
: logger_(log)
, schema_(nullptr)
, ifcroot_type_(nullptr)
@@ -1753,7 +1753,7 @@ file::file(const std::string& path, filetype ty, bool readonly, ::logger& log)
initialize(path, ty, readonly);
}
file::file(std::istream& stream, int length, ::logger& log)
file::file(std::istream& stream, int length, ifcopenshell::logger& log)
: logger_(log)
, schema_(nullptr)
, ifcroot_type_(nullptr)
@@ -1778,7 +1778,7 @@ file::file(std::istream& stream, int length, ::logger& log)
}
file::file(void* data, int length, ::logger& log)
file::file(void* data, int length, ifcopenshell::logger& log)
: logger_(log)
, schema_(nullptr)
, ifcroot_type_(nullptr)
@@ -1798,7 +1798,7 @@ file::file(void* data, int length, ::logger& log)
}
file::file(const ifcopenshell::schema_definition* schema, filetype ty, const std::string& path, ::logger& log)
file::file(const ifcopenshell::schema_definition* schema, filetype ty, const std::string& path, ifcopenshell::logger& log)
: logger_(log)
, schema_(schema)
, ifcroot_type_(schema_->declaration_by_name("IfcRoot"))
@@ -2017,7 +2017,7 @@ void ifcopenshell::instance_streamer<Reader>::push_page(const std::string& page)
}
template <typename Reader>
ifcopenshell::instance_streamer<Reader>::instance_streamer(ifcopenshell::file* f, ::logger& log)
ifcopenshell::instance_streamer<Reader>::instance_streamer(ifcopenshell::file* f, ifcopenshell::logger& log)
: stream_(nullptr)
, owner_(f)
, token_stream_(3, token{})
@@ -2042,7 +2042,7 @@ ifcopenshell::instance_streamer<Reader>::instance_streamer(ifcopenshell::file* f
}
template <typename Reader>
ifcopenshell::instance_streamer<Reader>::instance_streamer(const std::string& fn, bool mmap, ifcopenshell::file* f, ::logger& log)
ifcopenshell::instance_streamer<Reader>::instance_streamer(const std::string& fn, bool mmap, ifcopenshell::file* f, ifcopenshell::logger& log)
: stream_(nullptr)
, owner_(f)
, token_stream_(3, token{})
@@ -2070,7 +2070,7 @@ ifcopenshell::instance_streamer<Reader>::instance_streamer(const std::string& fn
}
template <typename Reader>
ifcopenshell::instance_streamer<Reader>::instance_streamer(void* data, int length, ifcopenshell::file* f, ::logger& log)
ifcopenshell::instance_streamer<Reader>::instance_streamer(void* data, int length, ifcopenshell::file* f, ifcopenshell::logger& log)
: stream_(nullptr)
, owner_(f)
, token_stream_(3, token{})
@@ -2094,7 +2094,7 @@ ifcopenshell::instance_streamer<Reader>::instance_streamer(void* data, int lengt
}
template <typename Reader>
ifcopenshell::instance_streamer<Reader>::instance_streamer(Reader* stream, ifcopenshell::file* f, ::logger& log)
ifcopenshell::instance_streamer<Reader>::instance_streamer(Reader* stream, ifcopenshell::file* f, ifcopenshell::logger& log)
: stream_(stream)
, owner_(f)
, token_stream_(3, token{})
@@ -2168,13 +2168,13 @@ std::optional<std::tuple<size_t, const ifcopenshell::declaration*, shared_pointe
try {
entity_type = schema_->declaration_by_name(token_stream_[2].as_string());
} catch (const exception& ex) {
logger_.get().message(::logger::LOG_ERROR, std::string(ex.what()) + " at offset " + std::to_string(token_stream_[2].start_pos));
logger_.get().message(ifcopenshell::logger::LOG_ERROR, std::string(ex.what()) + " at offset " + std::to_string(token_stream_[2].start_pos));
current_id = 0;
goto advance;
}
if (entity_type->as_entity() == nullptr) {
logger_.get().message(::logger::LOG_ERROR, "Non-entity type " + entity_type->name() + " at offset " + std::to_string(token_stream_[2].start_pos));
logger_.get().message(ifcopenshell::logger::LOG_ERROR, "Non-entity type " + entity_type->name() + " at offset " + std::to_string(token_stream_[2].start_pos));
current_id = 0;
goto advance;
}
@@ -2210,9 +2210,9 @@ std::optional<std::tuple<size_t, const ifcopenshell::declaration*, shared_pointe
try {
next_token = lexer_->next();
} catch (const exception& e) {
logger_.get().message(::logger::LOG_ERROR, std::string(e.what()) + ". Parsing terminated");
logger_.get().message(ifcopenshell::logger::LOG_ERROR, std::string(e.what()) + ". Parsing terminated");
} catch (...) {
logger_.get().message(::logger::LOG_ERROR, "Parsing terminated");
logger_.get().message(ifcopenshell::logger::LOG_ERROR, "Parsing terminated");
}
if (!lexer_->stream->eof() && !next_token) {
@@ -2268,7 +2268,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con
} else {
good_ = file_open_status::UNSUPPORTED_SCHEMA;
}
logger_.get().message(::logger::LOG_ERROR, "No support for file schema encountered (" + boost::algorithm::join(schemas, ", ") + ")");
logger_.get().message(ifcopenshell::logger::LOG_ERROR, "No support for file schema encountered (" + boost::algorithm::join(schemas, ", ") + ")");
return;
}
@@ -2293,11 +2293,11 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con
if (byguid_.find(guid) != byguid_.end()) {
std::stringstream ss;
ss << "Instance encountered with non-unique GlobalId " << guid;
logger_.get().message(::logger::LOG_WARNING, ss.str());
logger_.get().message(ifcopenshell::logger::LOG_WARNING, ss.str());
}
byguid_[guid] = instance;
} catch (const exception& ex) {
logger_.get().message(::logger::LOG_ERROR, ex.what());
logger_.get().message(ifcopenshell::logger::LOG_ERROR, ex.what());
}
}
@@ -2307,7 +2307,7 @@ void ifcopenshell::impl::in_memory_file_storage::read_from_stream(Reader* s, con
if (byid_.find(current_id) != byid_.end()) {
std::stringstream ss;
ss << "Overwriting instance with name #" << current_id;
logger_.get().message(::logger::LOG_WARNING, ss.str());
logger_.get().message(ifcopenshell::logger::LOG_WARNING, ss.str());
}
byid_.insert({(uint32_t)current_id, std::get<2>(*inst)});
@@ -2600,7 +2600,7 @@ express::base file::add_entity(const express::base& entity, int id) {
}
}
} catch (...) {
logger_.get().message(::logger::LOG_ERROR, "Failed to visit forward references of", entity);
logger_.get().message(ifcopenshell::logger::LOG_ERROR, "Failed to visit forward references of", entity);
}
// An instance is being added from another file. A copy of the
@@ -2729,11 +2729,11 @@ express::base file::add_entity(const express::base& entity, int id) {
if (byguid_.find(guid) != byguid_.end()) {
std::stringstream ss;
ss << "Overwriting entity with guid " << guid;
logger_.get().message(::logger::LOG_WARNING, ss.str());
logger_.get().message(ifcopenshell::logger::LOG_WARNING, ss.str());
}
byguid_.insert({ guid, new_entity });
} catch (const std::exception& ex) {
logger_.get().message(::logger::LOG_ERROR, ex.what());
logger_.get().message(ifcopenshell::logger::LOG_ERROR, ex.what());
}
}
*/
+2 -2
View File
@@ -52,7 +52,7 @@ template <typename Reader>
class IFC_PARSE_API spf_lexer {
private:
character_decoder<Reader>* decoder_;
::logger& logger_;
ifcopenshell::logger& logger_;
size_t skip_whitespace() const;
size_t skip_comment() const;
@@ -77,7 +77,7 @@ class IFC_PARSE_API spf_lexer {
Reader* stream;
// file* file;
spf_lexer(Reader* stream, ::logger& logger = ::logger::root());
spf_lexer(Reader* stream, ifcopenshell::logger& logger = ifcopenshell::logger::root());
token next();
~spf_lexer();
// void TokenString(size_t offset, std::string& result);
+2 -2
View File
@@ -36,10 +36,10 @@
#include <optional>
// Forward declarations
class instance_data;
namespace ifcopenshell {
class instance_data;
class declaration;
class type_declaration;
+2 -2
View File
@@ -12,7 +12,7 @@ using namespace ifcopenshell;
namespace {
shared_pointer_type make_header_entity(ifcopenshell::file* file, const ifcopenshell::entity& decl, ::logger& logger) {
shared_pointer_type make_header_entity(ifcopenshell::file* file, const ifcopenshell::entity& decl, ifcopenshell::logger& logger) {
static_cast<void>(logger);
const bool in_memory = file == nullptr || std::visit([](auto& storage) {
return std::is_same_v<std::decay_t<decltype(storage)>, ifcopenshell::impl::in_memory_file_storage>;
@@ -27,7 +27,7 @@ shared_pointer_type make_header_entity(ifcopenshell::file* file, const ifcopensh
} // namespace
ifcopenshell::spf_header::spf_header(ifcopenshell::file* file, ::logger* logger)
ifcopenshell::spf_header::spf_header(ifcopenshell::file* file, ifcopenshell::logger* logger)
: file_(file)
, logger_(logger_or_root(logger)) {
Header_section_schema::get_schema();
+3 -3
View File
@@ -32,19 +32,19 @@ class file;
class IFC_PARSE_API spf_header {
private:
ifcopenshell::file* file_;
std::reference_wrapper<::logger> logger_;
std::reference_wrapper<ifcopenshell::logger> logger_;
std::array<shared_pointer_type, 3> header_entities_;
public:
explicit spf_header(ifcopenshell::file* file = nullptr, ::logger* logger = nullptr);
explicit spf_header(ifcopenshell::file* file = nullptr, ifcopenshell::logger* logger = nullptr);
~spf_header();
void write(std::ostream& stream) const;
ifcopenshell::file* owner_file() { return file_; }
void owner_file(ifcopenshell::file* file);
::logger& logger() const { return logger_.get(); }
ifcopenshell::logger& logger() const { return logger_.get(); }
void set_file_description(const shared_pointer_type& description_data);
void set_file_name(const shared_pointer_type& name_data);
+4 -4
View File
@@ -123,10 +123,10 @@ private:
#endif
class mutable_attribute_value;
namespace ifcopenshell {
class mutable_attribute_value;
struct IFC_PARSE_API instance_reference {
int v;
size_t file_offset;
@@ -412,7 +412,7 @@ namespace ifcopenshell {
return std::move(read_simple_type_instances);
}
std::reference_wrapper<::logger> logger_;
std::reference_wrapper<ifcopenshell::logger> logger_;
// IfcParse::FileReader* stream;
// Either one of these needs to be set
@@ -429,7 +429,7 @@ namespace ifcopenshell {
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, ifcopenshell::logger& logger = ifcopenshell::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;
+3 -3
View File
@@ -131,19 +131,19 @@ void ifcopenshell::unescape_xml(std::string& str) {
boost::replace_all(str, "&gt;", ">");
}
void instance_data::populate_derived_() {
void ifcopenshell::instance_data::populate_derived_() {
if (auto* ent = declaration_->as_entity()) {
for (auto it = ent->derived().begin(); it != ent->derived().end(); ++it) {
if (*it) {
set_attribute_value(
std::distance(ent->derived().begin(), it),
derived{});
ifcopenshell::derived{});
}
}
}
}
attribute_value express::entity::get(const std::string& name) const {
ifcopenshell::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;