From 32338e2490129f6a4259d021fc825aff99d2c23d Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 14 Dec 2018 11:56:09 +0100 Subject: [PATCH] Make std::map inheritance private. #512 #517 --- src/ifcparse/IfcFile.h | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/ifcparse/IfcFile.h b/src/ifcparse/IfcFile.h index e093d706b9..db852a8d98 100644 --- a/src/ifcparse/IfcFile.h +++ b/src/ifcparse/IfcFile.h @@ -42,7 +42,7 @@ public: typedef std::map > entities_by_ref_t; typedef entity_by_id_t::const_iterator const_iterator; - class type_iterator : public entities_by_type_t::const_iterator { + class type_iterator : private entities_by_type_t::const_iterator { public: type_iterator() : entities_by_type_t::const_iterator() {}; @@ -54,12 +54,20 @@ public: return &entities_by_type_t::const_iterator::operator->()->first; } - const entities_by_type_t::key_type& operator*() const { + entities_by_type_t::key_type const & operator*() const { return entities_by_type_t::const_iterator::operator*().first; } - const std::string& as_string() const { - return (**this)->name(); + type_iterator& operator++() { + entities_by_type_t::const_iterator::operator++(); return *this; + } + + type_iterator operator++(int) { + type_iterator tmp(*this); operator++(); return tmp; + } + + bool operator!=(const type_iterator& other) const { + return entities_by_type_t::const_iterator::operator!=(other); } }; @@ -219,4 +227,13 @@ IFC_PARSE_API IfcFile* parse_ifcxml(const std::string& filename); } +template <> +struct std::iterator_traits { + typedef ptrdiff_t difference_type; + typedef const IfcParse::declaration* value_type; + typedef const IfcParse::declaration*& reference; + typedef const IfcParse::declaration** pointer; + typedef std::forward_iterator_tag iterator_category; +}; + #endif