mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
ifcparse: fix clang-tidy warning readability-identifier-length
This commit is contained in:
committed by
Thomas Krijnen
parent
eea9a14722
commit
47a2971c65
@@ -38,7 +38,7 @@ class IfcBaseClass;
|
|||||||
IFC_PARSE_API const char* ArgumentTypeToString(ArgumentType argument_type);
|
IFC_PARSE_API const char* ArgumentTypeToString(ArgumentType argument_type);
|
||||||
|
|
||||||
/// Returns false when the string `s` contains character outside of {'0', '1'}
|
/// Returns false when the string `s` contains character outside of {'0', '1'}
|
||||||
IFC_PARSE_API bool valid_binary_string(const std::string& s);
|
IFC_PARSE_API bool valid_binary_string(const std::string& string);
|
||||||
} // namespace IfcUtil
|
} // namespace IfcUtil
|
||||||
|
|
||||||
class IFC_PARSE_API Argument {
|
class IFC_PARSE_API Argument {
|
||||||
@@ -65,7 +65,7 @@ class IFC_PARSE_API Argument {
|
|||||||
virtual unsigned int size() const = 0;
|
virtual unsigned int size() const = 0;
|
||||||
|
|
||||||
virtual IfcUtil::ArgumentType type() const = 0;
|
virtual IfcUtil::ArgumentType type() const = 0;
|
||||||
virtual Argument* operator[](unsigned int i) const = 0;
|
virtual Argument* operator[](unsigned int index) const = 0;
|
||||||
virtual std::string toString(bool upper = false) const = 0;
|
virtual std::string toString(bool upper = false) const = 0;
|
||||||
|
|
||||||
virtual ~Argument(){};
|
virtual ~Argument(){};
|
||||||
|
|||||||
+12
-12
@@ -61,11 +61,11 @@ class IFC_PARSE_API IfcBaseInterface {
|
|||||||
if (is_null(this)) {
|
if (is_null(this)) {
|
||||||
return static_cast<T*>(0);
|
return static_cast<T*>(0);
|
||||||
}
|
}
|
||||||
auto t = dynamic_cast<T*>(this);
|
auto type = dynamic_cast<T*>(this);
|
||||||
if (do_throw && !t) {
|
if (do_throw && !type) {
|
||||||
raise_error_on_concrete_class<T>();
|
raise_error_on_concrete_class<T>();
|
||||||
}
|
}
|
||||||
return t;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -73,11 +73,11 @@ class IFC_PARSE_API IfcBaseInterface {
|
|||||||
if (is_null(this)) {
|
if (is_null(this)) {
|
||||||
return static_cast<const T*>(0);
|
return static_cast<const T*>(0);
|
||||||
}
|
}
|
||||||
auto t = dynamic_cast<const T*>(this);
|
auto type = dynamic_cast<const T*>(this);
|
||||||
if (do_throw && !t) {
|
if (do_throw && !type) {
|
||||||
raise_error_on_concrete_class<T>();
|
raise_error_on_concrete_class<T>();
|
||||||
}
|
}
|
||||||
return t;
|
return type;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -96,13 +96,13 @@ class IFC_PARSE_API IfcBaseClass : public virtual IfcBaseInterface {
|
|||||||
public:
|
public:
|
||||||
IfcBaseClass() : identity_(counter_++),
|
IfcBaseClass() : identity_(counter_++),
|
||||||
data_(0) {}
|
data_(0) {}
|
||||||
IfcBaseClass(IfcEntityInstanceData* d) : identity_(counter_++),
|
IfcBaseClass(IfcEntityInstanceData* data) : identity_(counter_++),
|
||||||
data_(d) {}
|
data_(data) {}
|
||||||
virtual ~IfcBaseClass() { delete data_; }
|
virtual ~IfcBaseClass() { delete data_; }
|
||||||
|
|
||||||
const IfcEntityInstanceData& data() const { return *data_; }
|
const IfcEntityInstanceData& data() const { return *data_; }
|
||||||
IfcEntityInstanceData& data() { return *data_; }
|
IfcEntityInstanceData& data() { return *data_; }
|
||||||
void data(IfcEntityInstanceData* d);
|
void data(IfcEntityInstanceData* data);
|
||||||
|
|
||||||
virtual const IfcParse::declaration& declaration() const = 0;
|
virtual const IfcParse::declaration& declaration() const = 0;
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ class IFC_PARSE_API IfcLateBoundEntity : public IfcBaseClass {
|
|||||||
class IFC_PARSE_API IfcBaseEntity : public IfcBaseClass {
|
class IFC_PARSE_API IfcBaseEntity : public IfcBaseClass {
|
||||||
public:
|
public:
|
||||||
IfcBaseEntity() : IfcBaseClass() {}
|
IfcBaseEntity() : IfcBaseClass() {}
|
||||||
IfcBaseEntity(IfcEntityInstanceData* d) : IfcBaseClass(d) {}
|
IfcBaseEntity(IfcEntityInstanceData* data) : IfcBaseClass(data) {}
|
||||||
|
|
||||||
virtual const IfcParse::entity& declaration() const = 0;
|
virtual const IfcParse::entity& declaration() const = 0;
|
||||||
|
|
||||||
@@ -137,14 +137,14 @@ class IFC_PARSE_API IfcBaseEntity : public IfcBaseClass {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
T get_value(const std::string& name, const T& default_value) const;
|
T get_value(const std::string& name, const T& default_value) const;
|
||||||
|
|
||||||
boost::shared_ptr<aggregate_of_instance> get_inverse(const std::string& a) const;
|
boost::shared_ptr<aggregate_of_instance> get_inverse(const std::string& name) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Investigate whether these should be template classes instead
|
// TODO: Investigate whether these should be template classes instead
|
||||||
class IFC_PARSE_API IfcBaseType : public IfcBaseClass {
|
class IFC_PARSE_API IfcBaseType : public IfcBaseClass {
|
||||||
public:
|
public:
|
||||||
IfcBaseType() : IfcBaseClass() {}
|
IfcBaseType() : IfcBaseClass() {}
|
||||||
IfcBaseType(IfcEntityInstanceData* d) : IfcBaseClass(d) {}
|
IfcBaseType(IfcEntityInstanceData* data) : IfcBaseClass(data) {}
|
||||||
|
|
||||||
virtual const IfcParse::declaration& declaration() const = 0;
|
virtual const IfcParse::declaration& declaration() const = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -71,8 +71,8 @@
|
|||||||
using namespace IfcParse;
|
using namespace IfcParse;
|
||||||
using namespace IfcWrite;
|
using namespace IfcWrite;
|
||||||
|
|
||||||
IfcCharacterDecoder::IfcCharacterDecoder(IfcParse::IfcSpfStream* f) {
|
IfcCharacterDecoder::IfcCharacterDecoder(IfcParse::IfcSpfStream* stream) {
|
||||||
stream_ = f;
|
stream_ = stream;
|
||||||
codepage_ = 0;
|
codepage_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,35 +205,35 @@ class pure_impure_helper {
|
|||||||
static std::string empty;
|
static std::string empty;
|
||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
auto it = std::max_element(builder_.begin(), builder_.end());
|
auto iter = std::max_element(builder_.begin(), builder_.end());
|
||||||
if (*it <= 0x7e) {
|
if (*iter <= 0x7e) {
|
||||||
std::string r(builder_.begin(), builder_.end());
|
std::string result(builder_.begin(), builder_.end());
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
return IfcUtil::convert_utf8(builder_);
|
return IfcUtil::convert_utf8(builder_);
|
||||||
}
|
}
|
||||||
if (mode == IfcParse::IfcCharacterDecoder::SUBSTITUTE) {
|
if (mode == IfcParse::IfcCharacterDecoder::SUBSTITUTE) {
|
||||||
std::string r;
|
std::string result;
|
||||||
r.reserve(builder_.size());
|
result.reserve(builder_.size());
|
||||||
std::transform(builder_.begin(), builder_.end(), std::back_inserter(r), [&substitution_character](wchar_t c) {
|
std::transform(builder_.begin(), builder_.end(), std::back_inserter(result), [&substitution_character](wchar_t character) {
|
||||||
if (c >= 0x20 && c <= 0x7e) {
|
if (character >= 0x20 && character <= 0x7e) {
|
||||||
return (char)c;
|
return (char)character;
|
||||||
}
|
}
|
||||||
return substitution_character;
|
return substitution_character;
|
||||||
});
|
});
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
if (mode == IfcParse::IfcCharacterDecoder::ESCAPE) {
|
if (mode == IfcParse::IfcCharacterDecoder::ESCAPE) {
|
||||||
std::stringstream str;
|
std::stringstream stream;
|
||||||
str << std::hex << std::setw(4) << std::setfill('0');
|
stream << std::hex << std::setw(4) << std::setfill('0');
|
||||||
std::for_each(builder_.begin(), builder_.end(), [&str](wchar_t c) {
|
std::for_each(builder_.begin(), builder_.end(), [&stream](wchar_t character) {
|
||||||
if (c >= 0x20 && c <= 0x7e) {
|
if (character >= 0x20 && character <= 0x7e) {
|
||||||
str.put((char)c);
|
stream.put((char)character);
|
||||||
} else {
|
} else {
|
||||||
str << "\\u" << c;
|
stream << "\\u" << character;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return str.str();
|
return stream.str();
|
||||||
}
|
}
|
||||||
throw IfcParse::IfcException("Invalid conversion mode");
|
throw IfcParse::IfcException("Invalid conversion mode");
|
||||||
}
|
}
|
||||||
@@ -334,20 +334,20 @@ IfcCharacterEncoder::operator std::string() {
|
|||||||
bool in_extended = false;
|
bool in_extended = false;
|
||||||
|
|
||||||
for (auto it = str_.begin(); it != str_.end(); ++it) {
|
for (auto it = str_.begin(); it != str_.end(); ++it) {
|
||||||
auto ch = *it;
|
auto character = *it;
|
||||||
const bool within_spf_range = ch >= 0x20 && ch <= 0x7e;
|
const bool within_spf_range = character >= 0x20 && character <= 0x7e;
|
||||||
if (in_extended && within_spf_range) {
|
if (in_extended && within_spf_range) {
|
||||||
oss << "\\X0\\";
|
oss << "\\X0\\";
|
||||||
} else if (!in_extended && !within_spf_range) {
|
} else if (!in_extended && !within_spf_range) {
|
||||||
oss << "\\X" << num_bytes_str << "\\";
|
oss << "\\X" << num_bytes_str << "\\";
|
||||||
}
|
}
|
||||||
if (within_spf_range) {
|
if (within_spf_range) {
|
||||||
oss.put((char)ch);
|
oss.put((char)character);
|
||||||
if (ch == '\\' || ch == '\'') {
|
if (character == '\\' || character == '\'') {
|
||||||
oss.put((char)ch);
|
oss.put((char)character);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
oss << std::hex << std::setw(num_bytes * 2) << std::uppercase << std::setfill('0') << (int)ch;
|
oss << std::hex << std::setw(num_bytes * 2) << std::uppercase << std::setfill('0') << (int)character;
|
||||||
}
|
}
|
||||||
in_extended = !within_spf_range;
|
in_extended = !within_spf_range;
|
||||||
}
|
}
|
||||||
@@ -374,13 +374,14 @@ def _():
|
|||||||
|
|
||||||
"{%s}" % ",".join(_())
|
"{%s}" % ",".join(_())
|
||||||
*/
|
*/
|
||||||
std::wstring::value_type IfcUtil::convert_codepage(int codepage, int c) {
|
std::wstring::value_type IfcUtil::convert_codepage(int codepage, int character) {
|
||||||
if (codepage < 1 || codepage > 16 || codepage == 12) {
|
if (codepage < 1 || codepage > 16 || codepage == 12) {
|
||||||
throw IfcParse::IfcException("Invalid codepage");
|
throw IfcParse::IfcException("Invalid codepage");
|
||||||
}
|
}
|
||||||
if (c < 0 || c > 255) {
|
if (character < 0 || character > 255) {
|
||||||
throw IfcParse::IfcException("Invalid character ordinal");
|
throw IfcParse::IfcException("Invalid character ordinal");
|
||||||
}
|
}
|
||||||
|
// NOLINTBEGIN(readability-magic-numbers)
|
||||||
static std::array<std::array<wchar_t, 256>, 16> codepage_data = {{{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}},
|
static std::array<std::array<wchar_t, 256>, 16> codepage_data = {{{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}},
|
||||||
{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 728, 321, 164, 317, 346, 167, 168, 352, 350, 356, 377, 173, 381, 379, 176, 261, 731, 322, 180, 318, 347, 711, 184, 353, 351, 357, 378, 733, 382, 380, 340, 193, 194, 258, 196, 313, 262, 199, 268, 201, 280, 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, 214, 215, 344, 366, 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, 314, 263, 231, 269, 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, 244, 337, 246, 247, 345, 367, 250, 369, 252, 253, 355, 729}},
|
{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 728, 321, 164, 317, 346, 167, 168, 352, 350, 356, 377, 173, 381, 379, 176, 261, 731, 322, 180, 318, 347, 711, 184, 353, 351, 357, 378, 733, 382, 380, 340, 193, 194, 258, 196, 313, 262, 199, 268, 201, 280, 203, 282, 205, 206, 270, 272, 323, 327, 211, 212, 336, 214, 215, 344, 366, 218, 368, 220, 221, 354, 223, 341, 225, 226, 259, 228, 314, 263, 231, 269, 233, 281, 235, 283, 237, 238, 271, 273, 324, 328, 243, 244, 337, 246, 247, 345, 367, 250, 369, 252, 253, 355, 729}},
|
||||||
{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 294, 728, 163, 164, 0, 292, 167, 168, 304, 350, 286, 308, 173, 0, 379, 176, 295, 178, 179, 180, 181, 293, 183, 184, 305, 351, 287, 309, 189, 0, 380, 192, 193, 194, 0, 196, 266, 264, 199, 200, 201, 202, 203, 204, 205, 206, 207, 0, 209, 210, 211, 212, 288, 214, 215, 284, 217, 218, 219, 220, 364, 348, 223, 224, 225, 226, 0, 228, 267, 265, 231, 232, 233, 234, 235, 236, 237, 238, 239, 0, 241, 242, 243, 244, 289, 246, 247, 285, 249, 250, 251, 252, 365, 349, 729}},
|
{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 294, 728, 163, 164, 0, 292, 167, 168, 304, 350, 286, 308, 173, 0, 379, 176, 295, 178, 179, 180, 181, 293, 183, 184, 305, 351, 287, 309, 189, 0, 380, 192, 193, 194, 0, 196, 266, 264, 199, 200, 201, 202, 203, 204, 205, 206, 207, 0, 209, 210, 211, 212, 288, 214, 215, 284, 217, 218, 219, 220, 364, 348, 223, 224, 225, 226, 0, 228, 267, 265, 231, 232, 233, 234, 235, 236, 237, 238, 239, 0, 241, 242, 243, 244, 289, 246, 247, 285, 249, 250, 251, 252, 365, 349, 729}},
|
||||||
@@ -397,19 +398,20 @@ std::wstring::value_type IfcUtil::convert_codepage(int codepage, int c) {
|
|||||||
{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 7682, 7683, 163, 266, 267, 7690, 167, 7808, 169, 7810, 7691, 7922, 173, 174, 376, 7710, 7711, 288, 289, 7744, 7745, 182, 7766, 7809, 7767, 7811, 7776, 7923, 7812, 7813, 7777, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 372, 209, 210, 211, 212, 213, 214, 7786, 216, 217, 218, 219, 220, 221, 374, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 373, 241, 242, 243, 244, 245, 246, 7787, 248, 249, 250, 251, 252, 253, 375, 255}},
|
{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 7682, 7683, 163, 266, 267, 7690, 167, 7808, 169, 7810, 7691, 7922, 173, 174, 376, 7710, 7711, 288, 289, 7744, 7745, 182, 7766, 7809, 7767, 7811, 7776, 7923, 7812, 7813, 7777, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 372, 209, 210, 211, 212, 213, 214, 7786, 216, 217, 218, 219, 220, 221, 374, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 373, 241, 242, 243, 244, 245, 246, 7787, 248, 249, 250, 251, 252, 253, 375, 255}},
|
||||||
{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 8364, 165, 352, 167, 353, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 381, 181, 182, 183, 382, 185, 186, 187, 338, 339, 376, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}},
|
{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 8364, 165, 352, 167, 353, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 381, 181, 182, 183, 382, 185, 186, 187, 338, 339, 376, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}},
|
||||||
{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 261, 321, 8364, 8222, 352, 167, 353, 169, 536, 171, 377, 173, 378, 379, 176, 177, 268, 322, 381, 8221, 182, 183, 382, 269, 537, 187, 338, 339, 376, 380, 192, 193, 194, 258, 196, 262, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 272, 323, 210, 211, 212, 336, 214, 346, 368, 217, 218, 219, 220, 280, 538, 223, 224, 225, 226, 259, 228, 263, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 273, 324, 242, 243, 244, 337, 246, 347, 369, 249, 250, 251, 252, 281, 539, 255}}}};
|
{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 260, 261, 321, 8364, 8222, 352, 167, 353, 169, 536, 171, 377, 173, 378, 379, 176, 177, 268, 322, 381, 8221, 182, 183, 382, 269, 537, 187, 338, 339, 376, 380, 192, 193, 194, 258, 196, 262, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 272, 323, 210, 211, 212, 336, 214, 346, 368, 217, 218, 219, 220, 280, 538, 223, 224, 225, 226, 259, 228, 263, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 273, 324, 242, 243, 244, 337, 246, 347, 369, 249, 250, 251, 252, 281, 539, 255}}}};
|
||||||
auto r = codepage_data[codepage - 1][c];
|
// NOLINTEND(readability-magic-numbers)
|
||||||
if (r == 0) {
|
auto result = codepage_data[codepage - 1][character];
|
||||||
|
if (result == 0) {
|
||||||
throw IfcParse::IfcException("Character not defined");
|
throw IfcParse::IfcException("Character not defined");
|
||||||
}
|
}
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string IfcUtil::convert_utf8(const std::wstring& s) {
|
std::string IfcUtil::convert_utf8(const std::wstring& string) {
|
||||||
return std::wstring_convert<std::codecvt_utf8<std::wstring::value_type>>().to_bytes(s);
|
return std::wstring_convert<std::codecvt_utf8<std::wstring::value_type>>().to_bytes(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring IfcUtil::convert_utf8(const std::string& s) {
|
std::wstring IfcUtil::convert_utf8(const std::string& string) {
|
||||||
return std::wstring_convert<std::codecvt_utf8<std::wstring::value_type>>().from_bytes(s);
|
return std::wstring_convert<std::codecvt_utf8<std::wstring::value_type>>().from_bytes(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -423,8 +425,8 @@ std::u32string IfcUtil::convert_utf8_to_utf32(const std::string& s) {
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
std::u32string IfcUtil::convert_utf8_to_utf32(const std::string& s) {
|
std::u32string IfcUtil::convert_utf8_to_utf32(const std::string& string) {
|
||||||
return std::wstring_convert<std::codecvt_utf8<std::u32string::value_type>, std::u32string::value_type>().from_bytes(s);
|
return std::wstring_convert<std::codecvt_utf8<std::u32string::value_type>, std::u32string::value_type>().from_bytes(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,10 +32,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace IfcUtil {
|
namespace IfcUtil {
|
||||||
std::wstring::value_type convert_codepage(int codepage, int c);
|
std::wstring::value_type convert_codepage(int codepage, int index);
|
||||||
std::string convert_utf8(const std::wstring& s);
|
std::string convert_utf8(const std::wstring& string);
|
||||||
std::wstring convert_utf8(const std::string& s);
|
std::wstring convert_utf8(const std::string& string);
|
||||||
std::u32string convert_utf8_to_utf32(const std::string& s);
|
std::u32string convert_utf8_to_utf32(const std::string& string);
|
||||||
} // namespace IfcUtil
|
} // namespace IfcUtil
|
||||||
|
|
||||||
namespace IfcParse {
|
namespace IfcParse {
|
||||||
@@ -53,7 +53,7 @@ class IFC_PARSE_API IfcCharacterDecoder {
|
|||||||
};
|
};
|
||||||
static ConversionMode mode;
|
static ConversionMode mode;
|
||||||
static char substitution_character;
|
static char substitution_character;
|
||||||
IfcCharacterDecoder(IfcParse::IfcSpfStream* file);
|
IfcCharacterDecoder(IfcParse::IfcSpfStream* stream);
|
||||||
~IfcCharacterDecoder();
|
~IfcCharacterDecoder();
|
||||||
// Only advances the underlying token stream read pointer
|
// Only advances the underlying token stream read pointer
|
||||||
// to the next token.
|
// to the next token.
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ class IFC_PARSE_API IfcEntityInstanceData {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
IfcEntityInstanceData(const IfcParse::declaration* type,
|
IfcEntityInstanceData(const IfcParse::declaration* type,
|
||||||
IfcParse::IfcFile* file_,
|
IfcParse::IfcFile* file,
|
||||||
unsigned id = 0,
|
unsigned id = 0,
|
||||||
unsigned offset_in_file = 0)
|
unsigned offset_in_file = 0)
|
||||||
: file(file_),
|
: file(file),
|
||||||
id_(id),
|
id_(id),
|
||||||
type_(type),
|
type_(type),
|
||||||
attributes_(0),
|
attributes_(0),
|
||||||
@@ -69,16 +69,16 @@ class IFC_PARSE_API IfcEntityInstanceData {
|
|||||||
|
|
||||||
void load() const;
|
void load() const;
|
||||||
|
|
||||||
IfcEntityInstanceData(const IfcEntityInstanceData& e);
|
IfcEntityInstanceData(const IfcEntityInstanceData& data);
|
||||||
|
|
||||||
virtual ~IfcEntityInstanceData();
|
virtual ~IfcEntityInstanceData();
|
||||||
|
|
||||||
boost::shared_ptr<aggregate_of_instance> getInverse(const IfcParse::declaration* type, int attribute_index) const;
|
boost::shared_ptr<aggregate_of_instance> getInverse(const IfcParse::declaration* type, int attribute_index) const;
|
||||||
|
|
||||||
Argument* getArgument(size_t i) const;
|
Argument* getArgument(size_t index) const;
|
||||||
|
|
||||||
// NB: This makes a copy of the argument if make_copy is set
|
// NB: This makes a copy of the argument if make_copy is set
|
||||||
void setArgument(size_t i, Argument* a, IfcUtil::ArgumentType attr_type = IfcUtil::Argument_UNKNOWN, bool make_copy = false);
|
void setArgument(size_t ibdex, Argument* argument, IfcUtil::ArgumentType attr_type = IfcUtil::Argument_UNKNOWN, bool make_copy = false);
|
||||||
|
|
||||||
virtual size_t getArgumentCount() const {
|
virtual size_t getArgumentCount() const {
|
||||||
if (type_ == 0) {
|
if (type_ == 0) {
|
||||||
@@ -104,7 +104,7 @@ class IFC_PARSE_API IfcEntityInstanceData {
|
|||||||
// NB: const ommitted for lazy loading
|
// NB: const ommitted for lazy loading
|
||||||
Argument**& attributes() const { return attributes_; }
|
Argument**& attributes() const { return attributes_; }
|
||||||
|
|
||||||
unsigned set_id(boost::optional<unsigned> i = boost::none);
|
unsigned set_id(boost::optional<unsigned> id = boost::none);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ class IFC_PARSE_API IfcException : public std::exception {
|
|||||||
std::string message_;
|
std::string message_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IfcException(const std::string& m)
|
IfcException(const std::string& message)
|
||||||
: message_(m) {}
|
: message_(message) {}
|
||||||
virtual ~IfcException() throw() {}
|
virtual ~IfcException() throw() {}
|
||||||
virtual const char* what() const throw() {
|
virtual const char* what() const throw() {
|
||||||
return message_.c_str();
|
return message_.c_str();
|
||||||
@@ -49,8 +49,8 @@ class IFC_PARSE_API IfcException : public std::exception {
|
|||||||
|
|
||||||
class IFC_PARSE_API IfcAttributeOutOfRangeException : public IfcException {
|
class IFC_PARSE_API IfcAttributeOutOfRangeException : public IfcException {
|
||||||
public:
|
public:
|
||||||
IfcAttributeOutOfRangeException(const std::string& e)
|
IfcAttributeOutOfRangeException(const std::string& exception)
|
||||||
: IfcException(e) {}
|
: IfcException(exception) {}
|
||||||
~IfcAttributeOutOfRangeException() throw() {}
|
~IfcAttributeOutOfRangeException() throw() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,9 +66,9 @@ class IFC_PARSE_API IfcInvalidTokenException : public IfcException {
|
|||||||
" invalid " + expected_type) {}
|
" invalid " + expected_type) {}
|
||||||
IfcInvalidTokenException(
|
IfcInvalidTokenException(
|
||||||
int token_start,
|
int token_start,
|
||||||
char c)
|
char character)
|
||||||
: IfcException(
|
: IfcException(
|
||||||
std::string("Unexpected '") + std::string(1, c) + "' at offset " +
|
std::string("Unexpected '") + std::string(1, character) + "' at offset " +
|
||||||
boost::lexical_cast<std::string>(token_start)) {}
|
boost::lexical_cast<std::string>(token_start)) {}
|
||||||
~IfcInvalidTokenException() throw() {}
|
~IfcInvalidTokenException() throw() {}
|
||||||
};
|
};
|
||||||
|
|||||||
+11
-11
@@ -87,8 +87,8 @@ class IFC_PARSE_API IfcFile {
|
|||||||
public:
|
public:
|
||||||
type_iterator() : entities_by_type_t::const_iterator(){};
|
type_iterator() : entities_by_type_t::const_iterator(){};
|
||||||
|
|
||||||
type_iterator(const entities_by_type_t::const_iterator& it)
|
type_iterator(const entities_by_type_t::const_iterator& iter)
|
||||||
: entities_by_type_t::const_iterator(it){};
|
: entities_by_type_t::const_iterator(iter){};
|
||||||
|
|
||||||
entities_by_type_t::key_type const* operator->() const {
|
entities_by_type_t::key_type const* operator->() const {
|
||||||
return &entities_by_type_t::const_iterator::operator->()->first;
|
return &entities_by_type_t::const_iterator::operator->()->first;
|
||||||
@@ -151,7 +151,7 @@ class IFC_PARSE_API IfcFile {
|
|||||||
|
|
||||||
void setDefaultHeaderValues();
|
void setDefaultHeaderValues();
|
||||||
|
|
||||||
void initialize_(IfcParse::IfcSpfStream* f);
|
void initialize_(IfcParse::IfcSpfStream* stream);
|
||||||
|
|
||||||
void build_inverses_(IfcUtil::IfcBaseClass*);
|
void build_inverses_(IfcUtil::IfcBaseClass*);
|
||||||
|
|
||||||
@@ -171,13 +171,13 @@ class IFC_PARSE_API IfcFile {
|
|||||||
IfcParse::IfcSpfStream* stream;
|
IfcParse::IfcSpfStream* stream;
|
||||||
|
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
IfcFile(const std::string& fn, bool mmap = false);
|
IfcFile(const std::string& path, bool mmap = false);
|
||||||
#else
|
#else
|
||||||
IfcFile(const std::string& fn);
|
IfcFile(const std::string& path);
|
||||||
#endif
|
#endif
|
||||||
IfcFile(std::istream& fn, int len);
|
IfcFile(std::istream& stream, int length);
|
||||||
IfcFile(void* data, int len);
|
IfcFile(void* data, int length);
|
||||||
IfcFile(IfcParse::IfcSpfStream* f);
|
IfcFile(IfcParse::IfcSpfStream* stream);
|
||||||
IfcFile(const IfcParse::schema_definition* schema = IfcParse::schema_by_name("IFC4"));
|
IfcFile(const IfcParse::schema_definition* schema = IfcParse::schema_by_name("IFC4"));
|
||||||
|
|
||||||
/// Deleting the file will also delete all new instances that were added to the file (via memory allocation)
|
/// Deleting the file will also delete all new instances that were added to the file (via memory allocation)
|
||||||
@@ -230,10 +230,10 @@ class IFC_PARSE_API IfcFile {
|
|||||||
/// Returns all entities in the file that match the positional argument.
|
/// Returns all entities in the file that match the positional argument.
|
||||||
/// NOTE: This also returns subtypes of the requested type, for example:
|
/// NOTE: This also returns subtypes of the requested type, for example:
|
||||||
/// IfcWall will also return IfcWallStandardCase entities
|
/// IfcWall will also return IfcWallStandardCase entities
|
||||||
aggregate_of_instance::ptr instances_by_type(const std::string& t);
|
aggregate_of_instance::ptr instances_by_type(const std::string& type);
|
||||||
|
|
||||||
/// Returns all entities in the file that match the positional argument.
|
/// Returns all entities in the file that match the positional argument.
|
||||||
aggregate_of_instance::ptr instances_by_type_excl_subtypes(const std::string& t);
|
aggregate_of_instance::ptr instances_by_type_excl_subtypes(const std::string& type);
|
||||||
|
|
||||||
/// Returns all entities in the file that reference the id
|
/// Returns all entities in the file that reference the id
|
||||||
aggregate_of_instance::ptr instances_by_reference(int id);
|
aggregate_of_instance::ptr instances_by_reference(int id);
|
||||||
@@ -275,7 +275,7 @@ class IFC_PARSE_API IfcFile {
|
|||||||
void recalculate_id_counter();
|
void recalculate_id_counter();
|
||||||
|
|
||||||
IfcUtil::IfcBaseClass* addEntity(IfcUtil::IfcBaseClass* entity, int id = -1);
|
IfcUtil::IfcBaseClass* addEntity(IfcUtil::IfcBaseClass* entity, int id = -1);
|
||||||
void addEntities(aggregate_of_instance::ptr es);
|
void addEntities(aggregate_of_instance::ptr entities);
|
||||||
|
|
||||||
void batch() { batch_mode_ = true; }
|
void batch() { batch_mode_ = true; }
|
||||||
void unbatch() {
|
void unbatch() {
|
||||||
|
|||||||
@@ -32,46 +32,47 @@
|
|||||||
static const char* chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$";
|
static const char* chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$";
|
||||||
|
|
||||||
// Converts an unsigned integer into a base64 string of length l
|
// Converts an unsigned integer into a base64 string of length l
|
||||||
std::string base64(unsigned v, int l) {
|
std::string base64(unsigned value, int length) {
|
||||||
std::string r;
|
const int BASE64 = 64;
|
||||||
r.reserve(l);
|
std::string result;
|
||||||
while (v != 0U) {
|
result.reserve(length);
|
||||||
r.push_back(chars[v % 64]);
|
while (value != 0U) {
|
||||||
v /= 64;
|
result.push_back(chars[value % BASE64]);
|
||||||
|
value /= BASE64;
|
||||||
}
|
}
|
||||||
while ((int)r.size() != l) {
|
while ((int)result.size() != length) {
|
||||||
r.push_back('0');
|
result.push_back('0');
|
||||||
}
|
}
|
||||||
std::reverse(r.begin(), r.end());
|
std::reverse(result.begin(), result.end());
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts a base64 string into an unsigned integer
|
// Converts a base64 string into an unsigned integer
|
||||||
unsigned from_base64(const std::string& s) {
|
unsigned from_base64(const std::string& string) {
|
||||||
std::string::size_type zeros = s.find_first_not_of('0');
|
std::string::size_type zeros = string.find_first_not_of('0');
|
||||||
unsigned r = 0;
|
unsigned result = 0;
|
||||||
if (zeros != std::string::npos) {
|
if (zeros != std::string::npos) {
|
||||||
for (std::string::const_iterator i = s.begin() + zeros; i != s.end(); ++i) {
|
for (std::string::const_iterator i = string.begin() + zeros; i != string.end(); ++i) {
|
||||||
r *= 64;
|
result *= 64;
|
||||||
const char* c = strchr(chars, *i);
|
const char* character = strchr(chars, *i);
|
||||||
if (c == nullptr) {
|
if (character == nullptr) {
|
||||||
throw IfcParse::IfcException("Failed to decode GlobalId");
|
throw IfcParse::IfcException("Failed to decode GlobalId");
|
||||||
}
|
}
|
||||||
r += (unsigned)(c - chars);
|
result += (unsigned)(character - chars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compresses the UUID byte array into a base64 representation
|
// Compresses the UUID byte array into a base64 representation
|
||||||
std::string compress(unsigned char* v) {
|
std::string compress(unsigned char* value) {
|
||||||
std::string r;
|
std::string result;
|
||||||
r.reserve(22);
|
result.reserve(22);
|
||||||
r += base64(v[0], 2);
|
result += base64(value[0], 2);
|
||||||
for (unsigned i = 1; i < 16; i += 3) {
|
for (unsigned i = 1; i < 16; i += 3) {
|
||||||
r += base64((v[i] << 16) + (v[i + 1] << 8) + v[i + 2], 4);
|
result += base64((value[i] << 16) + (value[i + 1] << 8) + value[i + 2], 4);
|
||||||
}
|
}
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expands the base64 representation into a UUID byte array
|
// Expands the base64 representation into a UUID byte array
|
||||||
@@ -110,20 +111,20 @@ IfcParse::IfcGlobalId::IfcGlobalId() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcParse::IfcGlobalId::IfcGlobalId(const std::string& s)
|
IfcParse::IfcGlobalId::IfcGlobalId(const std::string& string)
|
||||||
: string_data_(s) {
|
: string_data_(string) {
|
||||||
std::vector<unsigned char> v;
|
std::vector<unsigned char> result;
|
||||||
expand(string_data_, v);
|
expand(string_data_, result);
|
||||||
std::copy(v.begin(), v.end(), uuid_data_.begin());
|
std::copy(result.begin(), result.end(), uuid_data_.begin());
|
||||||
#if BOOST_VERSION < 104400
|
#if BOOST_VERSION < 104400
|
||||||
formatted_string = boost::lexical_cast<std::string>(uuid_data);
|
formatted_string_ = boost::lexical_cast<std::string>(uuid_data_);
|
||||||
#else
|
#else
|
||||||
formatted_string_ = boost::uuids::to_string(uuid_data_);
|
formatted_string_ = boost::uuids::to_string(uuid_data_);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
const std::string test_string = compress(&uuid_data.data[0]);
|
const std::string test_string = compress(&uuid_data_.data[0]);
|
||||||
if (string_data != test_string) {
|
if (string_data_ != test_string) {
|
||||||
Logger::Message(Logger::LOG_ERROR, "Internal error generating GlobalId");
|
Logger::Message(Logger::LOG_ERROR, "Internal error generating GlobalId");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -63,11 +63,11 @@ typename Schema::IfcLocalPlacement* IfcHierarchyHelper<Schema>::addLocalPlacemen
|
|||||||
double xx,
|
double xx,
|
||||||
double xy,
|
double xy,
|
||||||
double xz) {
|
double xz) {
|
||||||
typename Schema::IfcLocalPlacement* lp = new typename Schema::IfcLocalPlacement(parent,
|
typename Schema::IfcLocalPlacement* local_placement = new typename Schema::IfcLocalPlacement(parent,
|
||||||
addPlacement3d(ox, oy, oz, zx, zy, zz, xx, xy, xz));
|
addPlacement3d(ox, oy, oz, zx, zy, zz, xx, xy, xz));
|
||||||
|
|
||||||
addEntity(lp);
|
addEntity(local_placement);
|
||||||
return lp;
|
return local_placement;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Schema>
|
template <typename Schema>
|
||||||
@@ -995,9 +995,9 @@ void push_back_to_maybe_optional(boost::optional<boost::shared_ptr<T>>& t, U* u)
|
|||||||
|
|
||||||
template <typename Schema>
|
template <typename Schema>
|
||||||
typename Schema::IfcGeometricRepresentationContext* IfcHierarchyHelper<Schema>::getRepresentationContext(const std::string& s) {
|
typename Schema::IfcGeometricRepresentationContext* IfcHierarchyHelper<Schema>::getRepresentationContext(const std::string& s) {
|
||||||
typename std::map<std::string, typename Schema::IfcGeometricRepresentationContext*>::const_iterator it = contexts_.find(s);
|
typename std::map<std::string, typename Schema::IfcGeometricRepresentationContext*>::const_iterator iter = contexts_.find(s);
|
||||||
if (it != contexts_.end()) {
|
if (iter != contexts_.end()) {
|
||||||
return it->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
typename Schema::IfcProject* project = getSingle<typename Schema::IfcProject>();
|
typename Schema::IfcProject* project = getSingle<typename Schema::IfcProject>();
|
||||||
if (!project) {
|
if (!project) {
|
||||||
|
|||||||
@@ -451,7 +451,8 @@ class IFC_PARSE_API IfcHierarchyHelper : public IfcParse::IfcFile {
|
|||||||
attr->set(owner_hist);
|
attr->set(owner_hist);
|
||||||
data->setArgument(1, attr);
|
data->setArgument(1, attr);
|
||||||
}
|
}
|
||||||
int relating_index = 4, related_index = 5;
|
int relating_index = 4;
|
||||||
|
int related_index = 5;
|
||||||
if (T::Class().name() == "IfcRelContainedInSpatialStructure") {
|
if (T::Class().name() == "IfcRelContainedInSpatialStructure") {
|
||||||
// IfcRelContainedInSpatialStructure has attributes reversed.
|
// IfcRelContainedInSpatialStructure has attributes reversed.
|
||||||
std::swap(relating_index, related_index);
|
std::swap(relating_index, related_index);
|
||||||
|
|||||||
+38
-38
@@ -42,8 +42,8 @@ std::string get_time(bool with_milliseconds = false) {
|
|||||||
|
|
||||||
if (with_milliseconds) {
|
if (with_milliseconds) {
|
||||||
auto now_chrono = std::chrono::system_clock::now();
|
auto now_chrono = std::chrono::system_clock::now();
|
||||||
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(now_chrono.time_since_epoch()) % 1000;
|
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(now_chrono.time_since_epoch()) % 1000;
|
||||||
oss << '.' << std::setfill('0') << std::setw(3) << ms.count();
|
oss << '.' << std::setfill('0') << std::setw(3) << milliseconds.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
return oss.str();
|
return oss.str();
|
||||||
@@ -61,33 +61,33 @@ 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"};
|
const std::array<std::basic_string<wchar_t>, 5> severity_strings<wchar_t>::value = {L"Performance", L"Debug", L"Notice", L"Warning", L"Error"};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void plain_text_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
void plain_text_message(T& out, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||||
os << "[" << severity_strings<typename T::char_type>::value[type] << "] ";
|
out << "[" << severity_strings<typename T::char_type>::value[type] << "] ";
|
||||||
os << "[" << get_time(type <= Logger::LOG_PERF).c_str() << "] ";
|
out << "[" << get_time(type <= Logger::LOG_PERF).c_str() << "] ";
|
||||||
if (current_product) {
|
if (current_product) {
|
||||||
std::string global_id = *((IfcUtil::IfcBaseEntity*)*current_product)->get("GlobalId");
|
std::string global_id = *((IfcUtil::IfcBaseEntity*)*current_product)->get("GlobalId");
|
||||||
os << "{" << global_id.c_str() << "} ";
|
out << "{" << global_id.c_str() << "} ";
|
||||||
}
|
}
|
||||||
os << message.c_str() << std::endl;
|
out << message.c_str() << std::endl;
|
||||||
if (instance) {
|
if (instance) {
|
||||||
std::string instance_string = instance->data().toString();
|
std::string instance_string = instance->data().toString();
|
||||||
if (instance_string.size() > 259) {
|
if (instance_string.size() > 259) {
|
||||||
instance_string = instance_string.substr(0, 256) + "...";
|
instance_string = instance_string.substr(0, 256) + "...";
|
||||||
}
|
}
|
||||||
os << instance_string.c_str() << std::endl;
|
out << instance_string.c_str() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::basic_string<T> string_as(const std::string& s) {
|
std::basic_string<T> string_as(const std::string& string) {
|
||||||
std::basic_string<T> v;
|
std::basic_string<T> result;
|
||||||
v.assign(s.begin(), s.end());
|
result.assign(string.begin(), string.end());
|
||||||
return v;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void json_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
void json_message(T& out, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, 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>> pt;
|
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
|
// @todo this is crazy
|
||||||
static const typename T::char_type time_string[] = {'t', 'i', 'm', 'e', 0};
|
static const typename T::char_type time_string[] = {'t', 'i', 'm', 'e', 0};
|
||||||
@@ -96,18 +96,18 @@ void json_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_
|
|||||||
static const typename T::char_type message_string[] = {'m', 'e', 's', 's', 'a', 'g', 'e', 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};
|
static const typename T::char_type instance_string[] = {'i', 'n', 's', 't', 'a', 'n', 'c', 'e', 0};
|
||||||
|
|
||||||
pt.put(level_string, severity_strings<typename T::char_type>::value[type]);
|
property_tree.put(level_string, severity_strings<typename T::char_type>::value[type]);
|
||||||
if (current_product) {
|
if (current_product) {
|
||||||
pt.put(product_string, string_as<typename T::char_type>((**current_product).data().toString()));
|
property_tree.put(product_string, string_as<typename T::char_type>((**current_product).data().toString()));
|
||||||
}
|
}
|
||||||
pt.put(message_string, string_as<typename T::char_type>(message));
|
property_tree.put(message_string, string_as<typename T::char_type>(message));
|
||||||
if (instance) {
|
if (instance) {
|
||||||
pt.put(instance_string, string_as<typename T::char_type>(instance->data().toString()));
|
property_tree.put(instance_string, string_as<typename T::char_type>(instance->data().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.put(time_string, string_as<typename T::char_type>(get_time()));
|
property_tree.put(time_string, string_as<typename T::char_type>(get_time()));
|
||||||
|
|
||||||
boost::property_tree::write_json(os, pt, false);
|
boost::property_tree::write_json(out, property_tree, false);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -122,27 +122,27 @@ void Logger::SetProduct(boost::optional<const IfcUtil::IfcBaseClass*> product) {
|
|||||||
current_product_ = product;
|
current_product_ = product;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::SetOutput(std::ostream* l1, std::ostream* l2) {
|
void Logger::SetOutput(std::ostream* stream1, std::ostream* stream2) {
|
||||||
wlog1_ = wlog2_ = 0;
|
wlog1_ = wlog2_ = 0;
|
||||||
log1_ = l1;
|
log1_ = stream1;
|
||||||
log2_ = l2;
|
log2_ = stream2;
|
||||||
if (log2_ == nullptr) {
|
if (log2_ == nullptr) {
|
||||||
log2_ = &log_stream_;
|
log2_ = &log_stream_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::SetOutput(std::wostream* l1, std::wostream* l2) {
|
void Logger::SetOutput(std::wostream* stream1, std::wostream* stream2) {
|
||||||
log1_ = log2_ = 0;
|
log1_ = log2_ = 0;
|
||||||
wlog1_ = l1;
|
wlog1_ = stream1;
|
||||||
wlog2_ = l2;
|
wlog2_ = stream2;
|
||||||
if (wlog2_ == nullptr) {
|
if (wlog2_ == nullptr) {
|
||||||
log2_ = &log_stream_;
|
log2_ = &log_stream_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Message(Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
void Logger::Message(Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseInterface* instance) {
|
||||||
static std::mutex m;
|
static std::mutex mtx;
|
||||||
std::lock_guard<std::mutex> lk(m);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
|
|
||||||
if (type == LOG_PERF) {
|
if (type == LOG_PERF) {
|
||||||
if (!first_timepoint_) {
|
if (!first_timepoint_) {
|
||||||
@@ -209,32 +209,32 @@ std::string Logger::GetLog() {
|
|||||||
|
|
||||||
void Logger::PrintPerformanceStats() {
|
void Logger::PrintPerformanceStats() {
|
||||||
std::vector<std::pair<double, std::string>> items;
|
std::vector<std::pair<double, std::string>> items;
|
||||||
for (auto& p : performance_statistics_) {
|
for (auto& stat : performance_statistics_) {
|
||||||
items.push_back({p.second, p.first});
|
items.push_back({stat.second, stat.first});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(items.begin(), items.end());
|
std::sort(items.begin(), items.end());
|
||||||
std::reverse(items.begin(), items.end());
|
std::reverse(items.begin(), items.end());
|
||||||
|
|
||||||
size_t max_size = 0;
|
size_t max_size = 0;
|
||||||
for (auto& p : items) {
|
for (auto& item : items) {
|
||||||
if (p.second.size() > max_size) {
|
if (item.second.size() > max_size) {
|
||||||
max_size = p.second.size();
|
max_size = item.second.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& p : items) {
|
for (auto& item : items) {
|
||||||
auto s = p.second + std::string(max_size - p.second.size(), ' ') + ": " + std::to_string(p.first);
|
auto message = item.second + std::string(max_size - item.second.size(), ' ') + ": " + std::to_string(item.first);
|
||||||
Message(LOG_PERF, s);
|
Message(LOG_PERF, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Verbosity(Logger::Severity v) { verbosity_ = v; }
|
void Logger::Verbosity(Logger::Severity severity) { verbosity_ = severity; }
|
||||||
Logger::Severity Logger::Verbosity() { return verbosity_; }
|
Logger::Severity Logger::Verbosity() { return verbosity_; }
|
||||||
|
|
||||||
Logger::Severity Logger::MaxSeverity() { return max_severity_; }
|
Logger::Severity Logger::MaxSeverity() { return max_severity_; }
|
||||||
|
|
||||||
void Logger::OutputFormat(Format f) { format_ = f; }
|
void Logger::OutputFormat(Format format) { format_ = format; }
|
||||||
Logger::Format Logger::OutputFormat() { return format_; }
|
Logger::Format Logger::OutputFormat() { return format_; }
|
||||||
|
|
||||||
std::ostream* Logger::log1_ = 0;
|
std::ostream* Logger::log1_ = 0;
|
||||||
|
|||||||
@@ -70,23 +70,23 @@ class IFC_PARSE_API Logger {
|
|||||||
static void SetProduct(boost::optional<const IfcUtil::IfcBaseClass*> product);
|
static void SetProduct(boost::optional<const IfcUtil::IfcBaseClass*> product);
|
||||||
|
|
||||||
/// Determines to what stream respectively progress and errors are logged
|
/// Determines to what stream respectively progress and errors are logged
|
||||||
static void SetOutput(std::wostream* l1, std::wostream* l2);
|
static void SetOutput(std::wostream* stream1, std::wostream* stream2);
|
||||||
|
|
||||||
/// Determines to what stream respectively progress and errors are logged
|
/// Determines to what stream respectively progress and errors are logged
|
||||||
static void SetOutput(std::ostream* l1, std::ostream* l2);
|
static void SetOutput(std::ostream* stream1, std::ostream* stream2);
|
||||||
|
|
||||||
/// Determines the types of log messages to get logged
|
/// Determines the types of log messages to get logged
|
||||||
static void Verbosity(Severity v);
|
static void Verbosity(Severity severity);
|
||||||
static Severity Verbosity();
|
static Severity Verbosity();
|
||||||
static Severity MaxSeverity();
|
static Severity MaxSeverity();
|
||||||
|
|
||||||
/// Determines output format: plain text or sequence of JSON objects
|
/// Determines output format: plain text or sequence of JSON objects
|
||||||
static void OutputFormat(Format f);
|
static void OutputFormat(Format format);
|
||||||
static Format OutputFormat();
|
static Format OutputFormat();
|
||||||
|
|
||||||
/// Log a message to the output stream
|
/// 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::string& message, const IfcUtil::IfcBaseInterface* instance = 0);
|
||||||
static void Message(Severity type, const std::exception& message, const IfcUtil::IfcBaseInterface* instance = 0);
|
static void Message(Severity type, 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 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 Warning(const std::string& message, const IfcUtil::IfcBaseInterface* instance = 0) { Message(LOG_WARNING, message, instance); }
|
||||||
|
|||||||
+183
-161
@@ -106,16 +106,16 @@ void init_locale() {
|
|||||||
// Opens the file and gets the filesize
|
// Opens the file and gets the filesize
|
||||||
//
|
//
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
IfcSpfStream::IfcSpfStream(const std::string& fn, bool mmap)
|
IfcSpfStream::IfcSpfStream(const std::string& path, bool mmap)
|
||||||
#else
|
#else
|
||||||
IfcSpfStream::IfcSpfStream(const std::string& fn)
|
IfcSpfStream::IfcSpfStream(const std::string& path)
|
||||||
#endif
|
#endif
|
||||||
: stream_(0),
|
: stream_(0),
|
||||||
buffer_(0),
|
buffer_(0),
|
||||||
valid(false),
|
valid(false),
|
||||||
eof(false) {
|
eof(false) {
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
std::wstring fn_ws = IfcUtil::path::from_utf8(fn);
|
std::wstring fn_ws = IfcUtil::path::from_utf8(path);
|
||||||
const wchar_t* fn_wide = fn_ws.c_str();
|
const wchar_t* fn_wide = fn_ws.c_str();
|
||||||
|
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
@@ -132,10 +132,10 @@ IfcSpfStream::IfcSpfStream(const std::string& fn)
|
|||||||
|
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
if (mmap) {
|
if (mmap) {
|
||||||
mfs = boost::iostreams::mapped_file_source(fn);
|
mfs = boost::iostreams::mapped_file_source(path);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
stream_ = fopen(fn.c_str(), "rb");
|
stream_ = fopen(path.c_str(), "rb");
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -174,28 +174,28 @@ IfcSpfStream::IfcSpfStream(const std::string& fn)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcSpfStream::IfcSpfStream(std::istream& f, int l)
|
IfcSpfStream::IfcSpfStream(std::istream& stream, int length)
|
||||||
: stream_(0),
|
: stream_(0),
|
||||||
buffer_(0) {
|
buffer_(0) {
|
||||||
eof = false;
|
eof = false;
|
||||||
size = l;
|
size = length;
|
||||||
char* buffer_rw = new char[size];
|
char* buffer_rw = new char[size];
|
||||||
f.read(buffer_rw, size);
|
stream.read(buffer_rw, size);
|
||||||
buffer_ = buffer_rw;
|
buffer_ = buffer_rw;
|
||||||
valid = f.gcount() == size;
|
valid = stream.gcount() == size;
|
||||||
ptr_ = 0;
|
ptr_ = 0;
|
||||||
len_ = l;
|
len_ = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcSpfStream::IfcSpfStream(void* data, int l)
|
IfcSpfStream::IfcSpfStream(void* data, int length)
|
||||||
: stream_(0),
|
: stream_(0),
|
||||||
buffer_(0) {
|
buffer_(0) {
|
||||||
eof = false;
|
eof = false;
|
||||||
size = l;
|
size = length;
|
||||||
buffer_ = (char*)data;
|
buffer_ = (char*)data;
|
||||||
valid = true;
|
valid = true;
|
||||||
ptr_ = 0;
|
ptr_ = 0;
|
||||||
len_ = l;
|
len_ = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcSpfStream::~IfcSpfStream() {
|
IfcSpfStream::~IfcSpfStream() {
|
||||||
@@ -218,8 +218,8 @@ void IfcSpfStream::Close() {
|
|||||||
//
|
//
|
||||||
// Seeks an arbitrary position in the file
|
// Seeks an arbitrary position in the file
|
||||||
//
|
//
|
||||||
void IfcSpfStream::Seek(unsigned int o) {
|
void IfcSpfStream::Seek(unsigned int offset) {
|
||||||
ptr_ = o;
|
ptr_ = offset;
|
||||||
if (ptr_ >= len_) {
|
if (ptr_ >= len_) {
|
||||||
throw IfcException("Reading outside of file limits");
|
throw IfcException("Reading outside of file limits");
|
||||||
}
|
}
|
||||||
@@ -236,8 +236,8 @@ char IfcSpfStream::Peek() {
|
|||||||
//
|
//
|
||||||
// Returns the character at specified offset
|
// Returns the character at specified offset
|
||||||
//
|
//
|
||||||
char IfcSpfStream::Read(unsigned int o) {
|
char IfcSpfStream::Read(unsigned int offset) {
|
||||||
return buffer_[o];
|
return buffer_[offset];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -262,10 +262,10 @@ void IfcSpfStream::Inc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcSpfLexer::IfcSpfLexer(IfcParse::IfcSpfStream* s, IfcParse::IfcFile* f) {
|
IfcSpfLexer::IfcSpfLexer(IfcParse::IfcSpfStream* stream_, IfcParse::IfcFile* file_) {
|
||||||
file = f;
|
file = file_;
|
||||||
stream = s;
|
stream = stream_;
|
||||||
decoder_ = new IfcCharacterDecoder(s);
|
decoder_ = new IfcCharacterDecoder(stream_);
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcSpfLexer::~IfcSpfLexer() {
|
IfcSpfLexer::~IfcSpfLexer() {
|
||||||
@@ -273,42 +273,42 @@ IfcSpfLexer::~IfcSpfLexer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int IfcSpfLexer::skipWhitespace() {
|
unsigned int IfcSpfLexer::skipWhitespace() {
|
||||||
unsigned int n = 0;
|
unsigned int index = 0;
|
||||||
while (!stream->eof) {
|
while (!stream->eof) {
|
||||||
char c = stream->Peek();
|
char character = stream->Peek();
|
||||||
if ((c == ' ' || c == '\r' || c == '\n' || c == '\t')) {
|
if ((character == ' ' || character == '\r' || character == '\n' || character == '\t')) {
|
||||||
stream->Inc();
|
stream->Inc();
|
||||||
++n;
|
++index;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return n;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int IfcSpfLexer::skipComment() {
|
unsigned int IfcSpfLexer::skipComment() {
|
||||||
char c = stream->Peek();
|
char character = stream->Peek();
|
||||||
if (c != '/') {
|
if (character != '/') {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
stream->Inc();
|
stream->Inc();
|
||||||
c = stream->Peek();
|
character = stream->Peek();
|
||||||
if (c != '*') {
|
if (character != '*') {
|
||||||
stream->Seek(stream->Tell() - 1);
|
stream->Seek(stream->Tell() - 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
unsigned int n = 2;
|
unsigned int index = 2;
|
||||||
char p = 0;
|
char intermediate = 0;
|
||||||
while (!stream->eof) {
|
while (!stream->eof) {
|
||||||
c = stream->Peek();
|
character = stream->Peek();
|
||||||
stream->Inc();
|
stream->Inc();
|
||||||
++n;
|
++index;
|
||||||
if (c == '/' && p == '*') {
|
if (character == '/' && intermediate == '*') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
p = c;
|
intermediate = character;
|
||||||
}
|
}
|
||||||
return n;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -328,10 +328,16 @@ Token IfcSpfLexer::Next() {
|
|||||||
}
|
}
|
||||||
unsigned int pos = stream->Tell();
|
unsigned int pos = stream->Tell();
|
||||||
|
|
||||||
char c = stream->Peek();
|
char character = stream->Peek();
|
||||||
|
|
||||||
// If the cursor is at [()=,;$*] we know token consists of single char
|
// If the cursor is at [()=,;$*] we know token consists of single char
|
||||||
if (c == '(' || c == ')' || c == '=' || c == ',' || c == ';' || c == '$' || c == '*') {
|
if (character == '(' ||
|
||||||
|
character == ')' ||
|
||||||
|
character == '=' ||
|
||||||
|
character == ',' ||
|
||||||
|
character == ';' ||
|
||||||
|
character == '$' ||
|
||||||
|
character == '*') {
|
||||||
stream->Inc();
|
stream->Inc();
|
||||||
return OperatorTokenPtr(this, pos, pos + 1);
|
return OperatorTokenPtr(this, pos, pos + 1);
|
||||||
}
|
}
|
||||||
@@ -341,15 +347,20 @@ Token IfcSpfLexer::Next() {
|
|||||||
while (!stream->eof) {
|
while (!stream->eof) {
|
||||||
|
|
||||||
// Read character and increment pointer if not starting a new token
|
// Read character and increment pointer if not starting a new token
|
||||||
c = stream->Peek();
|
character = stream->Peek();
|
||||||
if ((len != 0) && (c == '(' || c == ')' || c == '=' || c == ',' || c == ';' || c == '/')) {
|
if ((len != 0) && (character == '(' ||
|
||||||
|
character == ')' ||
|
||||||
|
character == '=' ||
|
||||||
|
character == ',' ||
|
||||||
|
character == ';' ||
|
||||||
|
character == '/')) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stream->Inc();
|
stream->Inc();
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
// If a string is encountered defer processing to the IfcCharacterDecoder
|
// If a string is encountered defer processing to the IfcCharacterDecoder
|
||||||
if (c == '\'') {
|
if (character == '\'') {
|
||||||
decoder_->skip();
|
decoder_->skip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -384,20 +395,28 @@ char IfcSpfStream::peek_at(unsigned int local_ptr) {
|
|||||||
void IfcSpfLexer::TokenString(unsigned int offset, std::string& buffer) {
|
void IfcSpfLexer::TokenString(unsigned int offset, std::string& buffer) {
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
while (!stream->is_eof_at(offset)) {
|
while (!stream->is_eof_at(offset)) {
|
||||||
char c = stream->peek_at(offset);
|
char character = stream->peek_at(offset);
|
||||||
if (!buffer.empty() && (c == '(' || c == ')' || c == '=' || c == ',' || c == ';' || c == '/')) {
|
if (!buffer.empty() && (character == '(' ||
|
||||||
|
character == ')' ||
|
||||||
|
character == '=' ||
|
||||||
|
character == ',' ||
|
||||||
|
character == ';' ||
|
||||||
|
character == '/')) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stream->increment_at(offset);
|
stream->increment_at(offset);
|
||||||
if (c == ' ' || c == '\r' || c == '\n' || c == '\t') {
|
if (character == ' ' ||
|
||||||
|
character == '\r' ||
|
||||||
|
character == '\n' ||
|
||||||
|
character == '\t') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c == '\'') {
|
if (character == '\'') {
|
||||||
// todo, make decoder use local offset ptr
|
// todo, make decoder use local offset ptr
|
||||||
buffer = decoder_->get(offset);
|
buffer = decoder_->get(offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buffer.push_back(c);
|
buffer.push_back(character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,11 +424,14 @@ void IfcSpfLexer::TokenString(unsigned int offset, std::string& buffer) {
|
|||||||
inline void RemoveTokenSeparators(IfcSpfStream* stream, unsigned start, unsigned end, std::string& oDestination) {
|
inline void RemoveTokenSeparators(IfcSpfStream* stream, unsigned start, unsigned end, std::string& oDestination) {
|
||||||
oDestination.clear();
|
oDestination.clear();
|
||||||
for (unsigned i = start; i < end; i++) {
|
for (unsigned i = start; i < end; i++) {
|
||||||
char c = stream->Read(i);
|
char character = stream->Read(i);
|
||||||
if (c == ' ' || c == '\r' || c == '\n' || c == '\t') {
|
if (character == ' ' ||
|
||||||
|
character == '\r' ||
|
||||||
|
character == '\n' ||
|
||||||
|
character == '\t') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
oDestination += c;
|
oDestination += character;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,110 +520,110 @@ Token IfcParse::GeneralTokenPtr(IfcSpfLexer* lexer, unsigned start, unsigned end
|
|||||||
}
|
}
|
||||||
Token IfcParse::NoneTokenPtr() { return Token(); }
|
Token IfcParse::NoneTokenPtr() { return Token(); }
|
||||||
|
|
||||||
bool TokenFunc::isOperator(const Token& t) {
|
bool TokenFunc::isOperator(const Token& token) {
|
||||||
return t.type == Token_OPERATOR;
|
return token.type == Token_OPERATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenFunc::isOperator(const Token& t, char op) {
|
bool TokenFunc::isOperator(const Token& token, char character) {
|
||||||
return t.type == Token_OPERATOR && t.value_char == op;
|
return token.type == Token_OPERATOR && token.value_char == character;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenFunc::isIdentifier(const Token& t) {
|
bool TokenFunc::isIdentifier(const Token& token) {
|
||||||
return t.type == Token_IDENTIFIER;
|
return token.type == Token_IDENTIFIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenFunc::isString(const Token& t) {
|
bool TokenFunc::isString(const Token& token) {
|
||||||
return t.type == Token_STRING;
|
return token.type == Token_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenFunc::isEnumeration(const Token& t) {
|
bool TokenFunc::isEnumeration(const Token& token) {
|
||||||
return t.type == Token_ENUMERATION || t.type == Token_BOOL;
|
return token.type == Token_ENUMERATION || token.type == Token_BOOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenFunc::isBinary(const Token& t) {
|
bool TokenFunc::isBinary(const Token& token) {
|
||||||
return t.type == Token_BINARY;
|
return token.type == Token_BINARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenFunc::isKeyword(const Token& t) {
|
bool TokenFunc::isKeyword(const Token& token) {
|
||||||
return t.type == Token_KEYWORD;
|
return token.type == Token_KEYWORD;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenFunc::isInt(const Token& t) {
|
bool TokenFunc::isInt(const Token& token) {
|
||||||
return t.type == Token_INT;
|
return token.type == Token_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenFunc::isBool(const Token& t) {
|
bool TokenFunc::isBool(const Token& token) {
|
||||||
// Bool and logical share the same storage type, just logical unknown is stored as 2.
|
// Bool and logical share the same storage type, just logical unknown is stored as 2.
|
||||||
return t.type == Token_BOOL && t.value_int != 2;
|
return token.type == Token_BOOL && token.value_int != 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenFunc::isLogical(const Token& t) {
|
bool TokenFunc::isLogical(const Token& token) {
|
||||||
return t.type == Token_BOOL;
|
return token.type == Token_BOOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenFunc::isFloat(const Token& t) {
|
bool TokenFunc::isFloat(const Token& token) {
|
||||||
#ifdef PERMISSIVE_FLOAT
|
#ifdef PERMISSIVE_FLOAT
|
||||||
/// NB: We are being more permissive here then allowed by the standard
|
/// NB: We are being more permissive here then allowed by the standard
|
||||||
return t.type == Token_FLOAT || t.type == Token_INT;
|
return token.type == Token_FLOAT || token.type == Token_INT;
|
||||||
#else
|
#else
|
||||||
return t.type == Token_FLOAT;
|
return token.type == Token_FLOAT;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int TokenFunc::asInt(const Token& t) {
|
int TokenFunc::asInt(const Token& token) {
|
||||||
if (t.type != Token_INT) {
|
if (token.type != Token_INT) {
|
||||||
throw IfcInvalidTokenException(t.startPos, toString(t), "integer");
|
throw IfcInvalidTokenException(token.startPos, toString(token), "integer");
|
||||||
}
|
}
|
||||||
return t.value_int;
|
return token.value_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TokenFunc::asIdentifier(const Token& t) {
|
int TokenFunc::asIdentifier(const Token& token) {
|
||||||
if (t.type != Token_IDENTIFIER) {
|
if (token.type != Token_IDENTIFIER) {
|
||||||
throw IfcInvalidTokenException(t.startPos, toString(t), "instance name");
|
throw IfcInvalidTokenException(token.startPos, toString(token), "instance name");
|
||||||
}
|
}
|
||||||
return t.value_int;
|
return token.value_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TokenFunc::asBool(const Token& t) {
|
bool TokenFunc::asBool(const Token& token) {
|
||||||
if (t.type != Token_BOOL) {
|
if (token.type != Token_BOOL) {
|
||||||
throw IfcInvalidTokenException(t.startPos, toString(t), "boolean");
|
throw IfcInvalidTokenException(token.startPos, toString(token), "boolean");
|
||||||
}
|
}
|
||||||
return t.value_int == 1;
|
return token.value_int == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::logic::tribool TokenFunc::asLogical(const Token& t) {
|
boost::logic::tribool TokenFunc::asLogical(const Token& token) {
|
||||||
if (t.type != Token_BOOL) {
|
if (token.type != Token_BOOL) {
|
||||||
throw IfcInvalidTokenException(t.startPos, toString(t), "boolean");
|
throw IfcInvalidTokenException(token.startPos, toString(token), "boolean");
|
||||||
}
|
}
|
||||||
if (t.value_int == 0) {
|
if (token.value_int == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (t.value_int == 1) {
|
if (token.value_int == 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return boost::logic::indeterminate;
|
return boost::logic::indeterminate;
|
||||||
}
|
}
|
||||||
|
|
||||||
double TokenFunc::asFloat(const Token& t) {
|
double TokenFunc::asFloat(const Token& token) {
|
||||||
#ifdef PERMISSIVE_FLOAT
|
#ifdef PERMISSIVE_FLOAT
|
||||||
if (t.type == Token_INT) {
|
if (token.type == Token_INT) {
|
||||||
/// NB: We are being more permissive here then allowed by the standard
|
/// NB: We are being more permissive here then allowed by the standard
|
||||||
return t.value_int;
|
return token.value_int;
|
||||||
} // ----> continues beyond preprocessor directive
|
} // ----> continues beyond preprocessor directive
|
||||||
#endif
|
#endif
|
||||||
if (t.type == Token_FLOAT) {
|
if (token.type == Token_FLOAT) {
|
||||||
return t.value_double;
|
return token.value_double;
|
||||||
}
|
}
|
||||||
throw IfcInvalidTokenException(t.startPos, toString(t), "real");
|
throw IfcInvalidTokenException(token.startPos, toString(token), "real");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& TokenFunc::asStringRef(const Token& t) {
|
const std::string& TokenFunc::asStringRef(const Token& token) {
|
||||||
if (t.type == Token_NONE) {
|
if (token.type == Token_NONE) {
|
||||||
throw IfcParse::IfcException("Null token encountered, premature end of file?");
|
throw IfcParse::IfcException("Null token encountered, premature end of file?");
|
||||||
}
|
}
|
||||||
std::string& str = t.lexer->GetTempString();
|
std::string& str = token.lexer->GetTempString();
|
||||||
t.lexer->TokenString(t.startPos, str);
|
token.lexer->TokenString(token.startPos, str);
|
||||||
if ((isString(t) || isEnumeration(t) || isBinary(t)) && !str.empty()) {
|
if ((isString(token) || isEnumeration(token) || isBinary(token)) && !str.empty()) {
|
||||||
//remove start+end characters in-place
|
//remove start+end characters in-place
|
||||||
str.erase(str.end() - 1);
|
str.erase(str.end() - 1);
|
||||||
str.erase(str.begin());
|
str.erase(str.begin());
|
||||||
@@ -609,15 +631,15 @@ const std::string& TokenFunc::asStringRef(const Token& t) {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TokenFunc::asString(const Token& t) {
|
std::string TokenFunc::asString(const Token& token) {
|
||||||
if (isString(t) || isEnumeration(t) || isBinary(t)) {
|
if (isString(token) || isEnumeration(token) || isBinary(token)) {
|
||||||
return asStringRef(t);
|
return asStringRef(token);
|
||||||
}
|
}
|
||||||
throw IfcInvalidTokenException(t.startPos, toString(t), "string");
|
throw IfcInvalidTokenException(token.startPos, toString(token), "string");
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::dynamic_bitset<> TokenFunc::asBinary(const Token& t) {
|
boost::dynamic_bitset<> TokenFunc::asBinary(const Token& token) {
|
||||||
const std::string& str = asStringRef(t);
|
const std::string& str = asStringRef(token);
|
||||||
if (str.size() < 1) {
|
if (str.size() < 1) {
|
||||||
throw IfcException("Token is not a valid binary sequence");
|
throw IfcException("Token is not a valid binary sequence");
|
||||||
}
|
}
|
||||||
@@ -648,19 +670,19 @@ boost::dynamic_bitset<> TokenFunc::asBinary(const Token& t) {
|
|||||||
return bitset;
|
return bitset;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TokenFunc::toString(const Token& t) {
|
std::string TokenFunc::toString(const Token& token) {
|
||||||
std::string result;
|
std::string result;
|
||||||
t.lexer->TokenString(t.startPos, result);
|
token.lexer->TokenString(token.startPos, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenArgument::TokenArgument(const Token& t) {
|
TokenArgument::TokenArgument(const Token& tok) {
|
||||||
token = t;
|
token = tok;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityArgument::EntityArgument(const Token& t) {
|
EntityArgument::EntityArgument(const Token& token) {
|
||||||
IfcParse::IfcFile* file = t.lexer->file;
|
IfcParse::IfcFile* file = token.lexer->file;
|
||||||
IfcEntityInstanceData* data = read(0, file, t.startPos);
|
IfcEntityInstanceData* data = read(0, file, token.startPos);
|
||||||
// Data needs to be loaded, for the tokens
|
// Data needs to be loaded, for the tokens
|
||||||
// to be consumed and parsing to continue.
|
// to be consumed and parsing to continue.
|
||||||
data->load();
|
data->load();
|
||||||
@@ -687,12 +709,12 @@ class vector_or_array {
|
|||||||
size_(size),
|
size_(size),
|
||||||
index_(0) {}
|
index_(0) {}
|
||||||
|
|
||||||
void push_back(const T& t) {
|
void push_back(const T& type) {
|
||||||
// @todo this should log a warning when the size is exceeded
|
// @todo this should log a warning when the size is exceeded
|
||||||
if (array_ && index_ < size_) {
|
if (array_ && index_ < size_) {
|
||||||
array_[index_++] = t;
|
array_[index_++] = type;
|
||||||
} else if (vector_) {
|
} else if (vector_) {
|
||||||
vector_->push_back(t);
|
vector_->push_back(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -755,9 +777,9 @@ size_t IfcParse::IfcFile::load(unsigned entity_instance_name, const IfcParse::en
|
|||||||
|
|
||||||
if (TokenFunc::isKeyword(next)) {
|
if (TokenFunc::isKeyword(next)) {
|
||||||
try {
|
try {
|
||||||
auto* ea = new EntityArgument(next);
|
auto* entity = new EntityArgument(next);
|
||||||
addEntity(((IfcUtil::IfcBaseClass*)*ea));
|
addEntity(((IfcUtil::IfcBaseClass*)*entity));
|
||||||
filler.push_back(ea);
|
filler.push_back(entity);
|
||||||
} catch (IfcException& e) {
|
} catch (IfcException& e) {
|
||||||
Logger::Message(Logger::LOG_ERROR, e.what());
|
Logger::Message(Logger::LOG_ERROR, e.what());
|
||||||
}
|
}
|
||||||
@@ -1069,26 +1091,26 @@ void IfcParse::IfcFile::register_inverse(unsigned id_from, const IfcParse::entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IfcParse::IfcFile::unregister_inverse(unsigned id_from, const IfcParse::entity* from_entity, IfcUtil::IfcBaseClass* inst, int attribute_index) {
|
void IfcParse::IfcFile::unregister_inverse(unsigned id_from, const IfcParse::entity* from_entity, IfcUtil::IfcBaseClass* inst, int attribute_index) {
|
||||||
const auto* e = from_entity;
|
const auto* entity = from_entity;
|
||||||
while (e != nullptr) {
|
while (entity != nullptr) {
|
||||||
std::vector<int>& ids = byref_[{inst->data().id(), e->index_in_schema(), attribute_index}];
|
std::vector<int>& ids = byref_[{inst->data().id(), entity->index_in_schema(), attribute_index}];
|
||||||
std::vector<int>::iterator it = std::find(ids.begin(), ids.end(), id_from);
|
std::vector<int>::iterator iter = std::find(ids.begin(), ids.end(), id_from);
|
||||||
if (it == ids.end()) {
|
if (iter == ids.end()) {
|
||||||
// @todo inverses also need to be populated when multiple instances are added to a new file.
|
// @todo inverses also need to be populated when multiple instances are added to a new file.
|
||||||
// throw IfcParse::IfcException("Instance not found among inverses");
|
// throw IfcParse::IfcException("Instance not found among inverses");
|
||||||
} else {
|
} else {
|
||||||
ids.erase(it);
|
ids.erase(iter);
|
||||||
}
|
}
|
||||||
e = e->supertype();
|
entity = entity->supertype();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int>& ids = byref_excl_[inst->data().id()];
|
std::vector<int>& ids = byref_excl_[inst->data().id()];
|
||||||
std::vector<int>::iterator it = std::find(ids.begin(), ids.end(), id_from);
|
std::vector<int>::iterator iter = std::find(ids.begin(), ids.end(), id_from);
|
||||||
if (it == ids.end()) {
|
if (iter == ids.end()) {
|
||||||
// @todo inverses also need to be populated when multiple instances are added to a new file.
|
// @todo inverses also need to be populated when multiple instances are added to a new file.
|
||||||
// throw IfcParse::IfcException("Instance not found among inverses");
|
// throw IfcParse::IfcException("Instance not found among inverses");
|
||||||
} else {
|
} else {
|
||||||
ids.erase(it);
|
ids.erase(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1158,15 +1180,15 @@ unsigned IfcEntityInstanceData::set_id(boost::optional<unsigned> i) {
|
|||||||
// Returns the entities of Entity type that have this entity in their ArgumentList
|
// Returns the entities of Entity type that have this entity in their ArgumentList
|
||||||
//
|
//
|
||||||
aggregate_of_instance::ptr IfcEntityInstanceData::getInverse(const IfcParse::declaration* type, int attribute_index) const {
|
aggregate_of_instance::ptr IfcEntityInstanceData::getInverse(const IfcParse::declaration* type, int attribute_index) const {
|
||||||
static std::mutex m;
|
static std::mutex mtx;
|
||||||
std::lock_guard<std::mutex> lk(m);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
|
|
||||||
return file->getInverse(id_, type, attribute_index);
|
return file->getInverse(id_, type, attribute_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcEntityInstanceData::load() const {
|
void IfcEntityInstanceData::load() const {
|
||||||
static std::recursive_mutex m;
|
static std::recursive_mutex mtx;
|
||||||
std::lock_guard<std::recursive_mutex> lk(m);
|
std::lock_guard<std::recursive_mutex> lockk(mtx);
|
||||||
|
|
||||||
Argument** tmp_data = nullptr;
|
Argument** tmp_data = nullptr;
|
||||||
|
|
||||||
@@ -1221,19 +1243,19 @@ IfcUtil::ArgumentType get_argument_type(const IfcParse::declaration* decl, size_
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
IfcEntityInstanceData::IfcEntityInstanceData(const IfcEntityInstanceData& e) {
|
IfcEntityInstanceData::IfcEntityInstanceData(const IfcEntityInstanceData& data) {
|
||||||
file = 0;
|
file = 0;
|
||||||
type_ = e.type_;
|
type_ = data.type_;
|
||||||
id_ = 0;
|
id_ = 0;
|
||||||
|
|
||||||
const size_t count = e.getArgumentCount();
|
const size_t count = data.getArgumentCount();
|
||||||
|
|
||||||
// In order not to have the instance read from file
|
// In order not to have the instance read from file
|
||||||
attributes_ = new Argument*[count];
|
attributes_ = new Argument*[count];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < count; ++i) {
|
for (unsigned int i = 0; i < count; ++i) {
|
||||||
attributes_[i] = 0;
|
attributes_[i] = 0;
|
||||||
this->setArgument(i, e.getArgument(i), get_argument_type(e.type(), i), true);
|
this->setArgument(i, data.getArgument(i), get_argument_type(data.type(), i), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1548,17 +1570,17 @@ IfcFile::IfcFile(const std::string& fn, bool mmap) {
|
|||||||
initialize_(new IfcSpfStream(fn, mmap));
|
initialize_(new IfcSpfStream(fn, mmap));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
IfcFile::IfcFile(const std::string& fn) {
|
IfcFile::IfcFile(const std::string& path) {
|
||||||
initialize_(new IfcSpfStream(fn));
|
initialize_(new IfcSpfStream(path));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IfcFile::IfcFile(std::istream& f, int len) {
|
IfcFile::IfcFile(std::istream& stream, int length) {
|
||||||
initialize_(new IfcSpfStream(f, len));
|
initialize_(new IfcSpfStream(stream, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcFile::IfcFile(void* data, int len) {
|
IfcFile::IfcFile(void* data, int length) {
|
||||||
initialize_(new IfcSpfStream(data, len));
|
initialize_(new IfcSpfStream(data, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcFile::IfcFile(IfcParse::IfcSpfStream* s) {
|
IfcFile::IfcFile(IfcParse::IfcSpfStream* s) {
|
||||||
@@ -1844,18 +1866,18 @@ void traversal_visitor::operator()(IfcUtil::IfcBaseClass* inst, int /* index */)
|
|||||||
|
|
||||||
aggregate_of_instance::ptr IfcParse::traverse(IfcUtil::IfcBaseClass* instance, int max_level) {
|
aggregate_of_instance::ptr IfcParse::traverse(IfcUtil::IfcBaseClass* instance, int max_level) {
|
||||||
std::set<IfcUtil::IfcBaseClass*> visited;
|
std::set<IfcUtil::IfcBaseClass*> visited;
|
||||||
traversal_recorder r(0);
|
traversal_recorder recorder(0);
|
||||||
traverse_(instance, visited, r, 0, max_level);
|
traverse_(instance, visited, recorder, 0, max_level);
|
||||||
return r.get_list();
|
return recorder.get_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
// I'm cheating this isn't breadth-first, but rather we record visited instances
|
// 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?
|
// keeping track of their rank and return a list ordered by rank. Is this equivalent?
|
||||||
aggregate_of_instance::ptr IfcParse::traverse_breadth_first(IfcUtil::IfcBaseClass* instance, int max_level) {
|
aggregate_of_instance::ptr IfcParse::traverse_breadth_first(IfcUtil::IfcBaseClass* instance, int max_level) {
|
||||||
std::set<IfcUtil::IfcBaseClass*> visited;
|
std::set<IfcUtil::IfcBaseClass*> visited;
|
||||||
traversal_recorder r(1);
|
traversal_recorder recorder(1);
|
||||||
traverse_(instance, visited, r, 0, max_level);
|
traverse_(instance, visited, recorder, 0, max_level);
|
||||||
return r.get_list();
|
return recorder.get_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @note: for backwards compatibility
|
/// @note: for backwards compatibility
|
||||||
@@ -1868,8 +1890,8 @@ aggregate_of_instance::ptr IfcFile::traverse_breadth_first(IfcUtil::IfcBaseClass
|
|||||||
return IfcParse::traverse_breadth_first(instance, max_level);
|
return IfcParse::traverse_breadth_first(instance, max_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcFile::addEntities(aggregate_of_instance::ptr es) {
|
void IfcFile::addEntities(aggregate_of_instance::ptr entities) {
|
||||||
for (aggregate_of_instance::it i = es->begin(); i != es->end(); ++i) {
|
for (aggregate_of_instance::it i = entities->begin(); i != entities->end(); ++i) {
|
||||||
addEntity(*i);
|
addEntity(*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2463,24 +2485,24 @@ struct id_instance_pair_sorter {
|
|||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const IfcParse::IfcFile& f) {
|
std::ostream& operator<<(std::ostream& out, const IfcParse::IfcFile& file) {
|
||||||
f.header().write(os);
|
file.header().write(out);
|
||||||
|
|
||||||
typedef std::vector<std::pair<unsigned int, IfcUtil::IfcBaseClass*>> vector_t;
|
typedef std::vector<std::pair<unsigned int, IfcUtil::IfcBaseClass*>> vector_t;
|
||||||
vector_t sorted(f.begin(), f.end());
|
vector_t sorted(file.begin(), file.end());
|
||||||
std::sort(sorted.begin(), sorted.end(), id_instance_pair_sorter());
|
std::sort(sorted.begin(), sorted.end(), id_instance_pair_sorter());
|
||||||
|
|
||||||
for (vector_t::const_iterator it = sorted.begin(); it != sorted.end(); ++it) {
|
for (vector_t::const_iterator it = sorted.begin(); it != sorted.end(); ++it) {
|
||||||
const IfcUtil::IfcBaseClass* e = it->second;
|
const IfcUtil::IfcBaseClass* e = it->second;
|
||||||
if (e->declaration().as_entity() != nullptr) {
|
if (e->declaration().as_entity() != nullptr) {
|
||||||
os << e->data().toString(true) << ";" << std::endl;
|
out << e->data().toString(true) << ";" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
os << "ENDSEC;" << std::endl;
|
out << "ENDSEC;" << std::endl;
|
||||||
os << "END-ISO-10303-21;" << std::endl;
|
out << "END-ISO-10303-21;" << std::endl;
|
||||||
|
|
||||||
return os;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string IfcFile::createTimestamp() const {
|
std::string IfcFile::createTimestamp() const {
|
||||||
@@ -2520,8 +2542,8 @@ std::vector<int> IfcFile::get_inverse_indices(int instance_id) {
|
|||||||
|
|
||||||
auto refs = instances_by_reference(instance_id);
|
auto refs = instances_by_reference(instance_id);
|
||||||
|
|
||||||
for (const auto& r : *refs) {
|
for (const auto& ref : *refs) {
|
||||||
auto it = mapping.find(r->data().id());
|
auto it = mapping.find(ref->data().id());
|
||||||
if (it == mapping.end() || it->second.empty()) {
|
if (it == mapping.end() || it->second.empty()) {
|
||||||
throw IfcException("Internal error");
|
throw IfcException("Internal error");
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-32
@@ -88,51 +88,51 @@ struct Token {
|
|||||||
/// Tokens are merely offsets to where they can be read in the file
|
/// Tokens are merely offsets to where they can be read in the file
|
||||||
class IFC_PARSE_API TokenFunc {
|
class IFC_PARSE_API TokenFunc {
|
||||||
private:
|
private:
|
||||||
static bool startsWith(const Token& t, char c);
|
static bool startsWith(const Token& token, char character);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Returns the offset at which the token is read from the file
|
/// Returns the offset at which the token is read from the file
|
||||||
// static unsigned int Offset(const Token& t);
|
// static unsigned int Offset(const Token& t);
|
||||||
/// Returns whether the token can be interpreted as a string
|
/// Returns whether the token can be interpreted as a string
|
||||||
static bool isString(const Token& t);
|
static bool isString(const Token& token);
|
||||||
/// Returns whether the token can be interpreted as an identifier
|
/// Returns whether the token can be interpreted as an identifier
|
||||||
static bool isIdentifier(const Token& t);
|
static bool isIdentifier(const Token& token);
|
||||||
/// Returns whether the token can be interpreted as a syntactical operator
|
/// Returns whether the token can be interpreted as a syntactical operator
|
||||||
static bool isOperator(const Token& t);
|
static bool isOperator(const Token& token);
|
||||||
/// Returns whether the token is a given operator
|
/// Returns whether the token is a given operator
|
||||||
static bool isOperator(const Token& t, char op);
|
static bool isOperator(const Token& token, char character);
|
||||||
/// Returns whether the token can be interpreted as an enumerated value
|
/// Returns whether the token can be interpreted as an enumerated value
|
||||||
static bool isEnumeration(const Token& t);
|
static bool isEnumeration(const Token& token);
|
||||||
/// Returns whether the token can be interpreted as a datatype name
|
/// Returns whether the token can be interpreted as a datatype name
|
||||||
static bool isKeyword(const Token& t);
|
static bool isKeyword(const Token& token);
|
||||||
/// Returns whether the token can be interpreted as an integer
|
/// Returns whether the token can be interpreted as an integer
|
||||||
static bool isInt(const Token& t);
|
static bool isInt(const Token& token);
|
||||||
/// Returns whether the token can be interpreted as a boolean
|
/// Returns whether the token can be interpreted as a boolean
|
||||||
static bool isBool(const Token& t);
|
static bool isBool(const Token& token);
|
||||||
/// Returns whether the token can be interpreted as a logical
|
/// Returns whether the token can be interpreted as a logical
|
||||||
static bool isLogical(const Token& t);
|
static bool isLogical(const Token& token);
|
||||||
/// Returns whether the token can be interpreted as a floating point number
|
/// Returns whether the token can be interpreted as a floating point number
|
||||||
static bool isFloat(const Token& t);
|
static bool isFloat(const Token& token);
|
||||||
/// Returns whether the token can be interpreted as a binary type
|
/// Returns whether the token can be interpreted as a binary type
|
||||||
static bool isBinary(const Token& t);
|
static bool isBinary(const Token& token);
|
||||||
/// Returns the token interpreted as an integer
|
/// Returns the token interpreted as an integer
|
||||||
static int asInt(const Token& t);
|
static int asInt(const Token& token);
|
||||||
/// Returns the token interpreted as an identifier
|
/// Returns the token interpreted as an identifier
|
||||||
static int asIdentifier(const Token& t);
|
static int asIdentifier(const Token& token);
|
||||||
/// Returns the token interpreted as an boolean (.T. or .F.)
|
/// Returns the token interpreted as an boolean (.T. or .F.)
|
||||||
static bool asBool(const Token& t);
|
static bool asBool(const Token& token);
|
||||||
/// Returns the token interpreted as an logical (.T. or .F. or .U.)
|
/// Returns the token interpreted as an logical (.T. or .F. or .U.)
|
||||||
static boost::logic::tribool asLogical(const Token& t);
|
static boost::logic::tribool asLogical(const Token& token);
|
||||||
/// Returns the token as a floating point number
|
/// Returns the token as a floating point number
|
||||||
static double asFloat(const Token& t);
|
static double asFloat(const Token& token);
|
||||||
/// Returns the token as a string (without the dot or apostrophe)
|
/// Returns the token as a string (without the dot or apostrophe)
|
||||||
static std::string asString(const Token& t);
|
static std::string asString(const Token& token);
|
||||||
/// Returns the token as a string in internal buffer (for optimization purposes)
|
/// Returns the token as a string in internal buffer (for optimization purposes)
|
||||||
static const std::string& asStringRef(const Token& t);
|
static const std::string& asStringRef(const Token& token);
|
||||||
/// Returns the token as a string (without the dot or apostrophe)
|
/// Returns the token as a string (without the dot or apostrophe)
|
||||||
static boost::dynamic_bitset<> asBinary(const Token& t);
|
static boost::dynamic_bitset<> asBinary(const Token& token);
|
||||||
/// Returns a string representation of the token (including the dot or apostrophe)
|
/// Returns a string representation of the token (including the dot or apostrophe)
|
||||||
static std::string toString(const Token& t);
|
static std::string toString(const Token& token);
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -152,12 +152,12 @@ class IFC_PARSE_API IfcSpfLexer {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
std::string& GetTempString() const {
|
std::string& GetTempString() const {
|
||||||
static my_thread_local std::string s;
|
static my_thread_local std::string string;
|
||||||
return s;
|
return string;
|
||||||
}
|
}
|
||||||
IfcSpfStream* stream;
|
IfcSpfStream* stream;
|
||||||
IfcFile* file;
|
IfcFile* file;
|
||||||
IfcSpfLexer(IfcSpfStream* s, IfcFile* f);
|
IfcSpfLexer(IfcSpfStream* stream, IfcFile* file);
|
||||||
Token Next();
|
Token Next();
|
||||||
~IfcSpfLexer();
|
~IfcSpfLexer();
|
||||||
void TokenString(unsigned int offset, std::string& result);
|
void TokenString(unsigned int offset, std::string& result);
|
||||||
@@ -178,7 +178,7 @@ class IFC_PARSE_API ArgumentList : public Argument {
|
|||||||
list_(new Argument* [size_] { 0 }) {}
|
list_(new Argument* [size_] { 0 }) {}
|
||||||
~ArgumentList();
|
~ArgumentList();
|
||||||
|
|
||||||
void read(IfcSpfLexer* t, std::vector<unsigned int>& ids);
|
void read(IfcSpfLexer* lexer, std::vector<unsigned int>& ids);
|
||||||
|
|
||||||
IfcUtil::ArgumentType type() const;
|
IfcUtil::ArgumentType type() const;
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ class IFC_PARSE_API ArgumentList : public Argument {
|
|||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
unsigned int size() const;
|
unsigned int size() const;
|
||||||
|
|
||||||
Argument* operator[](unsigned int i) const;
|
Argument* operator[](unsigned int index) const;
|
||||||
|
|
||||||
std::string toString(bool upper = false) const;
|
std::string toString(bool upper = false) const;
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ class IFC_PARSE_API NullArgument : public Argument {
|
|||||||
class IFC_PARSE_API TokenArgument : public Argument {
|
class IFC_PARSE_API TokenArgument : public Argument {
|
||||||
public:
|
public:
|
||||||
Token token;
|
Token token;
|
||||||
TokenArgument(const Token& t);
|
TokenArgument(const Token& token);
|
||||||
|
|
||||||
IfcUtil::ArgumentType type() const;
|
IfcUtil::ArgumentType type() const;
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ class IFC_PARSE_API TokenArgument : public Argument {
|
|||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
unsigned int size() const;
|
unsigned int size() const;
|
||||||
|
|
||||||
Argument* operator[](unsigned int i) const;
|
Argument* operator[](unsigned int index) const;
|
||||||
std::string toString(bool upper = false) const;
|
std::string toString(bool upper = false) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ class IFC_PARSE_API EntityArgument : public Argument {
|
|||||||
IfcUtil::IfcBaseClass* entity_;
|
IfcUtil::IfcBaseClass* entity_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EntityArgument(const Token& t);
|
EntityArgument(const Token& token);
|
||||||
~EntityArgument();
|
~EntityArgument();
|
||||||
|
|
||||||
IfcUtil::ArgumentType type() const;
|
IfcUtil::ArgumentType type() const;
|
||||||
@@ -258,17 +258,17 @@ class IFC_PARSE_API EntityArgument : public Argument {
|
|||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
unsigned int size() const;
|
unsigned int size() const;
|
||||||
|
|
||||||
Argument* operator[](unsigned int i) const;
|
Argument* operator[](unsigned int index) const;
|
||||||
std::string toString(bool upper = false) const;
|
std::string toString(bool upper = false) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
IFC_PARSE_API IfcEntityInstanceData* read(unsigned int i, IfcFile* t, boost::optional<unsigned> offset = boost::none);
|
IFC_PARSE_API IfcEntityInstanceData* read(unsigned int index, IfcFile* file, boost::optional<unsigned> offset = boost::none);
|
||||||
|
|
||||||
IFC_PARSE_API aggregate_of_instance::ptr traverse(IfcUtil::IfcBaseClass* instance, int max_level = -1);
|
IFC_PARSE_API aggregate_of_instance::ptr traverse(IfcUtil::IfcBaseClass* instance, int max_level = -1);
|
||||||
|
|
||||||
IFC_PARSE_API aggregate_of_instance::ptr traverse_breadth_first(IfcUtil::IfcBaseClass* instance, int max_level = -1);
|
IFC_PARSE_API aggregate_of_instance::ptr traverse_breadth_first(IfcUtil::IfcBaseClass* instance, int max_level = -1);
|
||||||
} // namespace IfcParse
|
} // namespace IfcParse
|
||||||
|
|
||||||
IFC_PARSE_API std::ostream& operator<<(std::ostream& os, const IfcParse::IfcFile& f);
|
IFC_PARSE_API std::ostream& operator<<(std::ostream& out, const IfcParse::IfcFile& file);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -56,53 +56,53 @@
|
|||||||
#include "Ifc4x3_add2.h"
|
#include "Ifc4x3_add2.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
double IfcParse::IfcSIPrefixToValue(const std::string& v) {
|
double IfcParse::IfcSIPrefixToValue(const std::string& prefix) {
|
||||||
if (v == "EXA") {
|
if (prefix == "EXA") {
|
||||||
return 1.e18;
|
return 1.e18;
|
||||||
}
|
}
|
||||||
if (v == "PETA") {
|
if (prefix == "PETA") {
|
||||||
return 1.e15;
|
return 1.e15;
|
||||||
}
|
}
|
||||||
if (v == "TERA") {
|
if (prefix == "TERA") {
|
||||||
return 1.e12;
|
return 1.e12;
|
||||||
}
|
}
|
||||||
if (v == "GIGA") {
|
if (prefix == "GIGA") {
|
||||||
return 1.e9;
|
return 1.e9;
|
||||||
}
|
}
|
||||||
if (v == "MEGA") {
|
if (prefix == "MEGA") {
|
||||||
return 1.e6;
|
return 1.e6;
|
||||||
}
|
}
|
||||||
if (v == "KILO") {
|
if (prefix == "KILO") {
|
||||||
return 1.e3;
|
return 1.e3;
|
||||||
}
|
}
|
||||||
if (v == "HECTO") {
|
if (prefix == "HECTO") {
|
||||||
return 1.e2;
|
return 1.e2;
|
||||||
}
|
}
|
||||||
if (v == "DECA") {
|
if (prefix == "DECA") {
|
||||||
return 1.e1;
|
return 1.e1;
|
||||||
}
|
}
|
||||||
if (v == "DECI") {
|
if (prefix == "DECI") {
|
||||||
return 1.e-1;
|
return 1.e-1;
|
||||||
}
|
}
|
||||||
if (v == "CENTI") {
|
if (prefix == "CENTI") {
|
||||||
return 1.e-2;
|
return 1.e-2;
|
||||||
}
|
}
|
||||||
if (v == "MILLI") {
|
if (prefix == "MILLI") {
|
||||||
return 1.e-3;
|
return 1.e-3;
|
||||||
}
|
}
|
||||||
if (v == "MICRO") {
|
if (prefix == "MICRO") {
|
||||||
return 1.e-6;
|
return 1.e-6;
|
||||||
}
|
}
|
||||||
if (v == "NANO") {
|
if (prefix == "NANO") {
|
||||||
return 1.e-9;
|
return 1.e-9;
|
||||||
}
|
}
|
||||||
if (v == "PICO") {
|
if (prefix == "PICO") {
|
||||||
return 1.e-12;
|
return 1.e-12;
|
||||||
}
|
}
|
||||||
if (v == "FEMTO") {
|
if (prefix == "FEMTO") {
|
||||||
return 1.e-15;
|
return 1.e-15;
|
||||||
}
|
}
|
||||||
if (v == "ATTO") {
|
if (prefix == "ATTO") {
|
||||||
return 1.e-18;
|
return 1.e-18;
|
||||||
}
|
}
|
||||||
return 1.;
|
return 1.;
|
||||||
@@ -119,8 +119,8 @@ double IfcParse::get_SI_equivalent(typename Schema::IfcNamedUnit* named_unit) {
|
|||||||
typename Schema::IfcUnit* component = factor->UnitComponent();
|
typename Schema::IfcUnit* component = factor->UnitComponent();
|
||||||
if (component->declaration().is(Schema::IfcSIUnit::Class())) {
|
if (component->declaration().is(Schema::IfcSIUnit::Class())) {
|
||||||
si_unit = component->template as<typename Schema::IfcSIUnit>();
|
si_unit = component->template as<typename Schema::IfcSIUnit>();
|
||||||
typename Schema::IfcValue* v = factor->ValueComponent();
|
typename Schema::IfcValue* value = factor->ValueComponent();
|
||||||
scale = *v->data().getArgument(0);
|
scale = *value->data().getArgument(0);
|
||||||
}
|
}
|
||||||
} else if (named_unit->declaration().is(Schema::IfcSIUnit::Class())) {
|
} else if (named_unit->declaration().is(Schema::IfcSIUnit::Class())) {
|
||||||
si_unit = named_unit->template as<typename Schema::IfcSIUnit>();
|
si_unit = named_unit->template as<typename Schema::IfcSIUnit>();
|
||||||
|
|||||||
+12
-12
@@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
bool IfcParse::declaration::is(const std::string& name) const {
|
bool IfcParse::declaration::is(const std::string& name) const {
|
||||||
const std::string* name_ptr = &name;
|
const std::string* name_ptr = &name;
|
||||||
if (std::any_of(name.begin(), name.end(), [](char c) { return std::islower(c); })) {
|
if (std::any_of(name.begin(), name.end(), [](char character) { return std::islower(character); })) {
|
||||||
temp_string_() = name;
|
temp_string_() = name;
|
||||||
boost::to_upper(temp_string_());
|
boost::to_upper(temp_string_());
|
||||||
name_ptr = &temp_string_();
|
name_ptr = &temp_string_();
|
||||||
@@ -76,9 +76,9 @@ bool IfcParse::declaration::is(const std::string& name) const {
|
|||||||
return this->as_entity()->supertype()->is(name);
|
return this->as_entity()->supertype()->is(name);
|
||||||
}
|
}
|
||||||
if (this->as_type_declaration() != nullptr) {
|
if (this->as_type_declaration() != nullptr) {
|
||||||
const IfcParse::named_type* nt = this->as_type_declaration()->declared_type()->as_named_type();
|
const IfcParse::named_type* named_type = this->as_type_declaration()->declared_type()->as_named_type();
|
||||||
if (nt != nullptr) {
|
if (named_type != nullptr) {
|
||||||
return nt->is(name);
|
return named_type->is(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,9 +94,9 @@ bool IfcParse::declaration::is(const IfcParse::declaration& decl) const {
|
|||||||
return this->as_entity()->supertype()->is(decl);
|
return this->as_entity()->supertype()->is(decl);
|
||||||
}
|
}
|
||||||
if (this->as_type_declaration() != nullptr) {
|
if (this->as_type_declaration() != nullptr) {
|
||||||
const IfcParse::named_type* nt = this->as_type_declaration()->declared_type()->as_named_type();
|
const IfcParse::named_type* named_type = this->as_type_declaration()->declared_type()->as_named_type();
|
||||||
if (nt != nullptr) {
|
if (named_type != nullptr) {
|
||||||
return nt->is(decl);
|
return named_type->is(decl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,8 +159,8 @@ IfcUtil::IfcBaseClass* IfcParse::schema_definition::instantiate(IfcEntityInstanc
|
|||||||
return new IfcUtil::IfcLateBoundEntity(data->type(), data);
|
return new IfcUtil::IfcLateBoundEntity(data->type(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcParse::register_schema(schema_definition* s) {
|
void IfcParse::register_schema(schema_definition* schema) {
|
||||||
schemas.insert({boost::to_upper_copy(s->name()), s});
|
schemas.insert({boost::to_upper_copy(schema->name()), schema});
|
||||||
}
|
}
|
||||||
|
|
||||||
const IfcParse::schema_definition* IfcParse::schema_by_name(const std::string& name) {
|
const IfcParse::schema_definition* IfcParse::schema_by_name(const std::string& name) {
|
||||||
@@ -202,11 +202,11 @@ const IfcParse::schema_definition* IfcParse::schema_by_name(const std::string& n
|
|||||||
Ifc4x3_add2::get_schema();
|
Ifc4x3_add2::get_schema();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::map<std::string, const IfcParse::schema_definition*>::const_iterator it = schemas.find(boost::to_upper_copy(name));
|
std::map<std::string, const IfcParse::schema_definition*>::const_iterator iter = schemas.find(boost::to_upper_copy(name));
|
||||||
if (it == schemas.end()) {
|
if (iter == schemas.end()) {
|
||||||
throw IfcParse::IfcException("No schema named " + name);
|
throw IfcParse::IfcException("No schema named " + name);
|
||||||
}
|
}
|
||||||
return it->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> IfcParse::schema_names() {
|
std::vector<std::string> IfcParse::schema_names() {
|
||||||
|
|||||||
+24
-24
@@ -147,8 +147,8 @@ class IFC_PARSE_API declaration {
|
|||||||
mutable const schema_definition* schema_;
|
mutable const schema_definition* schema_;
|
||||||
|
|
||||||
std::string& temp_string_() const {
|
std::string& temp_string_() const {
|
||||||
static my_thread_local std::string s;
|
static my_thread_local std::string string;
|
||||||
return s;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -226,14 +226,14 @@ class IFC_PARSE_API enumeration_type : public declaration {
|
|||||||
return enumeration_items_[i].c_str();
|
return enumeration_items_[i].c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t lookup_enum_offset(const std::string& s) const {
|
size_t lookup_enum_offset(const std::string& string) const {
|
||||||
size_t i = 0;
|
size_t index = 0;
|
||||||
for (auto it = enumeration_items_.begin(); it != enumeration_items_.end(); ++it, ++i) {
|
for (auto it = enumeration_items_.begin(); it != enumeration_items_.end(); ++it, ++index) {
|
||||||
if (s == *it) {
|
if (string == *it) {
|
||||||
return i;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw IfcParse::IfcException("Unable to find keyword in schema: " + s);
|
throw IfcParse::IfcException("Unable to find keyword in schema: " + string);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const enumeration_type* as_enumeration_type() const { return this; }
|
virtual const enumeration_type* as_enumeration_type() const { return this; }
|
||||||
@@ -404,10 +404,10 @@ class IFC_PARSE_API entity : public declaration {
|
|||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
index += current->attributes().size();
|
index += current->attributes().size();
|
||||||
} else {
|
} else {
|
||||||
std::vector<const attribute*>::const_iterator it;
|
std::vector<const attribute*>::const_iterator iter;
|
||||||
it = std::find(current->attributes().begin(), current->attributes().end(), attr);
|
iter = std::find(current->attributes().begin(), current->attributes().end(), attr);
|
||||||
if (it != current->attributes().end()) {
|
if (iter != current->attributes().end()) {
|
||||||
index = std::distance(current->attributes().begin(), it);
|
index = std::distance(current->attributes().begin(), iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ((current = current->supertype_) != 0);
|
} while ((current = current->supertype_) != 0);
|
||||||
@@ -422,10 +422,10 @@ class IFC_PARSE_API entity : public declaration {
|
|||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
index += current->attributes().size();
|
index += current->attributes().size();
|
||||||
} else {
|
} else {
|
||||||
std::vector<const attribute*>::const_iterator it;
|
std::vector<const attribute*>::const_iterator iter;
|
||||||
it = std::find_if(current->attributes().begin(), current->attributes().end(), cmp);
|
iter = std::find_if(current->attributes().begin(), current->attributes().end(), cmp);
|
||||||
if (it != current->attributes().end()) {
|
if (iter != current->attributes().end()) {
|
||||||
index = std::distance(current->attributes().begin(), it);
|
index = std::distance(current->attributes().begin(), iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ((current = current->supertype_) != 0);
|
} while ((current = current->supertype_) != 0);
|
||||||
@@ -464,16 +464,16 @@ class IFC_PARSE_API schema_definition {
|
|||||||
|
|
||||||
class declaration_by_index_sort {
|
class declaration_by_index_sort {
|
||||||
public:
|
public:
|
||||||
bool operator()(const declaration* a, const declaration* b) {
|
bool operator()(const declaration* lhs, const declaration* rhs) {
|
||||||
return a->index_in_schema() < b->index_in_schema();
|
return lhs->index_in_schema() < rhs->index_in_schema();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
instance_factory* factory_;
|
instance_factory* factory_;
|
||||||
|
|
||||||
std::string& temp_string_() const {
|
std::string& temp_string_() const {
|
||||||
static my_thread_local std::string s;
|
static my_thread_local std::string string;
|
||||||
return s;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -483,16 +483,16 @@ class IFC_PARSE_API schema_definition {
|
|||||||
|
|
||||||
const declaration* declaration_by_name(const std::string& name) const {
|
const declaration* declaration_by_name(const std::string& name) const {
|
||||||
const std::string* name_ptr = &name;
|
const std::string* name_ptr = &name;
|
||||||
if (std::any_of(name.begin(), name.end(), [](char c) { return std::islower(c); })) {
|
if (std::any_of(name.begin(), name.end(), [](char character) { return std::islower(character); })) {
|
||||||
temp_string_() = name;
|
temp_string_() = name;
|
||||||
boost::to_upper(temp_string_());
|
boost::to_upper(temp_string_());
|
||||||
name_ptr = &temp_string_();
|
name_ptr = &temp_string_();
|
||||||
}
|
}
|
||||||
std::vector<const declaration*>::const_iterator it = std::lower_bound(declarations_.begin(), declarations_.end(), *name_ptr, declaration_by_name_cmp());
|
std::vector<const declaration*>::const_iterator iter = std::lower_bound(declarations_.begin(), declarations_.end(), *name_ptr, declaration_by_name_cmp());
|
||||||
if (it == declarations_.end() || (**it).name_uc() != *name_ptr) {
|
if (iter == declarations_.end() || (**iter).name_uc() != *name_ptr) {
|
||||||
throw IfcParse::IfcException("Entity with name '" + name + "' not found in schema '" + name_ + "'");
|
throw IfcParse::IfcException("Entity with name '" + name + "' not found in schema '" + name_ + "'");
|
||||||
}
|
}
|
||||||
return *it;
|
return *iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
const declaration* declaration_by_name(int name) const {
|
const declaration* declaration_by_name(int name) const {
|
||||||
|
|||||||
@@ -113,21 +113,21 @@ bool IfcSpfHeader::tryRead() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcSpfHeader::write(std::ostream& os) const {
|
void IfcSpfHeader::write(std::ostream& out) const {
|
||||||
os << ISO_10303_21 << ";"
|
out << ISO_10303_21 << ";"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
os << HEADER << ";"
|
out << HEADER << ";"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
os << file_description().toString(true) << ";"
|
out << file_description().toString(true) << ";"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
os << file_name().toString(true) << ";"
|
out << file_name().toString(true) << ";"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
os << file_schema().toString(true) << ";"
|
out << file_schema().toString(true) << ";"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
os << ENDSEC << ";"
|
out << ENDSEC << ";"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
os << DATA << ";"
|
out << DATA << ";"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
const FileDescription& IfcSpfHeader::file_description() const {
|
const FileDescription& IfcSpfHeader::file_description() const {
|
||||||
|
|||||||
+10
-10
@@ -36,16 +36,16 @@ class IFC_PARSE_API HeaderEntity : public IfcEntityInstanceData {
|
|||||||
HeaderEntity(const char* const datatype, size_t size, IfcParse::IfcFile* file);
|
HeaderEntity(const char* const datatype, size_t size, IfcParse::IfcFile* file);
|
||||||
virtual ~HeaderEntity();
|
virtual ~HeaderEntity();
|
||||||
|
|
||||||
void setValue(unsigned int i, const std::string& s) {
|
void setValue(unsigned int index, const std::string& string) {
|
||||||
IfcWrite::IfcWriteArgument* argument = new IfcWrite::IfcWriteArgument;
|
IfcWrite::IfcWriteArgument* argument = new IfcWrite::IfcWriteArgument;
|
||||||
argument->set(s);
|
argument->set(string);
|
||||||
setArgument(i, argument);
|
setArgument(index, argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setValue(unsigned int i, const std::vector<std::string>& s) {
|
void setValue(unsigned int index, const std::vector<std::string>& strings) {
|
||||||
IfcWrite::IfcWriteArgument* argument = new IfcWrite::IfcWriteArgument;
|
IfcWrite::IfcWriteArgument* argument = new IfcWrite::IfcWriteArgument;
|
||||||
argument->set(s);
|
argument->set(strings);
|
||||||
setArgument(i, argument);
|
setArgument(index, argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -54,9 +54,9 @@ class IFC_PARSE_API HeaderEntity : public IfcEntityInstanceData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string toString(bool upper = false) const {
|
std::string toString(bool upper = false) const {
|
||||||
std::stringstream ss;
|
std::stringstream stream;
|
||||||
ss << datatype_ << IfcEntityInstanceData::toString(upper);
|
stream << datatype_ << IfcEntityInstanceData::toString(upper);
|
||||||
return ss.str();
|
return stream.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ class IFC_PARSE_API IfcSpfHeader {
|
|||||||
void read();
|
void read();
|
||||||
bool tryRead();
|
bool tryRead();
|
||||||
|
|
||||||
void write(std::ostream& os) const;
|
void write(std::ostream& out) const;
|
||||||
|
|
||||||
const FileDescription& file_description() const;
|
const FileDescription& file_description() const;
|
||||||
const FileName& file_name() const;
|
const FileName& file_name() const;
|
||||||
|
|||||||
@@ -54,12 +54,12 @@ class IFC_PARSE_API IfcSpfStream {
|
|||||||
bool eof;
|
bool eof;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
#ifdef USE_MMAP
|
#ifdef USE_MMAP
|
||||||
IfcSpfStream(const std::string& fn, bool mmap = false);
|
IfcSpfStream(const std::string& path, bool mmap = false);
|
||||||
#else
|
#else
|
||||||
IfcSpfStream(const std::string& fn);
|
IfcSpfStream(const std::string& path);
|
||||||
#endif
|
#endif
|
||||||
IfcSpfStream(std::istream& f, int len);
|
IfcSpfStream(std::istream& stream, int length);
|
||||||
IfcSpfStream(void* data, int len);
|
IfcSpfStream(void* data, int length);
|
||||||
~IfcSpfStream();
|
~IfcSpfStream();
|
||||||
/// Returns the character at the cursor
|
/// Returns the character at the cursor
|
||||||
char Peek();
|
char Peek();
|
||||||
|
|||||||
+18
-18
@@ -61,14 +61,14 @@
|
|||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
void aggregate_of_instance::push(IfcUtil::IfcBaseClass* l) {
|
void aggregate_of_instance::push(IfcUtil::IfcBaseClass* instance) {
|
||||||
if (l != nullptr) {
|
if (instance != nullptr) {
|
||||||
list_.push_back(l);
|
list_.push_back(instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void aggregate_of_instance::push(const aggregate_of_instance::ptr& l) {
|
void aggregate_of_instance::push(const aggregate_of_instance::ptr& instance) {
|
||||||
if (l) {
|
if (instance) {
|
||||||
for (it i = l->begin(); i != l->end(); ++i) {
|
for (it i = instance->begin(); i != instance->end(); ++i) {
|
||||||
if (*i != nullptr) {
|
if (*i != nullptr) {
|
||||||
list_.push_back(*i);
|
list_.push_back(*i);
|
||||||
}
|
}
|
||||||
@@ -86,9 +86,9 @@ bool aggregate_of_instance::contains(IfcUtil::IfcBaseClass* instance) const {
|
|||||||
return std::find(list_.begin(), list_.end(), instance) != list_.end();
|
return std::find(list_.begin(), list_.end(), instance) != list_.end();
|
||||||
}
|
}
|
||||||
void aggregate_of_instance::remove(IfcUtil::IfcBaseClass* instance) {
|
void aggregate_of_instance::remove(IfcUtil::IfcBaseClass* instance) {
|
||||||
std::vector<IfcUtil::IfcBaseClass*>::iterator it;
|
std::vector<IfcUtil::IfcBaseClass*>::iterator iter;
|
||||||
while ((it = std::find(list_.begin(), list_.end(), instance)) != list_.end()) {
|
while ((iter = std::find(list_.begin(), list_.end(), instance)) != list_.end()) {
|
||||||
list_.erase(it);
|
list_.erase(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,8 +168,8 @@ const char* IfcUtil::ArgumentTypeToString(ArgumentType argument_type) {
|
|||||||
return argument_type_string[static_cast<int>(argument_type)];
|
return argument_type_string[static_cast<int>(argument_type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfcUtil::valid_binary_string(const std::string& s) {
|
bool IfcUtil::valid_binary_string(const std::string& str) {
|
||||||
for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) {
|
for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) {
|
||||||
if (*it != '0' && *it != '1') {
|
if (*it != '0' && *it != '1') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -205,20 +205,20 @@ Argument* IfcUtil::IfcBaseEntity::get(const std::string& name) const {
|
|||||||
|
|
||||||
aggregate_of_instance::ptr IfcUtil::IfcBaseEntity::get_inverse(const std::string& name) const {
|
aggregate_of_instance::ptr IfcUtil::IfcBaseEntity::get_inverse(const std::string& name) const {
|
||||||
const std::vector<const IfcParse::inverse_attribute*> attrs = declaration().as_entity()->all_inverse_attributes();
|
const std::vector<const IfcParse::inverse_attribute*> attrs = declaration().as_entity()->all_inverse_attributes();
|
||||||
std::vector<const IfcParse::inverse_attribute*>::const_iterator it = attrs.begin();
|
std::vector<const IfcParse::inverse_attribute*>::const_iterator iter = attrs.begin();
|
||||||
for (; it != attrs.end(); ++it) {
|
for (; iter != attrs.end(); ++iter) {
|
||||||
if ((*it)->name() == name) {
|
if ((*iter)->name() == name) {
|
||||||
return data().getInverse(
|
return data().getInverse(
|
||||||
(*it)->entity_reference(),
|
(*iter)->entity_reference(),
|
||||||
(int)(*it)->entity_reference()->attribute_index((*it)->attribute_reference()));
|
(int)(*iter)->entity_reference()->attribute_index((*iter)->attribute_reference()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw IfcParse::IfcException(name + " not found on " + declaration().name());
|
throw IfcParse::IfcException(name + " not found on " + declaration().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcUtil::IfcBaseClass::data(IfcEntityInstanceData* d) {
|
void IfcUtil::IfcBaseClass::data(IfcEntityInstanceData* data) {
|
||||||
delete data_;
|
delete data_;
|
||||||
data_ = d;
|
data_ = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcUtil::ArgumentType IfcUtil::make_aggregate(IfcUtil::ArgumentType elem_type) {
|
IfcUtil::ArgumentType IfcUtil::make_aggregate(IfcUtil::ArgumentType elem_type) {
|
||||||
|
|||||||
+66
-66
@@ -57,17 +57,17 @@ class StringBuilderVisitor : public boost::static_visitor<void> {
|
|||||||
StringBuilderVisitor(const StringBuilderVisitor&); //N/A
|
StringBuilderVisitor(const StringBuilderVisitor&); //N/A
|
||||||
StringBuilderVisitor& operator=(const StringBuilderVisitor&); //N/A
|
StringBuilderVisitor& operator=(const StringBuilderVisitor&); //N/A
|
||||||
|
|
||||||
std::ostringstream& data;
|
std::ostringstream& data_;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void serialize(const std::vector<T>& i) {
|
void serialize(const std::vector<T>& i) {
|
||||||
data << "(";
|
data_ << "(";
|
||||||
for (typename std::vector<T>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
for (typename std::vector<T>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
||||||
if (it != i.begin()) {
|
if (it != i.begin()) {
|
||||||
data << ",";
|
data_ << ",";
|
||||||
}
|
}
|
||||||
data << *it;
|
data_ << *it;
|
||||||
}
|
}
|
||||||
data << ")";
|
data_ << ")";
|
||||||
}
|
}
|
||||||
// The REAL token definition from the IFC SPF standard does not necessarily match
|
// The REAL token definition from the IFC SPF standard does not necessarily match
|
||||||
// the output of the C++ ostream formatting operation.
|
// the output of the C++ ostream formatting operation.
|
||||||
@@ -115,25 +115,25 @@ class StringBuilderVisitor : public boost::static_visitor<void> {
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool upper;
|
bool upper_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StringBuilderVisitor(std::ostringstream& stream, bool upper = false)
|
StringBuilderVisitor(std::ostringstream& stream, bool upper = false)
|
||||||
: data(stream),
|
: data_(stream),
|
||||||
upper(upper) {}
|
upper_(upper) {}
|
||||||
void operator()(const boost::blank& /*i*/) { data << "$"; }
|
void operator()(const boost::blank& /*i*/) { data_ << "$"; }
|
||||||
void operator()(const IfcWriteArgument::Derived& /*i*/) { data << "*"; }
|
void operator()(const IfcWriteArgument::Derived& /*i*/) { data_ << "*"; }
|
||||||
void operator()(const int& i) { data << i; }
|
void operator()(const int& i) { data_ << i; }
|
||||||
void operator()(const bool& i) { data << (i ? ".T." : ".F."); }
|
void operator()(const bool& i) { data_ << (i ? ".T." : ".F."); }
|
||||||
void operator()(const boost::logic::tribool& i) { data << (i ? ".T." : (boost::logic::indeterminate(i) ? ".U." : ".F.")); }
|
void operator()(const boost::logic::tribool& i) { data_ << (i ? ".T." : (boost::logic::indeterminate(i) ? ".U." : ".F.")); }
|
||||||
void operator()(const double& i) { data << format_double(i); }
|
void operator()(const double& i) { data_ << format_double(i); }
|
||||||
void operator()(const boost::dynamic_bitset<>& i) { data << format_binary(i); }
|
void operator()(const boost::dynamic_bitset<>& i) { data_ << format_binary(i); }
|
||||||
void operator()(const std::string& i) {
|
void operator()(const std::string& i) {
|
||||||
std::string s = i;
|
std::string s = i;
|
||||||
if (upper) {
|
if (upper_) {
|
||||||
data << static_cast<std::string>(IfcCharacterEncoder(s));
|
data_ << static_cast<std::string>(IfcCharacterEncoder(s));
|
||||||
} else {
|
} else {
|
||||||
data << '\'' << s << '\'';
|
data_ << '\'' << s << '\'';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void operator()(const std::vector<int>& i);
|
void operator()(const std::vector<int>& i);
|
||||||
@@ -141,85 +141,85 @@ class StringBuilderVisitor : public boost::static_visitor<void> {
|
|||||||
void operator()(const std::vector<std::string>& i);
|
void operator()(const std::vector<std::string>& i);
|
||||||
void operator()(const std::vector<boost::dynamic_bitset<>>& i);
|
void operator()(const std::vector<boost::dynamic_bitset<>>& i);
|
||||||
void operator()(const IfcWriteArgument::EnumerationReference& i) {
|
void operator()(const IfcWriteArgument::EnumerationReference& i) {
|
||||||
data << "." << i.enumeration_value << ".";
|
data_ << "." << i.enumeration_value << ".";
|
||||||
}
|
}
|
||||||
void operator()(const IfcUtil::IfcBaseClass* const& i) {
|
void operator()(const IfcUtil::IfcBaseClass* const& i) {
|
||||||
const IfcEntityInstanceData& e = i->data();
|
const IfcEntityInstanceData& e = i->data();
|
||||||
if (e.type()->as_entity() == nullptr) {
|
if (e.type()->as_entity() == nullptr) {
|
||||||
data << e.toString(upper);
|
data_ << e.toString(upper_);
|
||||||
} else {
|
} else {
|
||||||
data << "#" << e.id();
|
data_ << "#" << e.id();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void operator()(const aggregate_of_instance::ptr& i) {
|
void operator()(const aggregate_of_instance::ptr& i) {
|
||||||
data << "(";
|
data_ << "(";
|
||||||
for (aggregate_of_instance::it it = i->begin(); it != i->end(); ++it) {
|
for (aggregate_of_instance::it it = i->begin(); it != i->end(); ++it) {
|
||||||
if (it != i->begin()) {
|
if (it != i->begin()) {
|
||||||
data << ",";
|
data_ << ",";
|
||||||
}
|
}
|
||||||
(*this)(*it);
|
(*this)(*it);
|
||||||
}
|
}
|
||||||
data << ")";
|
data_ << ")";
|
||||||
}
|
}
|
||||||
void operator()(const std::vector<std::vector<int>>& i);
|
void operator()(const std::vector<std::vector<int>>& i);
|
||||||
void operator()(const std::vector<std::vector<double>>& i);
|
void operator()(const std::vector<std::vector<double>>& i);
|
||||||
void operator()(const aggregate_of_aggregate_of_instance::ptr& i) {
|
void operator()(const aggregate_of_aggregate_of_instance::ptr& i) {
|
||||||
data << "(";
|
data_ << "(";
|
||||||
for (aggregate_of_aggregate_of_instance::outer_it outer_it = i->begin(); outer_it != i->end(); ++outer_it) {
|
for (aggregate_of_aggregate_of_instance::outer_it outer_it = i->begin(); outer_it != i->end(); ++outer_it) {
|
||||||
if (outer_it != i->begin()) {
|
if (outer_it != i->begin()) {
|
||||||
data << ",";
|
data_ << ",";
|
||||||
}
|
}
|
||||||
data << "(";
|
data_ << "(";
|
||||||
for (aggregate_of_aggregate_of_instance::inner_it inner_it = outer_it->begin(); inner_it != outer_it->end(); ++inner_it) {
|
for (aggregate_of_aggregate_of_instance::inner_it inner_it = outer_it->begin(); inner_it != outer_it->end(); ++inner_it) {
|
||||||
if (inner_it != outer_it->begin()) {
|
if (inner_it != outer_it->begin()) {
|
||||||
data << ",";
|
data_ << ",";
|
||||||
}
|
}
|
||||||
(*this)(*inner_it);
|
(*this)(*inner_it);
|
||||||
}
|
}
|
||||||
data << ")";
|
data_ << ")";
|
||||||
}
|
}
|
||||||
data << ")";
|
data_ << ")";
|
||||||
}
|
}
|
||||||
void operator()(const IfcWriteArgument::empty_aggregate_t&) const { data << "()"; }
|
void operator()(const IfcWriteArgument::empty_aggregate_t&) const { data_ << "()"; }
|
||||||
void operator()(const IfcWriteArgument::empty_aggregate_of_aggregate_t&) const { data << "()"; }
|
void operator()(const IfcWriteArgument::empty_aggregate_of_aggregate_t&) const { data_ << "()"; }
|
||||||
operator std::string() { return data.str(); }
|
operator std::string() { return data_.str(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void StringBuilderVisitor::serialize(const std::vector<std::string>& i) {
|
void StringBuilderVisitor::serialize(const std::vector<std::string>& i) {
|
||||||
data << "(";
|
data_ << "(";
|
||||||
for (std::vector<std::string>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
for (std::vector<std::string>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
||||||
if (it != i.begin()) {
|
if (it != i.begin()) {
|
||||||
data << ",";
|
data_ << ",";
|
||||||
}
|
}
|
||||||
std::string s = IfcCharacterEncoder(*it);
|
std::string encoder = IfcCharacterEncoder(*it);
|
||||||
data << s;
|
data_ << encoder;
|
||||||
}
|
}
|
||||||
data << ")";
|
data_ << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void StringBuilderVisitor::serialize(const std::vector<double>& i) {
|
void StringBuilderVisitor::serialize(const std::vector<double>& i) {
|
||||||
data << "(";
|
data_ << "(";
|
||||||
for (std::vector<double>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
for (std::vector<double>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
||||||
if (it != i.begin()) {
|
if (it != i.begin()) {
|
||||||
data << ",";
|
data_ << ",";
|
||||||
}
|
}
|
||||||
data << format_double(*it);
|
data_ << format_double(*it);
|
||||||
}
|
}
|
||||||
data << ")";
|
data_ << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void StringBuilderVisitor::serialize(const std::vector<boost::dynamic_bitset<>>& i) {
|
void StringBuilderVisitor::serialize(const std::vector<boost::dynamic_bitset<>>& i) {
|
||||||
data << "(";
|
data_ << "(";
|
||||||
for (std::vector<boost::dynamic_bitset<>>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
for (std::vector<boost::dynamic_bitset<>>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
||||||
if (it != i.begin()) {
|
if (it != i.begin()) {
|
||||||
data << ",";
|
data_ << ",";
|
||||||
}
|
}
|
||||||
data << format_binary(*it);
|
data_ << format_binary(*it);
|
||||||
}
|
}
|
||||||
data << ")";
|
data_ << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringBuilderVisitor::operator()(const std::vector<int>& i) { serialize(i); }
|
void StringBuilderVisitor::operator()(const std::vector<int>& i) { serialize(i); }
|
||||||
@@ -227,24 +227,24 @@ void StringBuilderVisitor::operator()(const std::vector<double>& i) { serialize(
|
|||||||
void StringBuilderVisitor::operator()(const std::vector<std::string>& 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<boost::dynamic_bitset<>>& i) { serialize(i); }
|
||||||
void StringBuilderVisitor::operator()(const std::vector<std::vector<int>>& i) {
|
void StringBuilderVisitor::operator()(const std::vector<std::vector<int>>& i) {
|
||||||
data << "(";
|
data_ << "(";
|
||||||
for (std::vector<std::vector<int>>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
for (std::vector<std::vector<int>>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
||||||
if (it != i.begin()) {
|
if (it != i.begin()) {
|
||||||
data << ",";
|
data_ << ",";
|
||||||
}
|
}
|
||||||
serialize(*it);
|
serialize(*it);
|
||||||
}
|
}
|
||||||
data << ")";
|
data_ << ")";
|
||||||
}
|
}
|
||||||
void StringBuilderVisitor::operator()(const std::vector<std::vector<double>>& i) {
|
void StringBuilderVisitor::operator()(const std::vector<std::vector<double>>& i) {
|
||||||
data << "(";
|
data_ << "(";
|
||||||
for (std::vector<std::vector<double>>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
for (std::vector<std::vector<double>>::const_iterator it = i.begin(); it != i.end(); ++it) {
|
||||||
if (it != i.begin()) {
|
if (it != i.begin()) {
|
||||||
data << ",";
|
data_ << ",";
|
||||||
}
|
}
|
||||||
serialize(*it);
|
serialize(*it);
|
||||||
}
|
}
|
||||||
data << ")";
|
data_ << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcWriteArgument::operator int() const { return as<int>(); }
|
IfcWriteArgument::operator int() const { return as<int>(); }
|
||||||
@@ -272,13 +272,13 @@ Argument* IfcWriteArgument::operator[](unsigned int /*i*/) const { throw IfcPars
|
|||||||
std::string IfcWriteArgument::toString(bool upper) const {
|
std::string IfcWriteArgument::toString(bool upper) const {
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str.imbue(std::locale::classic());
|
str.imbue(std::locale::classic());
|
||||||
StringBuilderVisitor v(str, upper);
|
StringBuilderVisitor visitor(str, upper);
|
||||||
container_.apply_visitor(v);
|
container_.apply_visitor(visitor);
|
||||||
return v;
|
return visitor;
|
||||||
}
|
}
|
||||||
unsigned int IfcWriteArgument::size() const {
|
unsigned int IfcWriteArgument::size() const {
|
||||||
SizeVisitor v;
|
SizeVisitor visitor;
|
||||||
const int size = container_.apply_visitor(v);
|
const int size = container_.apply_visitor(visitor);
|
||||||
if (size == -1) {
|
if (size == -1) {
|
||||||
throw IfcParse::IfcException("Invalid cast");
|
throw IfcParse::IfcException("Invalid cast");
|
||||||
}
|
}
|
||||||
@@ -290,27 +290,27 @@ IfcUtil::ArgumentType IfcWriteArgument::type() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Overload to detect null values
|
// Overload to detect null values
|
||||||
void IfcWriteArgument::set(const aggregate_of_instance::ptr& v) {
|
void IfcWriteArgument::set(const aggregate_of_instance::ptr& value) {
|
||||||
if (v) {
|
if (value) {
|
||||||
container_ = v;
|
container_ = value;
|
||||||
} else {
|
} else {
|
||||||
container_ = boost::blank();
|
container_ = boost::blank();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overload to detect null values
|
// Overload to detect null values
|
||||||
void IfcWriteArgument::set(const aggregate_of_aggregate_of_instance::ptr& v) {
|
void IfcWriteArgument::set(const aggregate_of_aggregate_of_instance::ptr& value) {
|
||||||
if (v) {
|
if (value) {
|
||||||
container_ = v;
|
container_ = value;
|
||||||
} else {
|
} else {
|
||||||
container_ = boost::blank();
|
container_ = boost::blank();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overload to detect null values
|
// Overload to detect null values
|
||||||
void IfcWriteArgument::set(IfcUtil::IfcBaseInterface* const& v) {
|
void IfcWriteArgument::set(IfcUtil::IfcBaseInterface* const& value) {
|
||||||
if (v != nullptr) {
|
if (value != nullptr) {
|
||||||
container_ = v->as<IfcUtil::IfcBaseClass>();
|
container_ = value->as<IfcUtil::IfcBaseClass>();
|
||||||
} else {
|
} else {
|
||||||
container_ = boost::blank();
|
container_ = boost::blank();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,18 +128,18 @@ class IFC_PARSE_API IfcWriteArgument : public Argument {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename boost::disable_if<boost::is_base_of<IfcUtil::IfcBaseInterface, typename boost::remove_pointer<T>::type>, void>::type
|
typename boost::disable_if<boost::is_base_of<IfcUtil::IfcBaseInterface, typename boost::remove_pointer<T>::type>, void>::type
|
||||||
set(const T& t) {
|
set(const T& type) {
|
||||||
container_ = t;
|
container_ = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overload to detect null values
|
// Overload to detect null values
|
||||||
void set(const aggregate_of_instance::ptr& v);
|
void set(const aggregate_of_instance::ptr& value);
|
||||||
|
|
||||||
// Overload to detect null values
|
// Overload to detect null values
|
||||||
void set(const aggregate_of_aggregate_of_instance::ptr& v);
|
void set(const aggregate_of_aggregate_of_instance::ptr& value);
|
||||||
|
|
||||||
// Overload to detect null values
|
// Overload to detect null values
|
||||||
void set(IfcUtil::IfcBaseInterface* const& v);
|
void set(IfcUtil::IfcBaseInterface* const& value);
|
||||||
|
|
||||||
operator int() const;
|
operator int() const;
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
@@ -161,7 +161,7 @@ class IFC_PARSE_API IfcWriteArgument : public Argument {
|
|||||||
operator aggregate_of_aggregate_of_instance::ptr() const;
|
operator aggregate_of_aggregate_of_instance::ptr() const;
|
||||||
|
|
||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
Argument* operator[](unsigned int i) const;
|
Argument* operator[](unsigned int index) const;
|
||||||
std::string toString(bool upper = false) const;
|
std::string toString(bool upper = false) const;
|
||||||
unsigned int size() const;
|
unsigned int size() const;
|
||||||
IfcUtil::ArgumentType type() const;
|
IfcUtil::ArgumentType type() const;
|
||||||
|
|||||||
@@ -34,23 +34,23 @@ class IFC_PARSE_API aggregate_of_instance {
|
|||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<aggregate_of_instance> ptr;
|
typedef boost::shared_ptr<aggregate_of_instance> ptr;
|
||||||
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator it;
|
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator it;
|
||||||
void push(IfcUtil::IfcBaseClass* l);
|
void push(IfcUtil::IfcBaseClass* instance);
|
||||||
void push(const ptr& l);
|
void push(const ptr& instance);
|
||||||
it begin();
|
it begin();
|
||||||
it end();
|
it end();
|
||||||
IfcUtil::IfcBaseClass* operator[](int i);
|
IfcUtil::IfcBaseClass* operator[](int index);
|
||||||
unsigned int size() const;
|
unsigned int size() const;
|
||||||
void reserve(unsigned capacity);
|
void reserve(unsigned capacity);
|
||||||
bool contains(IfcUtil::IfcBaseClass*) const;
|
bool contains(IfcUtil::IfcBaseClass*) const;
|
||||||
template <class U>
|
template <class U>
|
||||||
typename U::list::ptr as() {
|
typename U::list::ptr as() {
|
||||||
typename U::list::ptr r(new typename U::list);
|
typename U::list::ptr result(new typename U::list);
|
||||||
for (it i = begin(); i != end(); ++i) {
|
for (it i = begin(); i != end(); ++i) {
|
||||||
if ((*i)->as<U>()) {
|
if ((*i)->as<U>()) {
|
||||||
r->push((*i)->as<U>());
|
result->push((*i)->as<U>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
void remove(IfcUtil::IfcBaseClass*);
|
void remove(IfcUtil::IfcBaseClass*);
|
||||||
aggregate_of_instance::ptr filtered(const std::set<const IfcParse::declaration*>& entities);
|
aggregate_of_instance::ptr filtered(const std::set<const IfcParse::declaration*>& entities);
|
||||||
@@ -64,14 +64,14 @@ class aggregate_of {
|
|||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<aggregate_of<T>> ptr;
|
typedef boost::shared_ptr<aggregate_of<T>> ptr;
|
||||||
typedef typename std::vector<T*>::const_iterator it;
|
typedef typename std::vector<T*>::const_iterator it;
|
||||||
void push(T* t) {
|
void push(T* type) {
|
||||||
if (t) {
|
if (type) {
|
||||||
list_.push_back(t);
|
list_.push_back(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void push(ptr t) {
|
void push(ptr instance) {
|
||||||
if (t) {
|
if (instance) {
|
||||||
for (typename T::list::it it = t->begin(); it != t->end(); ++it) {
|
for (typename T::list::it it = instance->begin(); it != instance->end(); ++it) {
|
||||||
push(*it);
|
push(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,28 +80,28 @@ class aggregate_of {
|
|||||||
it end() { return list_.end(); }
|
it end() { return list_.end(); }
|
||||||
unsigned int size() const { return (unsigned int)list_.size(); }
|
unsigned int size() const { return (unsigned int)list_.size(); }
|
||||||
aggregate_of_instance::ptr generalize() {
|
aggregate_of_instance::ptr generalize() {
|
||||||
aggregate_of_instance::ptr r(new aggregate_of_instance());
|
aggregate_of_instance::ptr result(new aggregate_of_instance());
|
||||||
for (it i = begin(); i != end(); ++i) {
|
for (it i = begin(); i != end(); ++i) {
|
||||||
r->push((*i)->template as<IfcUtil::IfcBaseClass>());
|
result->push((*i)->template as<IfcUtil::IfcBaseClass>());
|
||||||
}
|
}
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
bool contains(T* t) const { return std::find(list_.begin(), list_.end(), t) != list_.end(); }
|
bool contains(T* type) const { return std::find(list_.begin(), list_.end(), type) != list_.end(); }
|
||||||
template <class U>
|
template <class U>
|
||||||
typename U::list::ptr as() {
|
typename U::list::ptr as() {
|
||||||
typename U::list::ptr r(new typename U::list);
|
typename U::list::ptr result(new typename U::list);
|
||||||
const bool all = !U::Class().as_entity();
|
const bool all = !U::Class().as_entity();
|
||||||
for (it i = begin(); i != end(); ++i) {
|
for (it i = begin(); i != end(); ++i) {
|
||||||
if (all || (*i)->declaration().is(U::Class())) {
|
if (all || (*i)->declaration().is(U::Class())) {
|
||||||
r->push((U*)*i);
|
result->push((U*)*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
void remove(T* t) {
|
void remove(T* type) {
|
||||||
typename std::vector<T*>::iterator it;
|
typename std::vector<T*>::iterator iter;
|
||||||
while ((it = std::find(list_.begin(), list_.end(), t)) != list_.end()) {
|
while ((iter = std::find(list_.begin(), list_.end(), type)) != list_.end()) {
|
||||||
list_.erase(it);
|
list_.erase(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -116,16 +116,16 @@ class IFC_PARSE_API aggregate_of_aggregate_of_instance {
|
|||||||
typedef boost::shared_ptr<aggregate_of_aggregate_of_instance> ptr;
|
typedef boost::shared_ptr<aggregate_of_aggregate_of_instance> ptr;
|
||||||
typedef std::vector<std::vector<IfcUtil::IfcBaseClass*>>::const_iterator outer_it;
|
typedef std::vector<std::vector<IfcUtil::IfcBaseClass*>>::const_iterator outer_it;
|
||||||
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator inner_it;
|
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator inner_it;
|
||||||
void push(const std::vector<IfcUtil::IfcBaseClass*>& l) {
|
void push(const std::vector<IfcUtil::IfcBaseClass*>& instance) {
|
||||||
list_.push_back(l);
|
list_.push_back(instance);
|
||||||
}
|
}
|
||||||
void push(const aggregate_of_instance::ptr& l) {
|
void push(const aggregate_of_instance::ptr& instance) {
|
||||||
if (l) {
|
if (instance) {
|
||||||
std::vector<IfcUtil::IfcBaseClass*> li;
|
std::vector<IfcUtil::IfcBaseClass*> list;
|
||||||
for (std::vector<IfcUtil::IfcBaseClass*>::const_iterator jt = l->begin(); jt != l->end(); ++jt) {
|
for (std::vector<IfcUtil::IfcBaseClass*>::const_iterator iter = instance->begin(); iter != instance->end(); ++iter) {
|
||||||
li.push_back(*jt);
|
list.push_back(*iter);
|
||||||
}
|
}
|
||||||
push(li);
|
push(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outer_it begin() const { return list_.begin(); }
|
outer_it begin() const { return list_.begin(); }
|
||||||
@@ -149,7 +149,7 @@ class IFC_PARSE_API aggregate_of_aggregate_of_instance {
|
|||||||
}
|
}
|
||||||
template <class U>
|
template <class U>
|
||||||
typename aggregate_of_aggregate_of<U>::ptr as() {
|
typename aggregate_of_aggregate_of<U>::ptr as() {
|
||||||
typename aggregate_of_aggregate_of<U>::ptr r(new aggregate_of_aggregate_of<U>);
|
typename aggregate_of_aggregate_of<U>::ptr result(new aggregate_of_aggregate_of<U>);
|
||||||
const bool all = !U::Class().as_entity();
|
const bool all = !U::Class().as_entity();
|
||||||
for (outer_it outer = begin(); outer != end(); ++outer) {
|
for (outer_it outer = begin(); outer != end(); ++outer) {
|
||||||
const std::vector<IfcUtil::IfcBaseClass*>& from = *outer;
|
const std::vector<IfcUtil::IfcBaseClass*>& from = *outer;
|
||||||
@@ -159,9 +159,9 @@ class IFC_PARSE_API aggregate_of_aggregate_of_instance {
|
|||||||
to.push_back((U*)*inner);
|
to.push_back((U*)*inner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r->push(to);
|
result->push(to);
|
||||||
}
|
}
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ class aggregate_of_aggregate_of {
|
|||||||
typedef typename boost::shared_ptr<aggregate_of_aggregate_of<T>> ptr;
|
typedef typename boost::shared_ptr<aggregate_of_aggregate_of<T>> ptr;
|
||||||
typedef typename std::vector<std::vector<T*>>::const_iterator outer_it;
|
typedef typename std::vector<std::vector<T*>>::const_iterator outer_it;
|
||||||
typedef typename std::vector<T*>::const_iterator inner_it;
|
typedef typename std::vector<T*>::const_iterator inner_it;
|
||||||
void push(const std::vector<T*>& t) { list_.push_back(t); }
|
void push(const std::vector<T*>& type) { list_.push_back(type); }
|
||||||
outer_it begin() { return list_.begin(); }
|
outer_it begin() { return list_.begin(); }
|
||||||
outer_it end() { return list_.end(); }
|
outer_it end() { return list_.end(); }
|
||||||
int size() const { return (int)list_.size(); }
|
int size() const { return (int)list_.size(); }
|
||||||
@@ -184,26 +184,26 @@ class aggregate_of_aggregate_of {
|
|||||||
}
|
}
|
||||||
return accum;
|
return accum;
|
||||||
}
|
}
|
||||||
bool contains(T* t) const {
|
bool contains(T* type) const {
|
||||||
for (outer_it it = begin(); it != end(); ++it) {
|
for (outer_it iter = begin(); iter != end(); ++iter) {
|
||||||
const std::vector<T*>& inner = *it;
|
const std::vector<T*>& inner = *iter;
|
||||||
if (std::find(inner.begin(), inner.end(), t) != inner.end()) {
|
if (std::find(inner.begin(), inner.end(), type) != inner.end()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
aggregate_of_aggregate_of_instance::ptr generalize() {
|
aggregate_of_aggregate_of_instance::ptr generalize() {
|
||||||
aggregate_of_aggregate_of_instance::ptr r(new aggregate_of_aggregate_of_instance());
|
aggregate_of_aggregate_of_instance::ptr result(new aggregate_of_aggregate_of_instance());
|
||||||
for (outer_it outer = begin(); outer != end(); ++outer) {
|
for (outer_it outer = begin(); outer != end(); ++outer) {
|
||||||
const std::vector<T*>& from = *outer;
|
const std::vector<T*>& from = *outer;
|
||||||
std::vector<IfcUtil::IfcBaseClass*> to;
|
std::vector<IfcUtil::IfcBaseClass*> to;
|
||||||
for (inner_it inner = from.begin(); inner != from.end(); ++inner) {
|
for (inner_it inner = from.begin(); inner != from.end(); ++inner) {
|
||||||
to.push_back(*inner);
|
to.push_back(*inner);
|
||||||
}
|
}
|
||||||
r->push(to);
|
result->push(to);
|
||||||
}
|
}
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -91,64 +91,64 @@ class stack_node {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static stack_node instance(const std::string& id_in_file, IfcUtil::IfcBaseClass* inst) {
|
static stack_node instance(const std::string& id_in_file, IfcUtil::IfcBaseClass* inst) {
|
||||||
stack_node n;
|
stack_node node;
|
||||||
n.type_ = node_instance;
|
node.type_ = node_instance;
|
||||||
n.inst_ = inst;
|
node.inst_ = inst;
|
||||||
n.id_in_file_ = id_in_file;
|
node.id_in_file_ = id_in_file;
|
||||||
return n;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static stack_node instance_attribute(IfcUtil::IfcBaseClass* inst, int idx) {
|
static stack_node instance_attribute(IfcUtil::IfcBaseClass* inst, int idx) {
|
||||||
stack_node n;
|
stack_node node;
|
||||||
n.type_ = node_instance_attribute;
|
node.type_ = node_instance_attribute;
|
||||||
n.inst_ = inst;
|
node.inst_ = inst;
|
||||||
n.idx_ = idx;
|
node.idx_ = idx;
|
||||||
return n;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static stack_node aggregate(IfcUtil::IfcBaseClass* inst, int idx) {
|
static stack_node aggregate(IfcUtil::IfcBaseClass* inst, int idx) {
|
||||||
stack_node n;
|
stack_node node;
|
||||||
n.type_ = node_aggregate;
|
node.type_ = node_aggregate;
|
||||||
n.inst_ = inst;
|
node.inst_ = inst;
|
||||||
n.idx_ = idx;
|
node.idx_ = idx;
|
||||||
return n;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static stack_node aggregate_element(const IfcParse::parameter_type* aggregate_elem_type, int idx) {
|
static stack_node aggregate_element(const IfcParse::parameter_type* aggregate_elem_type, int idx) {
|
||||||
stack_node n;
|
stack_node node;
|
||||||
n.type_ = node_aggregate_element;
|
node.type_ = node_aggregate_element;
|
||||||
n.idx_ = idx;
|
node.idx_ = idx;
|
||||||
n.aggregate_elem_type_ = aggregate_elem_type;
|
node.aggregate_elem_type_ = aggregate_elem_type;
|
||||||
return n;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static stack_node inverse(IfcUtil::IfcBaseClass* inst, const IfcParse::inverse_attribute* inv) {
|
static stack_node inverse(IfcUtil::IfcBaseClass* inst, const IfcParse::inverse_attribute* inv) {
|
||||||
stack_node n;
|
stack_node node;
|
||||||
n.type_ = node_inverse;
|
node.type_ = node_inverse;
|
||||||
n.inst_ = inst;
|
node.inst_ = inst;
|
||||||
n.inv_ = inv;
|
node.inv_ = inv;
|
||||||
return n;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static stack_node select(IfcUtil::IfcBaseClass* inst, int idx) {
|
static stack_node select(IfcUtil::IfcBaseClass* inst, int idx) {
|
||||||
stack_node n;
|
stack_node node;
|
||||||
n.type_ = node_select;
|
node.type_ = node_select;
|
||||||
n.inst_ = inst;
|
node.inst_ = inst;
|
||||||
n.idx_ = idx;
|
node.idx_ = idx;
|
||||||
return n;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static stack_node header() {
|
static stack_node header() {
|
||||||
stack_node n;
|
stack_node node;
|
||||||
n.type_ = node_header;
|
node.type_ = node_header;
|
||||||
return n;
|
return node;
|
||||||
};
|
};
|
||||||
|
|
||||||
static stack_node header_entry(const std::string& tagname) {
|
static stack_node header_entry(const std::string& tagname) {
|
||||||
stack_node n;
|
stack_node node;
|
||||||
n.type_ = node_header_entry;
|
node.type_ = node_header_entry;
|
||||||
n.tagname_ = tagname;
|
node.tagname_ = tagname;
|
||||||
return n;
|
return node;
|
||||||
};
|
};
|
||||||
|
|
||||||
node_type ntype() const { return type_; }
|
node_type ntype() const { return type_; }
|
||||||
@@ -161,19 +161,19 @@ class stack_node {
|
|||||||
const IfcParse::parameter_type* aggregate_elem_type() const { return aggregate_elem_type_; }
|
const IfcParse::parameter_type* aggregate_elem_type() const { return aggregate_elem_type_; }
|
||||||
|
|
||||||
std::string repr() const {
|
std::string repr() const {
|
||||||
std::stringstream ss;
|
std::stringstream stream;
|
||||||
static const char* const node_type_names[] = {"empty", "inst", "attr", "aggr", "agelem", "inv", "sel", "head", "hdentry"};
|
static const char* const node_type_names[] = {"empty", "inst", "attr", "aggr", "agelem", "inv", "sel", "head", "hdentry"};
|
||||||
ss << "[" << node_type_names[type_] << "] ";
|
stream << "[" << node_type_names[type_] << "] ";
|
||||||
if (inst_ != nullptr) {
|
if (inst_ != nullptr) {
|
||||||
ss << inst_->declaration().name() << " ";
|
stream << inst_->declaration().name() << " ";
|
||||||
}
|
}
|
||||||
if (type_ == node_aggregate) {
|
if (type_ == node_aggregate) {
|
||||||
ss << "{" << aggregate_elements.size() << " elems} ";
|
stream << "{" << aggregate_elements.size() << " elems} ";
|
||||||
}
|
}
|
||||||
if (idx_ != -1) {
|
if (idx_ != -1) {
|
||||||
ss << idx_ << " ";
|
stream << idx_ << " ";
|
||||||
}
|
}
|
||||||
return ss.str();
|
return stream.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ template <typename T>
|
|||||||
std::vector<T> split(const std::string& value) {
|
std::vector<T> split(const std::string& value) {
|
||||||
std::vector<std::string> strs;
|
std::vector<std::string> strs;
|
||||||
boost::split(
|
boost::split(
|
||||||
strs, value, [](char c) { return c == ' '; }, boost::token_compress_on);
|
strs, value, [](char character) { return character == ' '; }, boost::token_compress_on);
|
||||||
std::vector<T> r(strs.size());
|
std::vector<T> r(strs.size());
|
||||||
boost::copy(strs | boost::adaptors::transformed([](const std::string& s) {
|
boost::copy(strs | boost::adaptors::transformed([](const std::string& s) {
|
||||||
return boost::lexical_cast<T>(s);
|
return boost::lexical_cast<T>(s);
|
||||||
@@ -209,13 +209,13 @@ Argument* parse_attribute_value(const IfcParse::parameter_type* ty, const std::s
|
|||||||
} else if (cpp_type == IfcUtil::Argument_ENUMERATION) {
|
} else if (cpp_type == IfcUtil::Argument_ENUMERATION) {
|
||||||
const auto* enum_type = ty->as_named_type()->declared_type()->as_enumeration_type();
|
const auto* enum_type = ty->as_named_type()->declared_type()->as_enumeration_type();
|
||||||
|
|
||||||
std::vector<std::string>::const_iterator it = std::find(
|
std::vector<std::string>::const_iterator iter = std::find(
|
||||||
enum_type->enumeration_items().begin(),
|
enum_type->enumeration_items().begin(),
|
||||||
enum_type->enumeration_items().end(),
|
enum_type->enumeration_items().end(),
|
||||||
boost::to_upper_copy(value));
|
boost::to_upper_copy(value));
|
||||||
|
|
||||||
if (it != enum_type->enumeration_items().end()) {
|
if (iter != enum_type->enumeration_items().end()) {
|
||||||
v->set(IfcWrite::IfcWriteArgument::EnumerationReference(it - enum_type->enumeration_items().begin(), it->c_str()));
|
v->set(IfcWrite::IfcWriteArgument::EnumerationReference(iter - enum_type->enumeration_items().begin(), iter->c_str()));
|
||||||
}
|
}
|
||||||
} else if (cpp_type == IfcUtil::Argument_INT) {
|
} else if (cpp_type == IfcUtil::Argument_INT) {
|
||||||
v->set(boost::lexical_cast<int>(value));
|
v->set(boost::lexical_cast<int>(value));
|
||||||
@@ -248,12 +248,12 @@ static void end_element(void* user, const xmlChar* tag) {
|
|||||||
if (!state->stack.empty() && state->stack.back().ntype() == stack_node::node_aggregate) {
|
if (!state->stack.empty() && state->stack.back().ntype() == stack_node::node_aggregate) {
|
||||||
const auto& back = state->stack.back();
|
const auto& back = state->stack.back();
|
||||||
auto& elems = state->stack.back().aggregate_elements;
|
auto& elems = state->stack.back().aggregate_elements;
|
||||||
auto* li = new IfcParse::ArgumentList(elems.size());
|
auto* list = new IfcParse::ArgumentList(elems.size());
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (auto& elem : elems) {
|
for (auto& elem : elems) {
|
||||||
li->arguments()[i++] = elem;
|
list->arguments()[i++] = elem;
|
||||||
}
|
}
|
||||||
back.inst()->data().attributes()[back.idx()] = li;
|
back.inst()->data().attributes()[back.idx()] = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->dialect == ifcxml_dialect_ifc2x3 && state->stack.back().ntype() == stack_node::node_instance) {
|
if (state->dialect == ifcxml_dialect_ifc2x3 && state->stack.back().ntype() == stack_node::node_instance) {
|
||||||
@@ -274,14 +274,14 @@ static void end_element(void* user, const xmlChar* tag) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_characters(void* user, const xmlChar* ch, int len) {
|
static void process_characters(void* user, const xmlChar* character, int len) {
|
||||||
ifcxml_parse_state* state = (ifcxml_parse_state*)user;
|
ifcxml_parse_state* state = (ifcxml_parse_state*)user;
|
||||||
|
|
||||||
if (state->file == nullptr) {
|
if (state->file == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string txt((char*)ch, len);
|
std::string txt((char*)character, len);
|
||||||
|
|
||||||
stack_node::node_type state_type = stack_node::stack_empty;
|
stack_node::node_type state_type = stack_node::stack_empty;
|
||||||
if (!state->stack.empty()) {
|
if (!state->stack.empty()) {
|
||||||
@@ -348,8 +348,8 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
|
|||||||
std::cout << "stack:" << std::endl;
|
std::cout << "stack:" << std::endl;
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (auto& n : state->stack) {
|
for (auto& node : state->stack) {
|
||||||
std::cout << " " << (i++) << ":" << n.repr() << std::endl;
|
std::cout << " " << (i++) << ":" << node.repr() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << std::string(state->stack.size(), ' ') << "<" << tagname << ">";
|
std::cout << std::string(state->stack.size(), ' ') << "<" << tagname << ">";
|
||||||
|
|||||||
Reference in New Issue
Block a user