From 71dcc96ac2bd9461a1adf391631d6389de387e3d Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 13 Oct 2017 14:51:09 +0200 Subject: [PATCH] Hacky support for LOGICAL --- src/ifcconvert/IfcConvert.cpp | 3 +++ src/ifcparse/IfcHdf5File.cpp | 25 ++++++++++++++++-------- src/ifcparse/IfcParse.cpp | 36 +++++++++++++++++++++++++++++++++++ src/ifcparse/IfcParse.h | 14 ++++++++++++++ src/ifcparse/IfcUtil.h | 15 ++++++++++++++- src/ifcparse/IfcWrite.cpp | 35 ++++++++++++++++++++++++++++++++++ src/ifcparse/IfcWrite.h | 9 +++++++++ 7 files changed, 128 insertions(+), 9 deletions(-) diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 71eafff711..eab063847e 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -26,6 +26,9 @@ * * ********************************************************************************/ +#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS +#define BOOST_MPL_LIMIT_LIST_SIZE 30 + #include #include #include diff --git a/src/ifcparse/IfcHdf5File.cpp b/src/ifcparse/IfcHdf5File.cpp index f11a1e75c1..560b43d27b 100644 --- a/src/ifcparse/IfcHdf5File.cpp +++ b/src/ifcparse/IfcHdf5File.cpp @@ -74,14 +74,16 @@ public: template struct is_hdf5_integral { static const bool value = false; }; template <> struct is_hdf5_integral { static const bool value = true; }; template <> struct is_hdf5_integral { static const bool value = true; }; +template <> struct is_hdf5_integral { static const bool value = true; }; template <> struct is_hdf5_integral { static const bool value = true; }; template <> struct is_hdf5_integral { static const bool value = true; }; template <> struct is_hdf5_integral { static const bool value = true; }; template struct hdf5_datatype_for{}; template <> struct hdf5_datatype_for { static const H5T_class_t value = H5T_INTEGER; }; -// Booleans are enumerations in HDF5 as well! +// Booleans and logicals are enumerations in HDF5 as well! template <> struct hdf5_datatype_for { static const H5T_class_t value = H5T_ENUM; }; +template <> struct hdf5_datatype_for { static const H5T_class_t value = H5T_ENUM; }; template <> struct hdf5_datatype_for { static const H5T_class_t value = H5T_FLOAT; }; template <> struct hdf5_datatype_for { static const H5T_class_t value = H5T_FLOAT; }; template <> struct hdf5_datatype_for { static const H5T_class_t value = H5T_ENUM; }; @@ -192,6 +194,13 @@ void write_number_of_size(void*& ptr, size_t n, T i) { } } +void write_number_of_size(void*& ptr, size_t n, boost::logic::tribool b) { + int i = b.value == boost::logic::tribool::false_value + ? 0 : b.value == boost::logic::tribool::indeterminate_value + ? -1 : 1; + write_number_of_size(ptr, n, i); +} + void write_string_of_size(void*& ptr, size_t n, const std::string& s) { memset(ptr, 0, n); memcpy(ptr, s.c_str(), s.size()); @@ -230,6 +239,7 @@ public: } CHECK_CAST_AND_CALL(IfcUtil::Argument_INT) CHECK_CAST_AND_CALL(IfcUtil::Argument_BOOL) + CHECK_CAST_AND_CALL(IfcUtil::Argument_TRIBOOL) CHECK_CAST_AND_CALL(IfcUtil::Argument_DOUBLE) CHECK_CAST_AND_CALL(IfcUtil::Argument_STRING) else if (attr_->type() == IfcUtil::Argument_BINARY) { @@ -246,6 +256,7 @@ public: CHECK_CAST_AND_CALL(IfcUtil::Argument_AGGREGATE_OF_INT) CHECK_CAST_AND_CALL(IfcUtil::Argument_AGGREGATE_OF_BOOL) + CHECK_CAST_AND_CALL(IfcUtil::Argument_AGGREGATE_OF_TRIBOOL) CHECK_CAST_AND_CALL(IfcUtil::Argument_AGGREGATE_OF_DOUBLE) CHECK_CAST_AND_CALL(IfcUtil::Argument_AGGREGATE_OF_STRING) else if (attr_->type() == IfcUtil::Argument_AGGREGATE_OF_BINARY) { @@ -259,6 +270,7 @@ public: CHECK_CAST_AND_CALL(IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT) CHECK_CAST_AND_CALL(IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL) + CHECK_CAST_AND_CALL(IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_TRIBOOL) CHECK_CAST_AND_CALL(IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE) else if (attr_->type() == IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE) { IfcUtil::attr_type_to_cpp_type::cpp_type v = *attr_; @@ -1985,20 +1997,17 @@ void visit(instance_resolver& resolver, std::ostream& output, void* buffer, H5:: } else if (dt->getClass() == H5T_FLOAT) { output << IfcWrite::format(read(buffer, dt)); } else if (dt->getClass() == H5T_ENUM) { - const char *enum_value; - char *to_free; - enum_value = to_free = H5Tget_member_name(dt->getId(), read(buffer, dt)); - char substr[2] = { 0,0 }; + char enum_value[255]; + H5Tenum_nameof(dt->getId(), buffer, enum_value, 255); const char BOOLEAN[] = "BOOLEAN-"; const char LOGICAL[] = "LOGICAL-"; if (strstr(enum_value, BOOLEAN) || strstr(enum_value, LOGICAL)) { // Hack to convert BOOLEAN-TRUE et al to T // Boolean and logical are of the same length coincedentally - substr[0] = enum_value[strlen(BOOLEAN)]; - enum_value = substr; + enum_value[0] = enum_value[strlen(BOOLEAN)]; + enum_value[1] = 0; } output << "." << enum_value << "."; - H5free_memory(to_free); } else { throw std::runtime_error("Unexpected datatype encountered"); } diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 5fede461fb..1706f94e6b 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -413,6 +413,12 @@ bool TokenFunc::isBool(const Token& t) { return str == "T" || str == "F"; } +bool TokenFunc::isLogical(const Token& t) { + if (!isEnumeration(t)) return false; + const std::string str = asString(t); + return str == "U"; // T and F covered as part of bool. +} + bool TokenFunc::isFloat(const Token& t) { if (isOperator(t) || isString(t) || isEnumeration(t)) { return false; @@ -443,6 +449,15 @@ bool TokenFunc::asBool(const Token& t) { return str == "T"; } +boost::logic::tribool TokenFunc::asLogical(const Token& t) { + if (isBool(t)) { + return asBool(t); + } else { + boost::logic::indeterminate_keyword_t x; + return boost::logic::tribool(x); + } +} + double TokenFunc::asFloat(const Token& t) { const std::string str = asString(t); const char* start = str.c_str(); @@ -553,6 +568,8 @@ IfcUtil::ArgumentType ArgumentList::type() const { return IfcUtil::Argument_AGGREGATE_OF_INT; } else if (elem_type == IfcUtil::Argument_BOOL) { return IfcUtil::Argument_AGGREGATE_OF_BOOL; + } else if (elem_type == IfcUtil::Argument_TRIBOOL) { + return IfcUtil::Argument_AGGREGATE_OF_TRIBOOL; } else if (elem_type == IfcUtil::Argument_DOUBLE) { return IfcUtil::Argument_AGGREGATE_OF_DOUBLE; } else if (elem_type == IfcUtil::Argument_STRING) { @@ -565,6 +582,8 @@ IfcUtil::ArgumentType ArgumentList::type() const { return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT; } else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_BOOL) { return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL; + } else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_TRIBOOL) { + return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_TRIBOOL; } else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_DOUBLE) { return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE; } else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) { @@ -605,6 +624,7 @@ std::vector< std::vector > read_aggregate_of_aggregate_as_vector2(const std:: // ArgumentList::operator int() const { throw IfcException("Argument is not an integer"); } ArgumentList::operator bool() const { throw IfcException("Argument is not a boolean"); } +ArgumentList::operator boost::logic::tribool() const { throw IfcException("Argument is not a boolean"); } ArgumentList::operator double() const { throw IfcException("Argument is not a number"); } ArgumentList::operator std::string() const { throw IfcException("Argument is not a string"); } ArgumentList::operator boost::dynamic_bitset<>() const { throw IfcException("Argument is not a binary"); } @@ -617,6 +637,10 @@ ArgumentList::operator std::vector() const { return read_aggregate_as_vector(list); } +ArgumentList::operator std::vector() const { + return read_aggregate_as_vector(list); +} + ArgumentList::operator std::vector() const { return read_aggregate_as_vector(list); } @@ -650,6 +674,10 @@ ArgumentList::operator std::vector< std::vector >() const { return read_aggregate_of_aggregate_as_vector2(list); } +ArgumentList::operator std::vector< std::vector >() const { + return read_aggregate_of_aggregate_as_vector2(list); +} + ArgumentList::operator std::vector< std::vector >() const { return read_aggregate_of_aggregate_as_vector2(list); } @@ -715,6 +743,8 @@ IfcUtil::ArgumentType TokenArgument::type() const { return IfcUtil::Argument_INT; } else if (TokenFunc::isBool(token)) { return IfcUtil::Argument_BOOL; + } else if (TokenFunc::isLogical(token)) { + return IfcUtil::Argument_TRIBOOL; } else if (TokenFunc::isFloat(token)) { return IfcUtil::Argument_DOUBLE; } else if (TokenFunc::isString(token)) { @@ -739,11 +769,13 @@ IfcUtil::ArgumentType TokenArgument::type() const { // TokenArgument::operator int() const { return TokenFunc::asInt(token); } TokenArgument::operator bool() const { return TokenFunc::asBool(token); } +TokenArgument::operator boost::logic::tribool() const { return TokenFunc::asLogical(token); } TokenArgument::operator double() const { return TokenFunc::asFloat(token); } TokenArgument::operator std::string() const { return TokenFunc::asString(token); } TokenArgument::operator boost::dynamic_bitset<>() const { return TokenFunc::asBinary(token); } TokenArgument::operator std::vector() const { throw IfcException("Argument is not a list of ints"); } TokenArgument::operator std::vector() const { throw IfcException("Argument is not a list of bools"); } +TokenArgument::operator std::vector() const { throw IfcException("Argument is not a list of logicals"); } TokenArgument::operator std::vector() const { throw IfcException("Argument is not a list of floats"); } TokenArgument::operator std::vector() const { throw IfcException("Argument is not a list of strings"); } TokenArgument::operator std::vector >() const { throw IfcException("Argument is not a list of binaries"); } @@ -751,6 +783,7 @@ TokenArgument::operator IfcUtil::IfcBaseClass*() const { return token.first->fil TokenArgument::operator IfcEntityList::ptr() const { throw IfcException("Argument is not a list of entity instances"); } TokenArgument::operator std::vector< std::vector >() const { throw IfcException("Argument is not a list of list of ints"); } TokenArgument::operator std::vector< std::vector >() const { throw IfcException("Argument is not a list of list of bools"); } +TokenArgument::operator std::vector< std::vector >() const { throw IfcException("Argument is not a list of list of logicals"); } TokenArgument::operator std::vector< std::vector >() const { throw IfcException("Argument is not a list of list of floats"); } TokenArgument::operator IfcEntityListList::ptr() const { throw IfcException("Argument is not a list of list of entity instances"); } unsigned int TokenArgument::size() const { return 1; } @@ -773,11 +806,13 @@ IfcUtil::ArgumentType EntityArgument::type() const { // EntityArgument::operator int() const { throw IfcException("Argument is not an integer"); } EntityArgument::operator bool() const { throw IfcException("Argument is not a boolean"); } +EntityArgument::operator boost::logic::tribool() const { throw IfcException("Argument is not a logical"); } EntityArgument::operator double() const { throw IfcException("Argument is not a number"); } EntityArgument::operator boost::dynamic_bitset<>() const { throw IfcException("Argument is not a binary"); } EntityArgument::operator std::string() const { throw IfcException("Argument is not a string"); } EntityArgument::operator std::vector() const { throw IfcException("Argument is not a list of ints"); } EntityArgument::operator std::vector() const { throw IfcException("Argument is not a list of bools"); } +EntityArgument::operator std::vector() const { throw IfcException("Argument is not a list of logicals"); } EntityArgument::operator std::vector() const { throw IfcException("Argument is not a list of floats"); } EntityArgument::operator std::vector() const { throw IfcException("Argument is not a list of strings"); } EntityArgument::operator std::vector >() const { throw IfcException("Argument is not a list of binaries"); } @@ -785,6 +820,7 @@ EntityArgument::operator IfcUtil::IfcBaseClass*() const { return entity; } EntityArgument::operator IfcEntityList::ptr() const { throw IfcException("Argument is not a list of entity instances"); } EntityArgument::operator std::vector< std::vector >() const { throw IfcException("Argument is not a list of list of ints"); } EntityArgument::operator std::vector< std::vector >() const { throw IfcException("Argument is not a list of list of bools"); } +EntityArgument::operator std::vector< std::vector >() const { throw IfcException("Argument is not a list of list of logicals"); } EntityArgument::operator std::vector< std::vector >() const { throw IfcException("Argument is not a list of list of floats"); } EntityArgument::operator IfcEntityListList::ptr() const { throw IfcException("Argument is not a list of list of entity instances"); } unsigned int EntityArgument::size() const { return 1; } diff --git a/src/ifcparse/IfcParse.h b/src/ifcparse/IfcParse.h index e38fc4bbf9..2583e6aed3 100644 --- a/src/ifcparse/IfcParse.h +++ b/src/ifcparse/IfcParse.h @@ -81,6 +81,7 @@ namespace IfcParse { static bool isInt(const Token& t); /// Returns whether the token can be interpreted as a boolean static bool isBool(const Token& t); + static bool isLogical(const Token& t); /// Returns whether the token can be interpreted as a floating point number static bool isFloat(const Token& t); /// Returns whether the token can be interpreted as a binary type @@ -89,6 +90,7 @@ namespace IfcParse { static int asInt(const Token& t); /// Returns the token interpreted as an boolean (.T. or .F.) static bool asBool(const Token& t); + static boost::logic::tribool asLogical(const Token& t); /// Returns the token as a floating point number static double asFloat(const Token& t); /// Returns the token as a string (without the dot or apostrophe) @@ -155,6 +157,10 @@ namespace IfcParse { operator std::vector< std::vector >() const; operator IfcEntityListList::ptr() const; + operator boost::logic::tribool() const; + operator std::vector() const; + operator std::vector< std::vector >() const; + bool isNull() const; unsigned int size() const; @@ -195,6 +201,10 @@ namespace IfcParse { operator std::vector< std::vector >() const; operator IfcEntityListList::ptr() const; + operator boost::logic::tribool() const; + operator std::vector() const; + operator std::vector< std::vector >() const; + bool isNull() const; unsigned int size() const; @@ -233,6 +243,10 @@ namespace IfcParse { operator std::vector< std::vector >() const; operator IfcEntityListList::ptr() const; + operator boost::logic::tribool() const; + operator std::vector() const; + operator std::vector< std::vector >() const; + bool isNull() const; unsigned int size() const; diff --git a/src/ifcparse/IfcUtil.h b/src/ifcparse/IfcUtil.h index e5534869d4..b655705e75 100644 --- a/src/ifcparse/IfcUtil.h +++ b/src/ifcparse/IfcUtil.h @@ -20,6 +20,9 @@ #ifndef IFCUTIL_H #define IFCUTIL_H +#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS +#define BOOST_MPL_LIMIT_LIST_SIZE 30 + #include #include #include @@ -28,6 +31,7 @@ #include #include +#include #include "../ifcparse/IfcSchema.h" @@ -58,6 +62,7 @@ namespace IfcUtil { Argument_DERIVED, Argument_INT, Argument_BOOL, + Argument_TRIBOOL, Argument_DOUBLE, Argument_STRING, Argument_BINARY, @@ -66,13 +71,15 @@ namespace IfcUtil { Argument_AGGREGATE_OF_INT, Argument_AGGREGATE_OF_BOOL, - Argument_AGGREGATE_OF_DOUBLE, + Argument_AGGREGATE_OF_TRIBOOL, + Argument_AGGREGATE_OF_DOUBLE, Argument_AGGREGATE_OF_STRING, Argument_AGGREGATE_OF_BINARY, Argument_AGGREGATE_OF_ENTITY_INSTANCE, Argument_AGGREGATE_OF_AGGREGATE_OF_INT, Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL, + Argument_AGGREGATE_OF_AGGREGATE_OF_TRIBOOL, Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE, Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE, @@ -314,6 +321,7 @@ class Argument { public: virtual operator int() const = 0; virtual operator bool() const = 0; + virtual operator boost::logic::tribool() const = 0; virtual operator double() const = 0; virtual operator std::string() const = 0; virtual operator boost::dynamic_bitset<>() const = 0; @@ -321,6 +329,7 @@ public: virtual operator std::vector() const = 0; virtual operator std::vector() const = 0; + virtual operator std::vector() const = 0; virtual operator std::vector() const = 0; virtual operator std::vector() const = 0; virtual operator std::vector >() const = 0; @@ -328,6 +337,7 @@ public: virtual operator std::vector< std::vector >() const = 0; virtual operator std::vector< std::vector >() const = 0; + virtual operator std::vector< std::vector >() const = 0; virtual operator std::vector< std::vector >() const = 0; virtual operator IfcEntityListList::ptr() const = 0; @@ -384,6 +394,7 @@ namespace IfcUtil { struct attr_type_to_cpp_type; template <> struct attr_type_to_cpp_type { typedef int cpp_type; }; template <> struct attr_type_to_cpp_type { typedef bool cpp_type; }; + template <> struct attr_type_to_cpp_type { typedef boost::logic::tribool cpp_type; }; template <> struct attr_type_to_cpp_type { typedef double cpp_type; }; template <> struct attr_type_to_cpp_type { typedef std::string cpp_type; }; template <> struct attr_type_to_cpp_type { typedef boost::dynamic_bitset<> cpp_type; }; @@ -391,6 +402,7 @@ namespace IfcUtil { template <> struct attr_type_to_cpp_type { typedef std::vector cpp_type; }; template <> struct attr_type_to_cpp_type { typedef std::vector cpp_type; }; + template <> struct attr_type_to_cpp_type { typedef std::vector cpp_type; }; template <> struct attr_type_to_cpp_type { typedef std::vector cpp_type; }; template <> struct attr_type_to_cpp_type { typedef std::vector cpp_type; }; template <> struct attr_type_to_cpp_type { typedef std::vector< boost::dynamic_bitset<> > cpp_type; }; @@ -398,6 +410,7 @@ namespace IfcUtil { template <> struct attr_type_to_cpp_type { typedef std::vector< std::vector > cpp_type; }; template <> struct attr_type_to_cpp_type { typedef std::vector< std::vector > cpp_type; }; + template <> struct attr_type_to_cpp_type { typedef std::vector< std::vector > cpp_type; }; template <> struct attr_type_to_cpp_type { typedef std::vector< std::vector > cpp_type; }; template <> struct attr_type_to_cpp_type { typedef IfcEntityListList::ptr cpp_type; }; } diff --git a/src/ifcparse/IfcWrite.cpp b/src/ifcparse/IfcWrite.cpp index 22a5d36f3d..d3265d8c7a 100644 --- a/src/ifcparse/IfcWrite.cpp +++ b/src/ifcparse/IfcWrite.cpp @@ -155,6 +155,9 @@ void IfcWritableEntity::setArgument(int i, Argument* a) { case IfcUtil::Argument_BOOL: this->setArgument(i, static_cast(*a)); break; + case IfcUtil::Argument_TRIBOOL: + this->setArgument(i, a->operator boost::logic::tribool()); + break; case IfcUtil::Argument_DOUBLE: this->setArgument(i, static_cast(*a)); break; @@ -309,14 +312,17 @@ public: int operator()(const IfcWriteArgument::Derived& /*i*/) const { return -1; } int operator()(const int& /*i*/) const { return -1; } int operator()(const bool& /*i*/) const { return -1; } + int operator()(const boost::logic::tribool& /*i*/) const { return -1; } int operator()(const double& /*i*/) const { return -1; } int operator()(const std::string& /*i*/) const { return -1; } int operator()(const boost::dynamic_bitset<>& /*i*/) const { return -1; } int operator()(const std::vector& i) const { return (int)i.size(); } int operator()(const std::vector& i) const { return (int)i.size(); } + int operator()(const std::vector& i) const { return (int)i.size(); } int operator()(const std::vector& i) const { return (int)i.size(); } int operator()(const std::vector< std::vector >& i) const { return (int)i.size(); } int operator()(const std::vector< std::vector >& i) const { return (int)i.size(); } + int operator()(const std::vector< std::vector >& i) const { return (int)i.size(); } int operator()(const std::vector< std::vector >& i) const { return (int)i.size(); } int operator()(const std::vector& i) const { return (int)i.size(); } int operator()(const std::vector< boost::dynamic_bitset<> >& i) const { return (int)i.size(); } @@ -375,6 +381,10 @@ std::string IfcWrite::format(bool b) { return b ? ".T." : ".F."; } +std::string IfcWrite::format(boost::logic::tribool b) { + return std::string(".") + "FTU"[b.value] + "."; +} + class StringBuilderVisitor : public boost::static_visitor { private: StringBuilderVisitor(const StringBuilderVisitor&); //N/A @@ -398,6 +408,7 @@ public: void operator()(const IfcWriteArgument::Derived& /*i*/) { data << "*"; } void operator()(const int& i) { data << i; } void operator()(const bool& i) { data << IfcWrite::format(i); } + void operator()(const boost::logic::tribool& i) { data << IfcWrite::format(i); } void operator()(const double& i) { data << IfcWrite::format(i); } void operator()(const boost::dynamic_bitset<>& i) { data << IfcWrite::format(i); } void operator()(const std::string& i) { @@ -410,6 +421,7 @@ public: } void operator()(const std::vector& i); void operator()(const std::vector& i); + void operator()(const std::vector& i); void operator()(const std::vector& i); void operator()(const std::vector& i); void operator()(const std::vector< boost::dynamic_bitset<> >& i); @@ -434,6 +446,7 @@ public: } void operator()(const std::vector< std::vector >& i); void operator()(const std::vector< std::vector >& i); + void operator()(const std::vector< std::vector >& i); void operator()(const std::vector< std::vector >& i); void operator()(const IfcEntityListList::ptr& i) { data << "("; @@ -486,6 +499,16 @@ void StringBuilderVisitor::serialize(const std::vector& i) { data << ")"; } +template <> +void StringBuilderVisitor::serialize(const std::vector& i) { + data << "("; + for (std::vector::const_iterator it = i.begin(); it != i.end(); ++it) { + if (it != i.begin()) data << ","; + data << IfcWrite::format(*it); + } + data << ")"; +} + template <> void StringBuilderVisitor::serialize(const std::vector< boost::dynamic_bitset<> >& i) { data << "("; @@ -498,6 +521,7 @@ void StringBuilderVisitor::serialize(const std::vector< boost::dynamic_bitset<> void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } +void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } void StringBuilderVisitor::operator()(const std::vector< boost::dynamic_bitset<> >& i) { serialize(i); } @@ -517,6 +541,14 @@ void StringBuilderVisitor::operator()(const std::vector< std::vector >& i) } data << ")"; } +void StringBuilderVisitor::operator()(const std::vector< std::vector >& i) { + data << "("; + for (std::vector< std::vector >::const_iterator it = i.begin(); it != i.end(); ++it) { + if (it != i.begin()) data << ","; + serialize(*it); + } + data << ")"; +} void StringBuilderVisitor::operator()(const std::vector< std::vector >& i) { data << "("; for (std::vector< std::vector >::const_iterator it = i.begin(); it != i.end(); ++it) { @@ -528,6 +560,7 @@ void StringBuilderVisitor::operator()(const std::vector< std::vector >& IfcWriteArgument::operator int() const { return as(); } IfcWriteArgument::operator bool() const { return as(); } +IfcWriteArgument::operator boost::logic::tribool() const { return as(); } IfcWriteArgument::operator double() const { return as(); } IfcWriteArgument::operator std::string() const { if (type() == IfcUtil::Argument_ENUMERATION) { @@ -539,12 +572,14 @@ IfcWriteArgument::operator IfcUtil::IfcBaseClass*() const { return as() const { return as< boost::dynamic_bitset<> >(); } IfcWriteArgument::operator std::vector() const { return as >(); } IfcWriteArgument::operator std::vector() const { return as >(); } +IfcWriteArgument::operator std::vector() const { return as >(); } IfcWriteArgument::operator std::vector() const { return as >(); } IfcWriteArgument::operator std::vector() const { return as >(); } IfcWriteArgument::operator std::vector< boost::dynamic_bitset<> >() const { return as< std::vector< boost::dynamic_bitset<> > >(); } IfcWriteArgument::operator IfcEntityList::ptr() const { return as(); } IfcWriteArgument::operator std::vector< std::vector >() const { return as > >(); } IfcWriteArgument::operator std::vector< std::vector >() const { return as > >(); } +IfcWriteArgument::operator std::vector< std::vector >() const { return as > >(); } IfcWriteArgument::operator std::vector< std::vector >() const { return as > >(); } IfcWriteArgument::operator IfcEntityListList::ptr() const { throw; } bool IfcWriteArgument::isNull() const { return type() == IfcUtil::Argument_NULL; } diff --git a/src/ifcparse/IfcWrite.h b/src/ifcparse/IfcWrite.h index c1dbd46c1c..592a653d77 100644 --- a/src/ifcparse/IfcWrite.h +++ b/src/ifcparse/IfcWrite.h @@ -40,6 +40,7 @@ namespace IfcWrite { std::string format(bool b); std::string format(double d); std::string format(const boost::dynamic_bitset<>& b); + std::string format(boost::logic::tribool b); /// This class is a writable container for attributes. A fundamental /// difference with the attribute types counterparts defined in the @@ -69,6 +70,8 @@ namespace IfcWrite { int, // A boolean argument, it will serialize to either .T. or .F. bool, + // A logical argument, it will serialize to either .T. or .F. or .U. + boost::logic::tribool, // A floating point argument, e.g. 12.3 double, // A character string argument, e.g. 'IfcOpenShell' @@ -92,6 +95,7 @@ namespace IfcWrite { std::vector, // An aggregate of bools, e.g. (.T.,.F.) std::vector, + std::vector, // An aggregate of floats, e.g. (12.3,4.) std::vector, // An aggregate of strings, e.g. ('Ifc','Open','Shell') @@ -108,6 +112,7 @@ namespace IfcWrite { std::vector< std::vector >, // An aggregate of bools, e.g. (.T.,(.T.,.F.)) std::vector< std::vector >, + std::vector< std::vector >, // An aggregate of an aggregate of floats. E.g. ((1., 2.3), (4.)) std::vector< std::vector >, // An aggregate of an aggregate of entities. E.g. ((#1, #2), (#3)) @@ -145,6 +150,10 @@ namespace IfcWrite { operator std::vector< std::vector >() const; operator IfcEntityListList::ptr() const; + operator boost::logic::tribool() const; + operator std::vector() const; + operator std::vector< std::vector >() const; + bool isNull() const; Argument* operator [] (unsigned int i) const; std::string toString(bool upper=false) const;