Hacky support for LOGICAL

This commit is contained in:
Thomas Krijnen
2017-10-13 14:51:09 +02:00
parent 2422da4048
commit 71dcc96ac2
7 changed files with 128 additions and 9 deletions
+3
View File
@@ -26,6 +26,9 @@
* *
********************************************************************************/
#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#define BOOST_MPL_LIMIT_LIST_SIZE 30
#include <fstream>
#include <sstream>
#include <set>
+17 -8
View File
@@ -74,14 +74,16 @@ public:
template <typename T> struct is_hdf5_integral { static const bool value = false; };
template <> struct is_hdf5_integral <int> { static const bool value = true; };
template <> struct is_hdf5_integral <bool> { static const bool value = true; };
template <> struct is_hdf5_integral <boost::logic::tribool> { static const bool value = true; };
template <> struct is_hdf5_integral <float> { static const bool value = true; };
template <> struct is_hdf5_integral <double> { static const bool value = true; };
template <> struct is_hdf5_integral <enumeration_reference> { static const bool value = true; };
template <typename T> struct hdf5_datatype_for{};
template <> struct hdf5_datatype_for <int> { 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 <bool> { static const H5T_class_t value = H5T_ENUM; };
template <> struct hdf5_datatype_for <boost::logic::tribool> { static const H5T_class_t value = H5T_ENUM; };
template <> struct hdf5_datatype_for <float> { static const H5T_class_t value = H5T_FLOAT; };
template <> struct hdf5_datatype_for <double> { static const H5T_class_t value = H5T_FLOAT; };
template <> struct hdf5_datatype_for <enumeration_reference> { 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<IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE>::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<double>(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<int>(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");
}
+36
View File
@@ -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<T> > 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<bool>() const {
return read_aggregate_as_vector<bool>(list);
}
ArgumentList::operator std::vector<boost::logic::tribool>() const {
return read_aggregate_as_vector<boost::logic::tribool>(list);
}
ArgumentList::operator std::vector<double>() const {
return read_aggregate_as_vector<double>(list);
}
@@ -650,6 +674,10 @@ ArgumentList::operator std::vector< std::vector<bool> >() const {
return read_aggregate_of_aggregate_as_vector2<bool>(list);
}
ArgumentList::operator std::vector< std::vector<boost::logic::tribool> >() const {
return read_aggregate_of_aggregate_as_vector2<boost::logic::tribool>(list);
}
ArgumentList::operator std::vector< std::vector<double> >() const {
return read_aggregate_of_aggregate_as_vector2<double>(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<int>() const { throw IfcException("Argument is not a list of ints"); }
TokenArgument::operator std::vector<bool>() const { throw IfcException("Argument is not a list of bools"); }
TokenArgument::operator std::vector<boost::logic::tribool>() const { throw IfcException("Argument is not a list of logicals"); }
TokenArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
TokenArgument::operator std::vector<std::string>() const { throw IfcException("Argument is not a list of strings"); }
TokenArgument::operator std::vector<boost::dynamic_bitset<> >() 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<int> >() const { throw IfcException("Argument is not a list of list of ints"); }
TokenArgument::operator std::vector< std::vector<bool> >() const { throw IfcException("Argument is not a list of list of bools"); }
TokenArgument::operator std::vector< std::vector<boost::logic::tribool> >() const { throw IfcException("Argument is not a list of list of logicals"); }
TokenArgument::operator std::vector< std::vector<double> >() 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<int>() const { throw IfcException("Argument is not a list of ints"); }
EntityArgument::operator std::vector<bool>() const { throw IfcException("Argument is not a list of bools"); }
EntityArgument::operator std::vector<boost::logic::tribool>() const { throw IfcException("Argument is not a list of logicals"); }
EntityArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
EntityArgument::operator std::vector<std::string>() const { throw IfcException("Argument is not a list of strings"); }
EntityArgument::operator std::vector<boost::dynamic_bitset<> >() 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<int> >() const { throw IfcException("Argument is not a list of list of ints"); }
EntityArgument::operator std::vector< std::vector<bool> >() const { throw IfcException("Argument is not a list of list of bools"); }
EntityArgument::operator std::vector< std::vector<boost::logic::tribool> >() const { throw IfcException("Argument is not a list of list of logicals"); }
EntityArgument::operator std::vector< std::vector<double> >() 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; }
+14
View File
@@ -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<double> >() const;
operator IfcEntityListList::ptr() const;
operator boost::logic::tribool() const;
operator std::vector<boost::logic::tribool>() const;
operator std::vector< std::vector<boost::logic::tribool> >() const;
bool isNull() const;
unsigned int size() const;
@@ -195,6 +201,10 @@ namespace IfcParse {
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
operator boost::logic::tribool() const;
operator std::vector<boost::logic::tribool>() const;
operator std::vector< std::vector<boost::logic::tribool> >() const;
bool isNull() const;
unsigned int size() const;
@@ -233,6 +243,10 @@ namespace IfcParse {
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
operator boost::logic::tribool() const;
operator std::vector<boost::logic::tribool>() const;
operator std::vector< std::vector<boost::logic::tribool> >() const;
bool isNull() const;
unsigned int size() const;
+14 -1
View File
@@ -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 <set>
#include <string>
#include <vector>
@@ -28,6 +31,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/logic/tribool.hpp>
#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<int>() const = 0;
virtual operator std::vector<bool>() const = 0;
virtual operator std::vector<boost::logic::tribool>() const = 0;
virtual operator std::vector<double>() const = 0;
virtual operator std::vector<std::string>() const = 0;
virtual operator std::vector<boost::dynamic_bitset<> >() const = 0;
@@ -328,6 +337,7 @@ public:
virtual operator std::vector< std::vector<int> >() const = 0;
virtual operator std::vector< std::vector<bool> >() const = 0;
virtual operator std::vector< std::vector<boost::logic::tribool> >() const = 0;
virtual operator std::vector< std::vector<double> >() 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 <Argument_INT> { typedef int cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_BOOL> { typedef bool cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_TRIBOOL> { typedef boost::logic::tribool cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_DOUBLE> { typedef double cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_STRING> { typedef std::string cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_BINARY> { typedef boost::dynamic_bitset<> cpp_type; };
@@ -391,6 +402,7 @@ namespace IfcUtil {
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_INT> { typedef std::vector<int> cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_BOOL> { typedef std::vector<bool> cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_TRIBOOL> { typedef std::vector<boost::logic::tribool> cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_DOUBLE> { typedef std::vector<double> cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_STRING> { typedef std::vector<std::string> cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_BINARY> { typedef std::vector< boost::dynamic_bitset<> > cpp_type; };
@@ -398,6 +410,7 @@ namespace IfcUtil {
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_INT> { typedef std::vector< std::vector<int> > cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL> { typedef std::vector< std::vector<bool> > cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_TRIBOOL> { typedef std::vector< std::vector<boost::logic::tribool> > cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE> { typedef std::vector< std::vector<double> > cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE> { typedef IfcEntityListList::ptr cpp_type; };
}
+35
View File
@@ -155,6 +155,9 @@ void IfcWritableEntity::setArgument(int i, Argument* a) {
case IfcUtil::Argument_BOOL:
this->setArgument(i, static_cast<bool>(*a));
break;
case IfcUtil::Argument_TRIBOOL:
this->setArgument(i, a->operator boost::logic::tribool());
break;
case IfcUtil::Argument_DOUBLE:
this->setArgument(i, static_cast<double>(*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<int>& i) const { return (int)i.size(); }
int operator()(const std::vector<bool>& i) const { return (int)i.size(); }
int operator()(const std::vector<boost::logic::tribool>& i) const { return (int)i.size(); }
int operator()(const std::vector<double>& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<int> >& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<bool> >& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<boost::logic::tribool> >& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<double> >& i) const { return (int)i.size(); }
int operator()(const std::vector<std::string>& i) const { return (int)i.size(); }
int operator()(const std::vector< boost::dynamic_bitset<> >& i) const { return (int)i.size(); }
@@ -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<void> {
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<int>& i);
void operator()(const std::vector<bool>& i);
void operator()(const std::vector<boost::logic::tribool>& i);
void operator()(const std::vector<double>& i);
void operator()(const std::vector<std::string>& i);
void operator()(const std::vector< boost::dynamic_bitset<> >& i);
@@ -434,6 +446,7 @@ public:
}
void operator()(const std::vector< std::vector<int> >& i);
void operator()(const std::vector< std::vector<bool> >& i);
void operator()(const std::vector< std::vector<boost::logic::tribool> >& i);
void operator()(const std::vector< std::vector<double> >& i);
void operator()(const IfcEntityListList::ptr& i) {
data << "(";
@@ -486,6 +499,16 @@ void StringBuilderVisitor::serialize(const std::vector<bool>& i) {
data << ")";
}
template <>
void StringBuilderVisitor::serialize(const std::vector<boost::logic::tribool>& i) {
data << "(";
for (std::vector<boost::logic::tribool>::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<int>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<bool>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<boost::logic::tribool>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<double>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<std::string>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector< boost::dynamic_bitset<> >& i) { serialize(i); }
@@ -517,6 +541,14 @@ void StringBuilderVisitor::operator()(const std::vector< std::vector<bool> >& i)
}
data << ")";
}
void StringBuilderVisitor::operator()(const std::vector< std::vector<boost::logic::tribool> >& i) {
data << "(";
for (std::vector< std::vector<boost::logic::tribool> >::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<double> >& i) {
data << "(";
for (std::vector< std::vector<double> >::const_iterator it = i.begin(); it != i.end(); ++it) {
@@ -528,6 +560,7 @@ void StringBuilderVisitor::operator()(const std::vector< std::vector<double> >&
IfcWriteArgument::operator int() const { return as<int>(); }
IfcWriteArgument::operator bool() const { return as<bool>(); }
IfcWriteArgument::operator boost::logic::tribool() const { return as<boost::logic::tribool>(); }
IfcWriteArgument::operator double() const { return as<double>(); }
IfcWriteArgument::operator std::string() const {
if (type() == IfcUtil::Argument_ENUMERATION) {
@@ -539,12 +572,14 @@ IfcWriteArgument::operator IfcUtil::IfcBaseClass*() const { return as<IfcUtil::I
IfcWriteArgument::operator boost::dynamic_bitset<>() const { return as< boost::dynamic_bitset<> >(); }
IfcWriteArgument::operator std::vector<int>() const { return as<std::vector<int> >(); }
IfcWriteArgument::operator std::vector<bool>() const { return as<std::vector<bool> >(); }
IfcWriteArgument::operator std::vector<boost::logic::tribool>() const { return as<std::vector<boost::logic::tribool> >(); }
IfcWriteArgument::operator std::vector<double>() const { return as<std::vector<double> >(); }
IfcWriteArgument::operator std::vector<std::string>() const { return as<std::vector<std::string > >(); }
IfcWriteArgument::operator std::vector< boost::dynamic_bitset<> >() const { return as< std::vector< boost::dynamic_bitset<> > >(); }
IfcWriteArgument::operator IfcEntityList::ptr() const { return as<IfcEntityList::ptr>(); }
IfcWriteArgument::operator std::vector< std::vector<int> >() const { return as<std::vector< std::vector<int> > >(); }
IfcWriteArgument::operator std::vector< std::vector<bool> >() const { return as<std::vector< std::vector<bool> > >(); }
IfcWriteArgument::operator std::vector< std::vector<boost::logic::tribool> >() const { return as<std::vector< std::vector<boost::logic::tribool> > >(); }
IfcWriteArgument::operator std::vector< std::vector<double> >() const { return as<std::vector< std::vector<double> > >(); }
IfcWriteArgument::operator IfcEntityListList::ptr() const { throw; }
bool IfcWriteArgument::isNull() const { return type() == IfcUtil::Argument_NULL; }
+9
View File
@@ -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<int>,
// An aggregate of bools, e.g. (.T.,.F.)
std::vector<bool>,
std::vector<boost::logic::tribool>,
// An aggregate of floats, e.g. (12.3,4.)
std::vector<double>,
// An aggregate of strings, e.g. ('Ifc','Open','Shell')
@@ -108,6 +112,7 @@ namespace IfcWrite {
std::vector< std::vector<int> >,
// An aggregate of bools, e.g. (.T.,(.T.,.F.))
std::vector< std::vector<bool> >,
std::vector< std::vector<boost::logic::tribool> >,
// An aggregate of an aggregate of floats. E.g. ((1., 2.3), (4.))
std::vector< std::vector<double> >,
// An aggregate of an aggregate of entities. E.g. ((#1, #2), (#3))
@@ -145,6 +150,10 @@ namespace IfcWrite {
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
operator boost::logic::tribool() const;
operator std::vector<boost::logic::tribool>() const;
operator std::vector< std::vector<boost::logic::tribool> >() const;
bool isNull() const;
Argument* operator [] (unsigned int i) const;
std::string toString(bool upper=false) const;