mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Introduce unique error codes
This commit is contained in:
@@ -412,7 +412,7 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
|
||||
} else if (cant) {
|
||||
result = mapAlignmentCantSegment(cant);
|
||||
} else {
|
||||
Logger::Error(std::string("Unexpected IfcAlignmentSegment subtype encountered"));
|
||||
Logger::Error("VAL", 8, std::string("Unexpected IfcAlignmentSegment subtype encountered"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -661,9 +661,9 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
|
||||
|
||||
result.first = curve_segment;
|
||||
} else if (type == Ifc4x3_add2::IfcAlignmentHorizontalSegmentTypeEnum::IfcAlignmentHorizontalSegmentType_VIENNESEBEND) {
|
||||
Logger::Warning(std::string("mapping of AlignmentHorizontalSegmentType VIENNESEBEND not supported"));
|
||||
Logger::Warning("UNS", 22, std::string("mapping of AlignmentHorizontalSegmentType VIENNESEBEND not supported"));
|
||||
} else {
|
||||
Logger::Error(std::string("unexpected AlignmentHorizontalSegmentType encountered"));
|
||||
Logger::Error("VAL", 9, std::string("unexpected AlignmentHorizontalSegmentType encountered"));
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -732,7 +732,7 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
|
||||
|
||||
result.first = curve_segment;
|
||||
} else if (type == Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_CLOTHOID) {
|
||||
Logger::Warning(std::string("mapping of AlignmentVerticalSegmentType CLOTHOID not supported"));
|
||||
Logger::Warning("UNS", 23, std::string("mapping of AlignmentVerticalSegmentType CLOTHOID not supported"));
|
||||
} else if (type == Ifc4x3_add2::IfcAlignmentVerticalSegmentTypeEnum::IfcAlignmentVerticalSegmentType_CIRCULARARC) {
|
||||
auto start_angle = atan(start_gradient);
|
||||
auto end_angle = atan(end_gradient);
|
||||
@@ -760,7 +760,7 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
|
||||
|
||||
result.first = curve_segment;
|
||||
} else {
|
||||
Logger::Error(std::string("unexpected AlignmentVerticalSegmentType encountered"));
|
||||
Logger::Error("VAL", 10, std::string("unexpected AlignmentVerticalSegmentType encountered"));
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -770,21 +770,21 @@ std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> mapAlign
|
||||
std::pair<Ifc4x3_add2::IfcCurveSegment*, Ifc4x3_add2::IfcCurveSegment*> result(nullptr, nullptr);
|
||||
auto type = segment->PredefinedType();
|
||||
if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_BLOSSCURVE) {
|
||||
Logger::Warning(std::string("mapping of AlignmentCantSegmentType BLOSSCURVE not supported"));
|
||||
Logger::Warning("UNS", 24, std::string("mapping of AlignmentCantSegmentType BLOSSCURVE not supported"));
|
||||
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_CONSTANTCANT) {
|
||||
Logger::Warning(std::string("mapping of AlignmentCantSegmentType CONSTANTCANT not supported"));
|
||||
Logger::Warning("UNS", 25, std::string("mapping of AlignmentCantSegmentType CONSTANTCANT not supported"));
|
||||
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_COSINECURVE) {
|
||||
Logger::Warning(std::string("mapping of AlignmentCantSegmentType COSINECURVE not supported"));
|
||||
Logger::Warning("UNS", 26, std::string("mapping of AlignmentCantSegmentType COSINECURVE not supported"));
|
||||
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_HELMERTCURVE) {
|
||||
Logger::Warning(std::string("mapping of AlignmentCantSegmentType HELMERTCURVE not supported"));
|
||||
Logger::Warning("UNS", 27, std::string("mapping of AlignmentCantSegmentType HELMERTCURVE not supported"));
|
||||
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_LINEARTRANSITION) {
|
||||
Logger::Warning(std::string("mapping of AlignmentCantSegmentType LINEARTRANSTION not supported"));
|
||||
Logger::Warning("UNS", 28, std::string("mapping of AlignmentCantSegmentType LINEARTRANSTION not supported"));
|
||||
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_SINECURVE) {
|
||||
Logger::Warning(std::string("mapping of AlignmentCantSegmentType SINECURVE not supported"));
|
||||
Logger::Warning("UNS", 29, std::string("mapping of AlignmentCantSegmentType SINECURVE not supported"));
|
||||
} else if (type == Ifc4x3_add2::IfcAlignmentCantSegmentTypeEnum::IfcAlignmentCantSegmentType_VIENNESEBEND) {
|
||||
Logger::Warning(std::string("mapping of AlignmentCantSegmentType VIENNESEBEND not supported"));
|
||||
Logger::Warning("UNS", 30, std::string("mapping of AlignmentCantSegmentType VIENNESEBEND not supported"));
|
||||
} else {
|
||||
Logger::Error(std::string("unexpected AlignmentCantSegmentType encountered"));
|
||||
Logger::Error("VAL", 11, std::string("unexpected AlignmentCantSegmentType encountered"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace {
|
||||
parse_state += PAGE;
|
||||
} else if (IS_HEXADECIMAL(current_char) && EXPECTS_HEX(parse_state)) {
|
||||
if (IS_LOWERCASE_HEX(current_char)) {
|
||||
Logger::Warning("Lowercase hexadecimal character '" + std::string(1, current_char) +
|
||||
Logger::Warning("SYN", 2, "Lowercase hexadecimal character '" + std::string(1, current_char) +
|
||||
"' found at offset " + std::to_string(stream_.tell()) +
|
||||
". It is recommended to use uppercase for hexadecimal.");
|
||||
}
|
||||
|
||||
+11
-11
@@ -72,10 +72,10 @@ namespace {
|
||||
try {
|
||||
fn(EnumerationReference(decl->as_enumeration_type(), decl->as_enumeration_type()->lookup_enum_offset(s)));
|
||||
} catch (IfcParse::IfcException& e) {
|
||||
Logger::Error("An enumeration literal '" + s + "' is not valid for type '" + decl->name() + "' at offset " + std::to_string(t.startPos));
|
||||
Logger::Error("VAL", 12, "An enumeration literal '" + s + "' is not valid for type '" + decl->name() + "' at offset " + std::to_string(t.startPos));
|
||||
}
|
||||
} else {
|
||||
Logger::Error("An enumeration literal '" + s + "' is not expected at attribute index '" + std::to_string(attribute_id) + "' at offset " + std::to_string(t.startPos));
|
||||
Logger::Error("VAL", 13, "An enumeration literal '" + s + "' is not expected at attribute index '" + std::to_string(attribute_id) + "' at offset " + std::to_string(t.startPos));
|
||||
}
|
||||
} else if (t.type == IfcParse::Token_FLOAT) {
|
||||
fn(IfcParse::TokenFunc::asFloat(t));
|
||||
@@ -194,7 +194,7 @@ namespace {
|
||||
}
|
||||
}, aggregate_storage);
|
||||
|
||||
Logger::Error("Inconsistent aggregate valuation while attempting to append " + std::string(typeid(decltype(v)).name()) + " to an aggregate of " + current);
|
||||
Logger::Error("VAL", 14, "Inconsistent aggregate valuation while attempting to append " + std::string(typeid(decltype(v)).name()) + " to an aggregate of " + current);
|
||||
|
||||
// @todo boolean -> logical upgrade
|
||||
// wait a second... there are no aggregate of bool / logical in the schema..
|
||||
@@ -213,7 +213,7 @@ namespace {
|
||||
}
|
||||
} else {
|
||||
// @todo would be cool if we can trace this back to file offset
|
||||
Logger::Error(std::string("Aggregates of ") + typeid(decltype(v)).name() + " are not supported in the IfcOpenShell parser");
|
||||
Logger::Error("UNS", 31, std::string("Aggregates of ") + typeid(decltype(v)).name() + " are not supported in the IfcOpenShell parser");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -263,9 +263,9 @@ IfcEntityInstanceData IfcParse::parse_context::construct(boost::optional<size_t>
|
||||
{
|
||||
size_t expected = expected_size ? *expected_size : parameter_types.size();
|
||||
if (decl != nullptr && decl->schema() == &Header_section_schema::get_schema()) {
|
||||
Logger::Warning("Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + " for header entity " + decl->name());
|
||||
Logger::Warning("VAL", 15, "Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + " for header entity " + decl->name());
|
||||
} else {
|
||||
Logger::Warning("Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + (name ? std::string(" for instance #" + std::to_string(*name)) : std::string("")));
|
||||
Logger::Warning("VAL", 16, "Expected " + std::to_string(expected) + " attribute values, found " + std::to_string(tokens_.size()) + (name ? std::string(" for instance #" + std::to_string(*name)) : std::string("")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,13 +719,13 @@ std::optional<std::tuple<size_t, const IfcParse::declaration*, IfcEntityInstance
|
||||
try {
|
||||
entity_type = schema_->declaration_by_name(TokenFunc::asStringRef(token_stream_[2]));
|
||||
} catch (const IfcException& ex) {
|
||||
Logger::Message(Logger::LOG_ERROR, std::string(ex.what()) + " at offset " + std::to_string(token_stream_[2].startPos));
|
||||
Logger::Message(Logger::LOG_ERROR, "SYN", 3, std::string(ex.what()) + " at offset " + std::to_string(token_stream_[2].startPos));
|
||||
current_id = 0;
|
||||
goto advance;
|
||||
}
|
||||
|
||||
if (entity_type->as_entity() == nullptr) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Non entity type " + entity_type->name() + " at offset " + std::to_string(token_stream_[2].startPos));
|
||||
Logger::Message(Logger::LOG_ERROR, "SYN", 4, "Non entity type " + entity_type->name() + " at offset " + std::to_string(token_stream_[2].startPos));
|
||||
goto advance;
|
||||
}
|
||||
|
||||
@@ -744,7 +744,7 @@ std::optional<std::tuple<size_t, const IfcParse::declaration*, IfcEntityInstance
|
||||
storage_.load(current_id, entity_type->as_entity(), ps, -1);
|
||||
} catch (const IfcInvalidTokenException& e) {
|
||||
good_ = file_open_status::INVALID_SYNTAX;
|
||||
Logger::Error(e);
|
||||
Logger::Error("SYN", 5, e);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -769,9 +769,9 @@ std::optional<std::tuple<size_t, const IfcParse::declaration*, IfcEntityInstance
|
||||
try {
|
||||
next_token = lexer_->Next();
|
||||
} catch (const IfcException& e) {
|
||||
Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + ". Parsing terminated");
|
||||
Logger::Message(Logger::LOG_ERROR, "SYN", 6, std::string(e.what()) + ". Parsing terminated");
|
||||
} catch (...) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Parsing terminated");
|
||||
Logger::Message(Logger::LOG_ERROR, "SYN", 7, "Parsing terminated");
|
||||
}
|
||||
|
||||
if (!lexer_->stream->eof() && next_token.type == Token_NONE) {
|
||||
|
||||
@@ -111,7 +111,7 @@ IfcParse::IfcGlobalId::IfcGlobalId() {
|
||||
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, "Internal error generating GlobalId");
|
||||
Logger::Message(Logger::LOG_ERROR, "SYS", 34, "Internal error generating GlobalId");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -130,7 +130,7 @@ IfcParse::IfcGlobalId::IfcGlobalId(const std::string& string)
|
||||
#ifndef NDEBUG
|
||||
const std::string test_string = compress(&uuid_data_.data[0]);
|
||||
if (string_data_ != test_string) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Internal error generating GlobalId");
|
||||
Logger::Message(Logger::LOG_ERROR, "SYS", 35, "Internal error generating GlobalId");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ void IfcHierarchyHelper<Schema>::relatePlacements(typename Schema::IfcProduct* p
|
||||
if (local_place != parent->ObjectPlacement()) {
|
||||
local_place->setPlacementRelTo(parent->ObjectPlacement());
|
||||
} else {
|
||||
Logger::Notice("Placement cannot be relative to self");
|
||||
Logger::Notice("SYN", 8, "Placement cannot be relative to self");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,9 +454,9 @@ class IFC_PARSE_API IfcHierarchyHelper : public IfcParse::IfcFile {
|
||||
break;
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SYN", 9, e);
|
||||
} catch (...) {
|
||||
Logger::Error("Unknown error in addRelatedObject()");
|
||||
Logger::Error("SYN", 10, "Unknown error in addRelatedObject()");
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
|
||||
+21
-11
@@ -62,9 +62,16 @@ const std::array<std::basic_string<char>, 5> severity_strings<char>::value = {"P
|
||||
template <>
|
||||
const std::array<std::basic_string<wchar_t>, 5> severity_strings<wchar_t>::value = {L"Performance", L"Debug", L"Notice", L"Warning", L"Error"};
|
||||
|
||||
std::string format_code(const char (&code_prefix)[4], uint16_t code_number) {
|
||||
std::ostringstream oss;
|
||||
oss << code_prefix[0] << code_prefix[1] << code_prefix[2] << std::setfill('0') << std::setw(3) << code_number;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void plain_text_message(T& out, const IfcUtil::IfcBaseClass* current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||
void plain_text_message(T& out, const IfcUtil::IfcBaseClass* current_product, Logger::Severity type, const std::string& code, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||
out << "[" << severity_strings<typename T::char_type>::value[type] << "] ";
|
||||
out << "[" << code.c_str() << "] ";
|
||||
out << "[" << get_time(type <= Logger::LOG_PERF).c_str() << "] ";
|
||||
if (current_product) {
|
||||
std::string global_id = current_product->as<IfcUtil::IfcBaseEntity>()->get("GlobalId");
|
||||
@@ -90,17 +97,19 @@ std::basic_string<T> string_as(const std::string& string) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void json_message(T& out, const IfcUtil::IfcBaseClass* current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||
void json_message(T& out, const IfcUtil::IfcBaseClass* current_product, Logger::Severity type, const std::string& code, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||
boost::property_tree::basic_ptree<std::basic_string<typename T::char_type>, std::basic_string<typename T::char_type>> property_tree;
|
||||
|
||||
// @todo this is crazy
|
||||
static const typename T::char_type time_string[] = {'t', 'i', 'm', 'e', 0};
|
||||
static const typename T::char_type level_string[] = {'l', 'e', 'v', 'e', 'l', 0};
|
||||
static const typename T::char_type code_string[] = {'c', 'o', 'd', 'e', 0};
|
||||
static const typename T::char_type product_string[] = {'p', 'r', 'o', 'd', 'u', 'c', 't', 0};
|
||||
static const typename T::char_type message_string[] = {'m', 'e', 's', 's', 'a', 'g', 'e', 0};
|
||||
static const typename T::char_type instance_string[] = {'i', 'n', 's', 't', 'a', 'n', 'c', 'e', 0};
|
||||
|
||||
property_tree.put(level_string, severity_strings<typename T::char_type>::value[type]);
|
||||
property_tree.put(code_string, string_as<typename T::char_type>(code));
|
||||
if (current_product) {
|
||||
std::ostringstream oss;
|
||||
current_product->toString(oss);
|
||||
@@ -127,7 +136,7 @@ void json_message(T& out, const IfcUtil::IfcBaseClass* current_product, Logger::
|
||||
|
||||
void Logger::SetProduct(boost::optional<const IfcUtil::IfcBaseClass*> product) {
|
||||
if (verbosity_ <= LOG_DEBUG && product) {
|
||||
Message(LOG_DEBUG, "Begin processing", *product);
|
||||
Message(LOG_DEBUG, "SYS", 3, "Begin processing", *product);
|
||||
}
|
||||
if (!product && print_perf_stats_on_element_) {
|
||||
PrintPerformanceStats();
|
||||
@@ -154,13 +163,14 @@ void Logger::SetOutput(std::wostream* stream1, std::wostream* stream2) {
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::Message(Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||
void Logger::Message(Logger::Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||
if (type < verbosity_) {
|
||||
return;
|
||||
}
|
||||
|
||||
static std::mutex mtx;
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
const std::string code = format_code(code_prefix, code_number);
|
||||
|
||||
if (type == LOG_PERF) {
|
||||
if (!first_timepoint_) {
|
||||
@@ -181,22 +191,22 @@ void Logger::Message(Logger::Severity type, const std::string& message, const If
|
||||
if (((log2_ != nullptr) || (wlog2_ != nullptr))) {
|
||||
if (format_ == FMT_PLAIN) {
|
||||
if (log2_ != nullptr) {
|
||||
plain_text_message(*log2_, current_product_, type, message, instance);
|
||||
plain_text_message(*log2_, current_product_, type, code, message, instance);
|
||||
} else if (wlog2_ != nullptr) {
|
||||
plain_text_message(*wlog2_, current_product_, type, message, instance);
|
||||
plain_text_message(*wlog2_, current_product_, type, code, message, instance);
|
||||
}
|
||||
} else if (format_ == FMT_JSON) {
|
||||
if (log2_ != nullptr) {
|
||||
json_message(*log2_, current_product_, type, message, instance);
|
||||
json_message(*log2_, current_product_, type, code, message, instance);
|
||||
} else if (wlog2_ != nullptr) {
|
||||
json_message(*wlog2_, current_product_, type, message, instance);
|
||||
json_message(*wlog2_, current_product_, type, code, message, instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::Message(Logger::Severity type, const std::exception& exception, const IfcUtil::IfcBaseInterface* 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::exception& exception, const IfcUtil::IfcBaseInterface* instance) {
|
||||
Message(type, code_prefix, code_number, std::string(exception.what()), instance);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -243,7 +253,7 @@ void Logger::PrintPerformanceStats() {
|
||||
|
||||
for (auto& item : items) {
|
||||
auto message = item.second + std::string(max_size - item.second.size(), ' ') + ": " + std::to_string(item.first);
|
||||
Message(LOG_PERF, message);
|
||||
Message(LOG_PERF, "SYS", 4, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-10
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/scope_exit.hpp>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
@@ -84,16 +85,16 @@ class IFC_PARSE_API Logger {
|
||||
static Format OutputFormat();
|
||||
|
||||
/// Log a message to the output stream
|
||||
static void Message(Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0);
|
||||
static void Message(Severity type, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0);
|
||||
static void Message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0);
|
||||
static void Message(Severity type, const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0);
|
||||
|
||||
static void Notice(const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, message, instance); }
|
||||
static void Warning(const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, message, instance); }
|
||||
static void Error(const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, message, instance); }
|
||||
static void Notice(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, code_prefix, code_number, message, instance); }
|
||||
static void Warning(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, code_prefix, code_number, message, instance); }
|
||||
static void Error(const char (&code_prefix)[4], uint16_t code_number, const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, code_prefix, code_number, message, instance); }
|
||||
|
||||
static void Notice(const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, exception, instance); }
|
||||
static void Warning(const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, exception, instance); }
|
||||
static void Error(const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, exception, instance); }
|
||||
static void Notice(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_NOTICE, code_prefix, code_number, exception, instance); }
|
||||
static void Warning(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, code_prefix, code_number, exception, instance); }
|
||||
static void Error(const char (&code_prefix)[4], uint16_t code_number, const std::exception& exception, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_ERROR, code_prefix, code_number, exception, instance); }
|
||||
|
||||
static void Status(const std::string& message, bool new_line = true);
|
||||
|
||||
@@ -105,10 +106,10 @@ class IFC_PARSE_API Logger {
|
||||
|
||||
#define PERF(x) \
|
||||
\
|
||||
Logger::Message(Logger::LOG_PERF, x); \
|
||||
Logger::Message(Logger::LOG_PERF, "SYS", 1, x); \
|
||||
\
|
||||
BOOST_SCOPE_EXIT(void) { \
|
||||
Logger::Message(Logger::LOG_PERF, "done " + std::string(x)); \
|
||||
Logger::Message(Logger::LOG_PERF, "SYS", 2, "done " + std::string(x)); \
|
||||
} \
|
||||
BOOST_SCOPE_EXIT_END
|
||||
|
||||
|
||||
+21
-21
@@ -320,7 +320,7 @@ Token IfcParse::GeneralTokenPtr(IfcSpfLexer* lexer, size_t start, const std::str
|
||||
if (first == '#') {
|
||||
token.type = Token_IDENTIFIER;
|
||||
if (!ParseInt(tokenStr.c_str() + 1, token.value_int)) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Token '" + tokenStr + "' at offset " + std::to_string(token.startPos) + " is not valid");
|
||||
Logger::Message(Logger::LOG_ERROR, "SYN", 11, "Token '" + tokenStr + "' at offset " + std::to_string(token.startPos) + " is not valid");
|
||||
token.type = Token_OPERATOR;
|
||||
token.value_char = '$';
|
||||
}
|
||||
@@ -568,7 +568,7 @@ void IfcParse::impl::in_memory_file_storage::load(boost::optional<size_t> entity
|
||||
context.push(simple_type_instance);
|
||||
simple_type_instance->file_ = file;
|
||||
} catch (IfcException& e) {
|
||||
Logger::Message(Logger::LOG_ERROR, std::string(e.what()) + " at offset " + std::to_string(next.startPos));
|
||||
Logger::Message(Logger::LOG_ERROR, "SYN", 12, std::string(e.what()) + " at offset " + std::to_string(next.startPos));
|
||||
// #4070 We didn't actually capture an aggregate entry, undo length increment.
|
||||
return_value--;
|
||||
}
|
||||
@@ -663,7 +663,7 @@ void IfcParse::impl::rocks_db_file_storage::unregister_inverse(unsigned id_from,
|
||||
if (it != vals.end()) {
|
||||
vals.erase(it);
|
||||
} else {
|
||||
Logger::Error("Unregistering non-existant inverse #" + std::to_string(id_from) + " on instance #" + std::to_string(inst_id) + " at attribute " + std::to_string(attribute_index));
|
||||
Logger::Error("VAL", 17, "Unregistering non-existant inverse #" + std::to_string(id_from) + " on instance #" + std::to_string(inst_id) + " at attribute " + std::to_string(attribute_index));
|
||||
}
|
||||
s.resize(vals.size() * sizeof(uint32_t));
|
||||
memcpy(s.data(), vals.data(), s.size());
|
||||
@@ -1122,7 +1122,7 @@ IfcUtil::IfcBaseClass::set_attribute_value(size_t i, const T& t) {
|
||||
}
|
||||
}
|
||||
} catch (IfcParse::IfcException& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SYN", 13, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1159,11 +1159,11 @@ IfcUtil::IfcBaseClass::set_attribute_value(size_t i, const T& t) {
|
||||
auto guid = (std::string) new_attribute;
|
||||
auto it = file_->internal_guid_map().find(guid);
|
||||
if (it != file_->internal_guid_map().end()) {
|
||||
Logger::Warning("Duplicate guid " + guid);
|
||||
Logger::Warning("VAL", 18, "Duplicate guid " + guid);
|
||||
}
|
||||
file_->internal_guid_map().insert({ guid, this });
|
||||
} catch (IfcParse::IfcException& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SYN", 14, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1531,12 +1531,12 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
||||
schema = IfcParse::schema_by_name(schemas.front());
|
||||
} catch (const IfcParse::IfcException& e) {
|
||||
good_ = file_open_status::UNSUPPORTED_SCHEMA;
|
||||
Logger::Error(e);
|
||||
Logger::Error("SYN", 15, e);
|
||||
}
|
||||
}
|
||||
|
||||
if (schema == nullptr) {
|
||||
Logger::Message(Logger::LOG_ERROR, "No support for file schema encountered (" + boost::algorithm::join(schemas, ", ") + ")");
|
||||
Logger::Message(Logger::LOG_ERROR, "UNS", 32, "No support for file schema encountered (" + boost::algorithm::join(schemas, ", ") + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1569,11 +1569,11 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
||||
if (byguid_.find(guid) != byguid_.end()) {
|
||||
std::stringstream ss;
|
||||
ss << "Instance encountered with non-unique GlobalId " << guid;
|
||||
Logger::Message(Logger::LOG_WARNING, ss.str());
|
||||
Logger::Message(Logger::LOG_WARNING, "SYN", 16, ss.str());
|
||||
}
|
||||
byguid_[guid] = instance;
|
||||
} catch (const IfcException& ex) {
|
||||
Logger::Message(Logger::LOG_ERROR, ex.what());
|
||||
Logger::Message(Logger::LOG_ERROR, "SYN", 17, ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1589,7 +1589,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
||||
if (byid_.find(current_id) != byid_.end()) {
|
||||
std::stringstream ss;
|
||||
ss << "Overwriting instance with name #" << current_id;
|
||||
Logger::Message(Logger::LOG_WARNING, ss.str());
|
||||
Logger::Message(Logger::LOG_WARNING, "SYN", 18, ss.str());
|
||||
}
|
||||
|
||||
// byidentity_[instance->identity()] = instance;
|
||||
@@ -1632,7 +1632,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
||||
}
|
||||
auto it = byid_.find(*name);
|
||||
if (it == byid_.end()) {
|
||||
Logger::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));
|
||||
Logger::Error("SYN", 19, "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 {
|
||||
auto* storage = &byid_[p.first.name_]->data();
|
||||
auto attr_index = p.first.index_;
|
||||
@@ -1649,7 +1649,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
||||
if (storage->has_attribute_value<Blank>(nullptr, nullptr, 0, attr_index)) {
|
||||
storage->set_attribute_value(nullptr, nullptr, 0, attr_index, it->second);
|
||||
} else {
|
||||
Logger::Error("Duplicate definition for instance reference");
|
||||
Logger::Error("SYN", 20, "Duplicate definition for instance reference");
|
||||
}
|
||||
}
|
||||
} else if (auto* inst = std::get_if<IfcUtil::IfcBaseClass*>(v)) {
|
||||
@@ -1665,7 +1665,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
||||
}
|
||||
auto it = byid_.find(*name);
|
||||
if (it == byid_.end()) {
|
||||
Logger::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));
|
||||
Logger::Error("SYN", 21, "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(it->second);
|
||||
}
|
||||
@@ -1689,7 +1689,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
||||
if (storage->has_attribute_value<Blank>(nullptr, nullptr, 0, attr_index)) {
|
||||
storage->set_attribute_value(nullptr, nullptr, 0, attr_index, instances);
|
||||
} else {
|
||||
Logger::Error("Duplicate definition for instance reference");
|
||||
Logger::Error("SYN", 22, "Duplicate definition for instance reference");
|
||||
}
|
||||
} else if (auto* vvv = std::get_if<std::vector<std::vector<reference_or_simple_type>>>(&p.second)) {
|
||||
aggregate_of_aggregate_of_instance::ptr instances(new aggregate_of_aggregate_of_instance);
|
||||
@@ -1702,7 +1702,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
||||
}
|
||||
auto it = byid_.find(*name);
|
||||
if (it == byid_.end()) {
|
||||
Logger::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));
|
||||
Logger::Error("SYN", 23, "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(it->second);
|
||||
}
|
||||
@@ -1728,7 +1728,7 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
|
||||
if (storage->has_attribute_value<Blank>(nullptr, nullptr, 0, attr_index)) {
|
||||
storage->set_attribute_value(nullptr, nullptr, 0, attr_index, instances);
|
||||
} else {
|
||||
Logger::Error("Duplicate definition for instance reference");
|
||||
Logger::Error("SYN", 24, "Duplicate definition for instance reference");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1893,7 +1893,7 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Failed to visit forward references of", entity);
|
||||
Logger::Message(Logger::LOG_ERROR, "SYN", 25, "Failed to visit forward references of", entity);
|
||||
}
|
||||
|
||||
// See whether the instance is already part of a file
|
||||
@@ -2066,11 +2066,11 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
|
||||
if (byguid_.find(guid) != byguid_.end()) {
|
||||
std::stringstream ss;
|
||||
ss << "Overwriting entity with guid " << guid;
|
||||
Logger::Message(Logger::LOG_WARNING, ss.str());
|
||||
Logger::Message(Logger::LOG_WARNING, "SYN", 26, ss.str());
|
||||
}
|
||||
byguid_.insert({ guid, new_entity });
|
||||
} catch (const std::exception& ex) {
|
||||
Logger::Message(Logger::LOG_ERROR, ex.what());
|
||||
Logger::Message(Logger::LOG_ERROR, "SYN", 27, ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2243,7 +2243,7 @@ void IfcFile::process_deletion_(IfcUtil::IfcBaseClass* entity) {
|
||||
if (it != byguid_.end()) {
|
||||
byguid_.erase(it);
|
||||
} else {
|
||||
Logger::Warning("GlobalId on rooted instance not encountered in map");
|
||||
Logger::Warning("VAL", 19, "GlobalId on rooted instance not encountered in map");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ bool IfcSpfHeader::tryRead() {
|
||||
read();
|
||||
return true;
|
||||
} catch (const std::exception& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SYN", 28, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ boost::any parse_attribute_value(const IfcParse::parameter_type* ty, const std::
|
||||
}
|
||||
|
||||
if (any.empty()) {
|
||||
Logger::Error("Attribute '" + value + "' not successfully parsed");
|
||||
Logger::Error("SYN", 29, "Attribute '" + value + "' not successfully parsed");
|
||||
}
|
||||
|
||||
return any;
|
||||
@@ -293,7 +293,7 @@ static void end_element(void* user, const xmlChar* tag) {
|
||||
// ignore uos ex:iso_10303_28 (ifc2x3) and ifc:ifcXML (ifc4)
|
||||
if (tagname != "uos" && tagname != "ex:iso_10303_28" && tagname != "ifc:ifcXML" && tagname != "ifcXML") {
|
||||
if (state->stack.empty()) {
|
||||
Logger::Error("Mismatch in parse stack due to previous errors");
|
||||
Logger::Error("SYN", 30, "Mismatch in parse stack due to previous errors");
|
||||
} else {
|
||||
state->stack.pop_back();
|
||||
}
|
||||
@@ -320,7 +320,7 @@ static void process_characters(void* user, const xmlChar* character, int len) {
|
||||
try {
|
||||
val = parse_attribute_value(pt, txt);
|
||||
} catch (const std::exception& e) {
|
||||
Logger::Error(e, state->stack.back().inst());
|
||||
Logger::Error("SYN", 31, e, state->stack.back().inst());
|
||||
}
|
||||
if (!val.empty()) {
|
||||
// type declaration always at idx 0
|
||||
@@ -348,7 +348,7 @@ static void process_characters(void* user, const xmlChar* character, int len) {
|
||||
} else if (tagname == "documentation") {
|
||||
header.file_description()->setdescription({txt});
|
||||
} else {
|
||||
Logger::Error("Unrecognized header entry " + tagname);
|
||||
Logger::Error("SYN", 32, "Unrecognized header entry " + tagname);
|
||||
}
|
||||
} else if (state_type == stack_node::node_instance_attribute) {
|
||||
const auto* pt = state->stack.back().inst()->declaration().as_entity()->attribute_by_index(state->stack.back().idx())->type_of_attribute();
|
||||
@@ -498,7 +498,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
|
||||
}, val);
|
||||
}
|
||||
} else {
|
||||
Logger::Error("Unknown attribute '" + pair.first + "' on entity '" + entity->name() + "' with value '" + pair.second + "'");
|
||||
Logger::Error("SYN", 33, "Unknown attribute '" + pair.first + "' on entity '" + entity->name() + "' with value '" + pair.second + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -556,7 +556,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
|
||||
try {
|
||||
decl = state->file->schema()->declaration_by_name(tagname_copy);
|
||||
} catch (const std::exception& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SYN", 34, e);
|
||||
}
|
||||
if (decl != nullptr) {
|
||||
auto inst_or_ref = create_instance(decl);
|
||||
@@ -571,7 +571,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
|
||||
} else if (state_type == stack_node::node_instance) {
|
||||
const IfcParse::entity* current = state->stack.back().inst()->declaration().as_entity();
|
||||
if (current == nullptr) {
|
||||
Logger::Error("'" + state->stack.back().inst()->declaration().name() + "' is not an entity, unable to set attribute '" + tagname + "'");
|
||||
Logger::Error("SYN", 35, "'" + state->stack.back().inst()->declaration().name() + "' is not an entity, unable to set attribute '" + tagname + "'");
|
||||
// We need to push something on the stack. Likely there has been some extra indirection that is not understood.
|
||||
state->stack.push_back(state->stack.back());
|
||||
} else {
|
||||
@@ -582,7 +582,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
|
||||
return attr->name() == tagname;
|
||||
});
|
||||
if (found == inverses.end()) {
|
||||
Logger::Error("Unknown attribute " + tagname);
|
||||
Logger::Error("SYN", 36, "Unknown attribute " + tagname);
|
||||
state->stack.push_back(state->stack.back());
|
||||
} else {
|
||||
if ((*found)->bound1() == 0 && (*found)->bound2() == 1) {
|
||||
@@ -595,7 +595,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
|
||||
inst->set_attribute_value(idx, state->stack.back().inst());
|
||||
state->stack.push_back(stack_node::instance(id, inst));
|
||||
} else {
|
||||
Logger::Error("Unknown attribute " + tagname);
|
||||
Logger::Error("SYN", 37, "Unknown attribute " + tagname);
|
||||
state->stack.push_back(state->stack.back());
|
||||
}
|
||||
} else {
|
||||
@@ -642,7 +642,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
|
||||
try {
|
||||
decl = state->file->schema()->declaration_by_name(tagname);
|
||||
} catch (const std::exception& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SYN", 38, e);
|
||||
}
|
||||
|
||||
if (decl == nullptr) {
|
||||
@@ -651,7 +651,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
|
||||
|
||||
const IfcParse::entity* entity = decl->as_entity();
|
||||
if ((entity == nullptr) && state_type != stack_node::node_instance_attribute) {
|
||||
Logger::Error("Not an entity definition " + tagname);
|
||||
Logger::Error("SYN", 39, "Not an entity definition " + tagname);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -665,7 +665,7 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
|
||||
if (inst != nullptr) {
|
||||
inst->set_attribute_value(idx, state->stack.back().inst());
|
||||
} else {
|
||||
Logger::Error("Internal error, inverse attribute not processed");
|
||||
Logger::Error("SYN", 40, "Internal error, inverse attribute not processed");
|
||||
}
|
||||
} else if (state_type == stack_node::node_instance_attribute) {
|
||||
state->stack.back().inst()->set_attribute_value(state->stack.back().idx(), inst);
|
||||
|
||||
Reference in New Issue
Block a user