diff --git a/src/OpenMesh/Core/IO/SR_binary.hh b/src/OpenMesh/Core/IO/SR_binary.hh index dd4f4218..fbf4772b 100644 --- a/src/OpenMesh/Core/IO/SR_binary.hh +++ b/src/OpenMesh/Core/IO/SR_binary.hh @@ -106,6 +106,8 @@ template < typename T > struct binary static size_t size_of(void) { return UnknownSize; } static size_t size_of(const value_type&) { return UnknownSize; } + static std::string string_for_value_type (void) { return "UnknownType"; } + static size_t store( std::ostream& /* _os */, const value_type& /* _v */, diff --git a/src/OpenMesh/Core/IO/SR_binary_spec.hh b/src/OpenMesh/Core/IO/SR_binary_spec.hh index 725ce727..6d7bc2cc 100644 --- a/src/OpenMesh/Core/IO/SR_binary_spec.hh +++ b/src/OpenMesh/Core/IO/SR_binary_spec.hh @@ -72,6 +72,9 @@ #include #include + +#include + //== NAMESPACES =============================================================== namespace OpenMesh { @@ -91,6 +94,7 @@ namespace IO { static const bool is_streamable = true; \ static size_t size_of(const value_type&) { return sizeof(value_type); } \ static size_t size_of(void) { return sizeof(value_type); } \ + static std::string string_for_value_type(void) { return get_string_for_type(value_type()); } \ static size_t store( std::ostream& _os, const value_type& _val, \ bool _swap=false) { \ value_type tmp = _val; \ @@ -142,6 +146,7 @@ SIMPLE_BINARY(uint64_t); static const bool is_streamable = true; \ static size_t size_of(const value_type&) { return sizeof(value_type); } \ static size_t size_of(void) { return sizeof(value_type); } \ + static std::string string_for_value_type(void) { return get_string_for_type(value_type()); } \ static size_t store( std::ostream& _os, const value_type& _val, \ bool _swap=false) { \ value_type tmp = _val; \ @@ -172,6 +177,7 @@ SIMPLE_BINARY(unsigned long); static const bool is_streamable = true; \ static size_t size_of(void) { return sizeof(value_type); } \ static size_t size_of(const value_type&) { return size_of(); } \ + static std::string string_for_value_type(void) { return get_string_for_type(value_type()); } \ static size_t store( std::ostream& _os, const value_type& _val, \ bool _swap=false) { \ value_type tmp = _val; \ @@ -222,7 +228,7 @@ template <> struct binary< std::string > { static size_t size_of() { return UnknownSize; } static size_t size_of(const value_type &_v) { return sizeof(length_t) + _v.size(); } - + static std::string string_for_value_type(void) { return get_string_for_type(value_type()); } static size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) { @@ -264,6 +270,7 @@ template <> struct binary static size_t size_of() { return sizeof(status_t); } static size_t size_of(const value_type&) { return size_of(); } + static std::string string_for_value_type(void) { return "StatusInfo";} static size_t n_bytes(size_t _n_elem) { return _n_elem*sizeof(status_t); } diff --git a/src/OpenMesh/Core/IO/SR_binary_vector_of_bool.inl b/src/OpenMesh/Core/IO/SR_binary_vector_of_bool.inl index 3ec619ca..f5f9d19c 100644 --- a/src/OpenMesh/Core/IO/SR_binary_vector_of_bool.inl +++ b/src/OpenMesh/Core/IO/SR_binary_vector_of_bool.inl @@ -12,7 +12,7 @@ template <> struct binary< std::vector > { return _v.size() / 8 + ((_v.size() % 8)!=0); } - + static std::string string_for_value_type(void) { return get_string_for_type(value_type()); } static size_t store( std::ostream& _ostr, const value_type& _v, bool ) { diff --git a/src/OpenMesh/Core/IO/SR_binary_vector_of_fundamentals.inl b/src/OpenMesh/Core/IO/SR_binary_vector_of_fundamentals.inl index 15ebae26..ba995e0f 100644 --- a/src/OpenMesh/Core/IO/SR_binary_vector_of_fundamentals.inl +++ b/src/OpenMesh/Core/IO/SR_binary_vector_of_fundamentals.inl @@ -11,7 +11,7 @@ template <> struct binary< std::vector< T > > { \ \ static size_t size_of(const value_type& _v) \ { return sizeof(elem_type)*_v.size(); } \ - \ + static std::string string_for_value_type(void) { return get_string_for_type(value_type()); }\ static \ size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) { \ size_t bytes=0; \ diff --git a/src/OpenMesh/Core/IO/SR_binary_vector_of_string.inl b/src/OpenMesh/Core/IO/SR_binary_vector_of_string.inl index c6201ded..d420b30a 100644 --- a/src/OpenMesh/Core/IO/SR_binary_vector_of_string.inl +++ b/src/OpenMesh/Core/IO/SR_binary_vector_of_string.inl @@ -23,6 +23,7 @@ template <> struct binary< std::vector< std::string > > static size_t size_of(const value_type& _v) { return std::accumulate( _v.begin(), _v.end(), size_t(0), Sum() ); } + static std::string string_for_value_type(void) { return get_string_for_type(value_type()); } static size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) { diff --git a/src/Unittests/unittests_tutorials.cc b/src/Unittests/unittests_tutorials.cc index b227d166..c98455a8 100644 --- a/src/Unittests/unittests_tutorials.cc +++ b/src/Unittests/unittests_tutorials.cc @@ -79,6 +79,7 @@ namespace OpenMesh { return size_of(); } + static std::string string_for_value_type(void) { return "MyData"; } static size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) { size_t bytes; @@ -125,6 +126,7 @@ namespace OpenMesh { return bytes; } + static std::string string_for_value_type(void) { return "MyMap"; } static size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) {