ifcparse: fix clang-tidy warning readability-else-after-return

This commit is contained in:
Dirk Olbrich
2023-10-24 12:21:32 +02:00
committed by Thomas Krijnen
parent b264408d85
commit 9f40674d91
12 changed files with 160 additions and 161 deletions
+14 -18
View File
@@ -92,17 +92,15 @@ class pure_impure_helper {
char peek() { char peek() {
if (pure_) { if (pure_) {
return stream_->peek_at(pointer_); return stream_->peek_at(pointer_);
} else {
return stream_->Peek();
} }
return stream_->Peek();
} }
unsigned int tell() { unsigned int tell() {
if (pure_) { if (pure_) {
return pointer_; return pointer_;
} else {
return stream_->Tell();
} }
return stream_->Tell();
} }
void increment() { void increment() {
@@ -206,27 +204,26 @@ class pure_impure_helper {
if (builder_.empty()) { if (builder_.empty()) {
static std::string empty; static std::string empty;
return empty; return empty;
} else {
auto it = std::max_element(builder_.begin(), builder_.end());
if (*it <= 0x7e) {
std::string r(builder_.begin(), builder_.end());
return r;
} else {
return IfcUtil::convert_utf8(builder_);
}
} }
} else if (mode == IfcParse::IfcCharacterDecoder::SUBSTITUTE) { auto it = std::max_element(builder_.begin(), builder_.end());
if (*it <= 0x7e) {
std::string r(builder_.begin(), builder_.end());
return r;
}
return IfcUtil::convert_utf8(builder_);
}
if (mode == IfcParse::IfcCharacterDecoder::SUBSTITUTE) {
std::string r; std::string r;
r.reserve(builder_.size()); r.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(r), [&substitution_character](wchar_t c) {
if (c >= 0x20 && c <= 0x7e) { if (c >= 0x20 && c <= 0x7e) {
return (char)c; return (char)c;
} else {
return substitution_character;
} }
return substitution_character;
}); });
return r; return r;
} else if (mode == IfcParse::IfcCharacterDecoder::ESCAPE) { }
if (mode == IfcParse::IfcCharacterDecoder::ESCAPE) {
std::stringstream str; std::stringstream str;
str << std::hex << std::setw(4) << std::setfill('0'); str << 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(), [&str](wchar_t c) {
@@ -237,9 +234,8 @@ class pure_impure_helper {
} }
}); });
return str.str(); return str.str();
} else {
throw IfcParse::IfcException("Invalid conversion mode");
} }
throw IfcParse::IfcException("Invalid conversion mode");
} }
}; };
} // namespace } // namespace
+1 -2
View File
@@ -86,9 +86,8 @@ class IFC_PARSE_API IfcEntityInstanceData {
} }
if (type_->as_entity()) { if (type_->as_entity()) {
return type_->as_entity()->attribute_count(); return type_->as_entity()->attribute_count();
} else {
return 1;
} }
return 1;
} }
void clearArguments(); void clearArguments();
+2 -4
View File
@@ -206,9 +206,8 @@ class IFC_PARSE_API IfcFile {
aggregate_of_instance::ptr untyped_list = instances_by_type(&T::Class()); aggregate_of_instance::ptr untyped_list = instances_by_type(&T::Class());
if (untyped_list) { if (untyped_list) {
return untyped_list->as<T>(); return untyped_list->as<T>();
} else {
return typename T::list::ptr(new typename T::list);
} }
return typename T::list::ptr(new typename T::list);
} }
template <class T> template <class T>
@@ -216,9 +215,8 @@ class IFC_PARSE_API IfcFile {
aggregate_of_instance::ptr untyped_list = instances_by_type_excl_subtypes(&T::Class()); aggregate_of_instance::ptr untyped_list = instances_by_type_excl_subtypes(&T::Class());
if (untyped_list) { if (untyped_list) {
return untyped_list->as<T>(); return untyped_list->as<T>();
} else {
return typename T::list::ptr(new typename T::list);
} }
return typename T::list::ptr(new typename T::list);
} }
/// Returns all entities in the file that match the positional argument. /// Returns all entities in the file that match the positional argument.
+12 -13
View File
@@ -998,20 +998,19 @@ typename Schema::IfcGeometricRepresentationContext* IfcHierarchyHelper<Schema>::
typename std::map<std::string, typename Schema::IfcGeometricRepresentationContext*>::const_iterator it = contexts.find(s); typename std::map<std::string, typename Schema::IfcGeometricRepresentationContext*>::const_iterator it = contexts.find(s);
if (it != contexts.end()) { if (it != contexts.end()) {
return it->second; return it->second;
} else {
typename Schema::IfcProject* project = getSingle<typename Schema::IfcProject>();
if (!project) {
project = addProject();
}
auto project_contexts = project->RepresentationContexts();
typename Schema::IfcGeometricRepresentationContext* context = new typename Schema::IfcGeometricRepresentationContext(
boost::none, s, 3, 1e-5, addPlacement3d(), addDoublet<typename Schema::IfcDirection>(0, 1));
addEntity(context);
push_back_to_maybe_optional(project_contexts, context);
project->setRepresentationContexts(project_contexts);
return contexts[s] = context;
} }
typename Schema::IfcProject* project = getSingle<typename Schema::IfcProject>();
if (!project) {
project = addProject();
}
auto project_contexts = project->RepresentationContexts();
typename Schema::IfcGeometricRepresentationContext* context = new typename Schema::IfcGeometricRepresentationContext(
boost::none, s, 3, 1e-5, addPlacement3d(), addDoublet<typename Schema::IfcDirection>(0, 1));
addEntity(context);
push_back_to_maybe_optional(project_contexts, context);
project->setRepresentationContexts(project_contexts);
return contexts[s] = context;
} }
#ifdef HAS_SCHEMA_2x3 #ifdef HAS_SCHEMA_2x3
+52 -56
View File
@@ -355,9 +355,8 @@ Token IfcSpfLexer::Next() {
} }
if (len) { if (len) {
return GeneralTokenPtr(this, pos, stream->Tell()); return GeneralTokenPtr(this, pos, stream->Tell());
} else {
return NoneTokenPtr();
} }
return NoneTokenPtr();
} }
bool IfcSpfStream::is_eof_at(unsigned int local_ptr) { bool IfcSpfStream::is_eof_at(unsigned int local_ptr) {
@@ -392,13 +391,13 @@ void IfcSpfLexer::TokenString(unsigned int offset, std::string& buffer) {
stream->increment_at(offset); stream->increment_at(offset);
if (c == ' ' || c == '\r' || c == '\n' || c == '\t') { if (c == ' ' || c == '\r' || c == '\n' || c == '\t') {
continue; continue;
} else if (c == '\'') { }
if (c == '\'') {
// todo, make decoder use local offset ptr // todo, make decoder use local offset ptr
buffer = decoder->get(offset); buffer = decoder->get(offset);
break; break;
} else {
buffer.push_back(c);
} }
buffer.push_back(c);
} }
} }
@@ -574,14 +573,13 @@ boost::logic::tribool TokenFunc::asLogical(const Token& t) {
if (t.type != Token_BOOL) { if (t.type != Token_BOOL) {
throw IfcInvalidTokenException(t.startPos, toString(t), "boolean"); throw IfcInvalidTokenException(t.startPos, toString(t), "boolean");
} }
if (t.value_int == 0) { if (t.value_int == 0) {
return false; return false;
} else if (t.value_int == 1) {
return true;
} else {
return boost::logic::indeterminate;
} }
if (t.value_int == 1) {
return true;
}
return boost::logic::indeterminate;
} }
double TokenFunc::asFloat(const Token& t) { double TokenFunc::asFloat(const Token& t) {
@@ -589,13 +587,12 @@ double TokenFunc::asFloat(const Token& t) {
if (t.type == Token_INT) { if (t.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 t.value_int;
} else // ----> continues beyond preprocessor directive } // ----> continues beyond preprocessor directive
#endif #endif
if (t.type == Token_FLOAT) { if (t.type == Token_FLOAT) {
return t.value_double; return t.value_double;
} else {
throw IfcInvalidTokenException(t.startPos, toString(t), "real");
} }
throw IfcInvalidTokenException(t.startPos, toString(t), "real");
} }
const std::string& TokenFunc::asStringRef(const Token& t) { const std::string& TokenFunc::asStringRef(const Token& t) {
@@ -615,9 +612,8 @@ const std::string& TokenFunc::asStringRef(const Token& t) {
std::string TokenFunc::asString(const Token& t) { std::string TokenFunc::asString(const Token& t) {
if (isString(t) || isEnumeration(t) || isBinary(t)) { if (isString(t) || isEnumeration(t) || isBinary(t)) {
return asStringRef(t); return asStringRef(t);
} else {
throw IfcInvalidTokenException(t.startPos, toString(t), "string");
} }
throw IfcInvalidTokenException(t.startPos, toString(t), "string");
} }
boost::dynamic_bitset<> TokenFunc::asBinary(const Token& t) { boost::dynamic_bitset<> TokenFunc::asBinary(const Token& t) {
@@ -703,9 +699,8 @@ class vector_or_array {
size_t index() const { size_t index() const {
if (vector_) { if (vector_) {
return vector_->size(); return vector_->size();
} else {
return index_;
} }
return index_;
} }
}; };
} // namespace } // namespace
@@ -935,27 +930,35 @@ ArgumentList::~ArgumentList() {
IfcUtil::ArgumentType TokenArgument::type() const { IfcUtil::ArgumentType TokenArgument::type() const {
if (TokenFunc::isInt(token)) { if (TokenFunc::isInt(token)) {
return IfcUtil::Argument_INT; return IfcUtil::Argument_INT;
} else if (TokenFunc::isBool(token)) {
return IfcUtil::Argument_BOOL;
} else if (TokenFunc::isLogical(token)) {
return IfcUtil::Argument_LOGICAL;
} else if (TokenFunc::isFloat(token)) {
return IfcUtil::Argument_DOUBLE;
} else if (TokenFunc::isString(token)) {
return IfcUtil::Argument_STRING;
} else if (TokenFunc::isEnumeration(token)) {
return IfcUtil::Argument_ENUMERATION;
} else if (TokenFunc::isIdentifier(token)) {
return IfcUtil::Argument_ENTITY_INSTANCE;
} else if (TokenFunc::isBinary(token)) {
return IfcUtil::Argument_BINARY;
} else if (TokenFunc::isOperator(token, '$')) {
return IfcUtil::Argument_NULL;
} else if (TokenFunc::isOperator(token, '*')) {
return IfcUtil::Argument_DERIVED;
} else {
return IfcUtil::Argument_UNKNOWN;
} }
if (TokenFunc::isBool(token)) {
return IfcUtil::Argument_BOOL;
}
if (TokenFunc::isLogical(token)) {
return IfcUtil::Argument_LOGICAL;
}
if (TokenFunc::isFloat(token)) {
return IfcUtil::Argument_DOUBLE;
}
if (TokenFunc::isString(token)) {
return IfcUtil::Argument_STRING;
}
if (TokenFunc::isEnumeration(token)) {
return IfcUtil::Argument_ENUMERATION;
}
if (TokenFunc::isIdentifier(token)) {
return IfcUtil::Argument_ENTITY_INSTANCE;
}
if (TokenFunc::isBinary(token)) {
return IfcUtil::Argument_BINARY;
}
if (TokenFunc::isOperator(token, '$')) {
return IfcUtil::Argument_NULL;
}
if (TokenFunc::isOperator(token, '*')) {
return IfcUtil::Argument_DERIVED;
}
return IfcUtil::Argument_UNKNOWN;
} }
// //
@@ -973,9 +976,8 @@ Argument* TokenArgument::operator[](unsigned int /*i*/) const { throw IfcExcepti
std::string TokenArgument::toString(bool upper) const { std::string TokenArgument::toString(bool upper) const {
if (upper && TokenFunc::isString(token)) { if (upper && TokenFunc::isString(token)) {
return IfcWrite::IfcCharacterEncoder(TokenFunc::asString(token)); return IfcWrite::IfcCharacterEncoder(TokenFunc::asString(token));
} else {
return TokenFunc::toString(token);
} }
return TokenFunc::toString(token);
} }
bool TokenArgument::isNull() const { return TokenFunc::isOperator(token, '$'); } bool TokenArgument::isNull() const { return TokenFunc::isOperator(token, '$'); }
@@ -1148,9 +1150,8 @@ IfcEntityInstanceData::~IfcEntityInstanceData() {
unsigned IfcEntityInstanceData::set_id(boost::optional<unsigned> i) { unsigned IfcEntityInstanceData::set_id(boost::optional<unsigned> i) {
if (i) { if (i) {
return id_ = *i; return id_ = *i;
} else {
return id_ = file->FreshId();
} }
return id_ = file->FreshId();
} }
// //
@@ -1215,9 +1216,8 @@ IfcUtil::ArgumentType get_argument_type(const IfcParse::declaration* decl, size_
if (pt == 0) { if (pt == 0) {
return IfcUtil::Argument_UNKNOWN; return IfcUtil::Argument_UNKNOWN;
} else {
return IfcUtil::from_parameter_type(pt);
} }
return IfcUtil::from_parameter_type(pt);
} }
} // namespace } // namespace
@@ -1246,12 +1246,10 @@ Argument* IfcEntityInstanceData::getArgument(size_t i) const {
if (i < getArgumentCount()) { if (i < getArgumentCount()) {
if (attributes_[i] == nullptr) { if (attributes_[i] == nullptr) {
return &static_null_attribute; return &static_null_attribute;
} else {
return attributes_[i];
} }
} else { return attributes_[i];
throw IfcParse::IfcException("Attribute index out of range");
} }
throw IfcParse::IfcException("Attribute index out of range");
} }
class unregister_inverse_visitor { class unregister_inverse_visitor {
@@ -1799,13 +1797,12 @@ class traversal_recorder {
aggregate_of_instance::ptr get_list() const { aggregate_of_instance::ptr get_list() const {
if (mode_ == 0) { if (mode_ == 0) {
return list_; return list_;
} else {
aggregate_of_instance::ptr l(new aggregate_of_instance);
for (auto& p : instances_by_level_) {
l->push(p.second);
}
return l;
} }
aggregate_of_instance::ptr l(new aggregate_of_instance);
for (auto& p : instances_by_level_) {
l->push(p.second);
}
return l;
} }
}; };
@@ -2415,9 +2412,8 @@ IfcUtil::IfcBaseClass* IfcFile::instance_by_guid(const std::string& guid) {
entity_by_guid_t::const_iterator it = byguid.find(guid); entity_by_guid_t::const_iterator it = byguid.find(guid);
if (it == byguid.end()) { if (it == byguid.end()) {
throw IfcException("Instance with GlobalId '" + guid + "' not found"); throw IfcException("Instance with GlobalId '" + guid + "' not found");
} else {
return it->second;
} }
return it->second;
} }
// FIXME: Test destructor to delete entity and arg allocations // FIXME: Test destructor to delete entity and arg allocations
+46 -32
View File
@@ -59,39 +59,53 @@
double IfcParse::IfcSIPrefixToValue(const std::string& v) { double IfcParse::IfcSIPrefixToValue(const std::string& v) {
if (v == "EXA") { if (v == "EXA") {
return 1.e18; return 1.e18;
} else if (v == "PETA") {
return 1.e15;
} else if (v == "TERA") {
return 1.e12;
} else if (v == "GIGA") {
return 1.e9;
} else if (v == "MEGA") {
return 1.e6;
} else if (v == "KILO") {
return 1.e3;
} else if (v == "HECTO") {
return 1.e2;
} else if (v == "DECA") {
return 1.e1;
} else if (v == "DECI") {
return 1.e-1;
} else if (v == "CENTI") {
return 1.e-2;
} else if (v == "MILLI") {
return 1.e-3;
} else if (v == "MICRO") {
return 1.e-6;
} else if (v == "NANO") {
return 1.e-9;
} else if (v == "PICO") {
return 1.e-12;
} else if (v == "FEMTO") {
return 1.e-15;
} else if (v == "ATTO") {
return 1.e-18;
} else {
return 1.;
} }
if (v == "PETA") {
return 1.e15;
}
if (v == "TERA") {
return 1.e12;
}
if (v == "GIGA") {
return 1.e9;
}
if (v == "MEGA") {
return 1.e6;
}
if (v == "KILO") {
return 1.e3;
}
if (v == "HECTO") {
return 1.e2;
}
if (v == "DECA") {
return 1.e1;
}
if (v == "DECI") {
return 1.e-1;
}
if (v == "CENTI") {
return 1.e-2;
}
if (v == "MILLI") {
return 1.e-3;
}
if (v == "MICRO") {
return 1.e-6;
}
if (v == "NANO") {
return 1.e-9;
}
if (v == "PICO") {
return 1.e-12;
}
if (v == "FEMTO") {
return 1.e-15;
}
if (v == "ATTO") {
return 1.e-18;
}
return 1.;
} }
template <typename Schema> template <typename Schema>
+5 -4
View File
@@ -74,7 +74,8 @@ bool IfcParse::declaration::is(const std::string& name) const {
if (this->as_entity() && this->as_entity()->supertype()) { if (this->as_entity() && this->as_entity()->supertype()) {
return this->as_entity()->supertype()->is(name); return this->as_entity()->supertype()->is(name);
} else if (this->as_type_declaration()) { }
if (this->as_type_declaration()) {
const IfcParse::named_type* nt = this->as_type_declaration()->declared_type()->as_named_type(); const IfcParse::named_type* nt = this->as_type_declaration()->declared_type()->as_named_type();
if (nt) { if (nt) {
return nt->is(name); return nt->is(name);
@@ -91,7 +92,8 @@ bool IfcParse::declaration::is(const IfcParse::declaration& decl) const {
if (this->as_entity() && this->as_entity()->supertype()) { if (this->as_entity() && this->as_entity()->supertype()) {
return this->as_entity()->supertype()->is(decl); return this->as_entity()->supertype()->is(decl);
} else if (this->as_type_declaration()) { }
if (this->as_type_declaration()) {
const IfcParse::named_type* nt = this->as_type_declaration()->declared_type()->as_named_type(); const IfcParse::named_type* nt = this->as_type_declaration()->declared_type()->as_named_type();
if (nt) { if (nt) {
return nt->is(decl); return nt->is(decl);
@@ -153,9 +155,8 @@ IfcParse::schema_definition::~schema_definition() {
IfcUtil::IfcBaseClass* IfcParse::schema_definition::instantiate(IfcEntityInstanceData* data) const { IfcUtil::IfcBaseClass* IfcParse::schema_definition::instantiate(IfcEntityInstanceData* data) const {
if (factory_) { if (factory_) {
return (*factory_)(data); return (*factory_)(data);
} else {
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* s) {
+1 -2
View File
@@ -489,9 +489,8 @@ class IFC_PARSE_API schema_definition {
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 it = std::lower_bound(declarations_.begin(), declarations_.end(), *name_ptr, declaration_by_name_cmp());
if (it == declarations_.end() || (**it).name_uc() != *name_ptr) { if (it == declarations_.end() || (**it).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_ + "'");
} else {
return *it;
} }
return *it;
} }
const declaration* declaration_by_name(int name) const { const declaration* declaration_by_name(int name) const {
+6 -12
View File
@@ -133,49 +133,43 @@ void IfcSpfHeader::write(std::ostream& os) const {
const FileDescription& IfcSpfHeader::file_description() const { const FileDescription& IfcSpfHeader::file_description() const {
if (_file_description) { if (_file_description) {
return *_file_description; return *_file_description;
} else {
throw IfcException("File description not set");
} }
throw IfcException("File description not set");
} }
const FileName& IfcSpfHeader::file_name() const { const FileName& IfcSpfHeader::file_name() const {
if (_file_name) { if (_file_name) {
return *_file_name; return *_file_name;
} else {
throw IfcException("File name not set");
} }
throw IfcException("File name not set");
} }
const FileSchema& IfcSpfHeader::file_schema() const { const FileSchema& IfcSpfHeader::file_schema() const {
if (_file_schema) { if (_file_schema) {
return *_file_schema; return *_file_schema;
} else {
throw IfcException("File schema not set");
} }
throw IfcException("File schema not set");
} }
FileDescription& IfcSpfHeader::file_description() { FileDescription& IfcSpfHeader::file_description() {
if (_file_description) { if (_file_description) {
return *_file_description; return *_file_description;
} else {
throw IfcException("File description not set");
} }
throw IfcException("File description not set");
} }
FileName& IfcSpfHeader::file_name() { FileName& IfcSpfHeader::file_name() {
if (_file_name) { if (_file_name) {
return *_file_name; return *_file_name;
} else {
throw IfcException("File name not set");
} }
throw IfcException("File name not set");
} }
FileSchema& IfcSpfHeader::file_schema() { FileSchema& IfcSpfHeader::file_schema() {
if (_file_schema) { if (_file_schema) {
return *_file_schema; return *_file_schema;
} else {
throw IfcException("File schema not set");
} }
throw IfcException("File schema not set");
} }
FileDescription::FileDescription(IfcFile* file) : HeaderEntity(FILE_DESCRIPTION, 2, file) {} FileDescription::FileDescription(IfcFile* file) : HeaderEntity(FILE_DESCRIPTION, 2, file) {}
+19 -14
View File
@@ -222,25 +222,26 @@ void IfcUtil::IfcBaseClass::data(IfcEntityInstanceData* d) {
} }
IfcUtil::ArgumentType IfcUtil::make_aggregate(IfcUtil::ArgumentType elem_type) { IfcUtil::ArgumentType IfcUtil::make_aggregate(IfcUtil::ArgumentType elem_type) {
if (elem_type == IfcUtil::Argument_INT) { switch (elem_type) {
case IfcUtil::Argument_INT:
return IfcUtil::Argument_AGGREGATE_OF_INT; return IfcUtil::Argument_AGGREGATE_OF_INT;
} else if (elem_type == IfcUtil::Argument_DOUBLE) { case IfcUtil::Argument_DOUBLE:
return IfcUtil::Argument_AGGREGATE_OF_DOUBLE; return IfcUtil::Argument_AGGREGATE_OF_DOUBLE;
} else if (elem_type == IfcUtil::Argument_STRING) { case IfcUtil::Argument_STRING:
return IfcUtil::Argument_AGGREGATE_OF_STRING; return IfcUtil::Argument_AGGREGATE_OF_STRING;
} else if (elem_type == IfcUtil::Argument_BINARY) { case IfcUtil::Argument_BINARY:
return IfcUtil::Argument_AGGREGATE_OF_BINARY; return IfcUtil::Argument_AGGREGATE_OF_BINARY;
} else if (elem_type == IfcUtil::Argument_ENTITY_INSTANCE) { case IfcUtil::Argument_ENTITY_INSTANCE:
return IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE; return IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_INT) { case IfcUtil::Argument_AGGREGATE_OF_INT:
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT; return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_DOUBLE) { case IfcUtil::Argument_AGGREGATE_OF_DOUBLE:
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE; return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) { case IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE:
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE; return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE;
} else if (elem_type == IfcUtil::Argument_EMPTY_AGGREGATE) { case IfcUtil::Argument_EMPTY_AGGREGATE:
return IfcUtil::Argument_AGGREGATE_OF_EMPTY_AGGREGATE; return IfcUtil::Argument_AGGREGATE_OF_EMPTY_AGGREGATE;
} else { default:
return IfcUtil::Argument_UNKNOWN; return IfcUtil::Argument_UNKNOWN;
} }
} }
@@ -254,14 +255,18 @@ IfcUtil::ArgumentType IfcUtil::from_parameter_type(const IfcParse::parameter_typ
if (at) { if (at) {
return make_aggregate(from_parameter_type(at->type_of_element())); return make_aggregate(from_parameter_type(at->type_of_element()));
} else if (nt) { }
if (nt) {
if (nt->declared_type()->as_entity()) { if (nt->declared_type()->as_entity()) {
return IfcUtil::Argument_ENTITY_INSTANCE; return IfcUtil::Argument_ENTITY_INSTANCE;
} else if (nt->declared_type()->as_enumeration_type()) { }
if (nt->declared_type()->as_enumeration_type()) {
return IfcUtil::Argument_ENUMERATION; return IfcUtil::Argument_ENUMERATION;
} else if (nt->declared_type()->as_select_type()) { }
if (nt->declared_type()->as_select_type()) {
return IfcUtil::Argument_ENTITY_INSTANCE; return IfcUtil::Argument_ENTITY_INSTANCE;
} else if (nt->declared_type()->as_type_declaration()) { }
if (nt->declared_type()->as_type_declaration()) {
return from_parameter_type(nt->declared_type()->as_type_declaration()->declared_type()); return from_parameter_type(nt->declared_type()->as_type_declaration()->declared_type());
} }
} else if (st) { } else if (st) {
+1 -2
View File
@@ -281,9 +281,8 @@ unsigned int IfcWriteArgument::size() const {
const int size = container.apply_visitor(v); const int size = container.apply_visitor(v);
if (size == -1) { if (size == -1) {
throw IfcParse::IfcException("Invalid cast"); throw IfcParse::IfcException("Invalid cast");
} else {
return size;
} }
return size;
} }
IfcUtil::ArgumentType IfcWriteArgument::type() const { IfcUtil::ArgumentType IfcWriteArgument::type() const {
+1 -2
View File
@@ -122,9 +122,8 @@ class IFC_PARSE_API IfcWriteArgument : public Argument {
const T& as() const { const T& as() const {
if (const T* val = boost::get<T>(&container)) { if (const T* val = boost::get<T>(&container)) {
return *val; return *val;
} else {
throw IfcParse::IfcException("Invalid cast");
} }
throw IfcParse::IfcException("Invalid cast");
} }
template <typename T> template <typename T>