From 7f6e86ff62840eefeb8842751523ca9302de5c3d Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Mon, 15 Mar 2021 14:15:18 +0100 Subject: [PATCH] simplify how names for property types are generated --- src/OpenMesh/Core/IO/SR_binary_spec.hh | 20 ++++++------- .../Core/IO/SR_binary_vector_of_bool.inl | 2 +- src/OpenMesh/Core/Utils/typename.hh | 29 ------------------- 3 files changed, 11 insertions(+), 40 deletions(-) diff --git a/src/OpenMesh/Core/IO/SR_binary_spec.hh b/src/OpenMesh/Core/IO/SR_binary_spec.hh index 2bb7ceeb..326ed5d6 100644 --- a/src/OpenMesh/Core/IO/SR_binary_spec.hh +++ b/src/OpenMesh/Core/IO/SR_binary_spec.hh @@ -96,7 +96,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 std::string string_for_value_type(void) { return #T; } \ static size_t store( std::ostream& _os, const value_type& _val, \ bool _swap=false) { \ value_type tmp = _val; \ @@ -133,11 +133,11 @@ SIMPLE_BINARY(uint32_t); SIMPLE_BINARY(uint64_t); //handles -SIMPLE_BINARY(OpenMesh::FaceHandle); -SIMPLE_BINARY(OpenMesh::EdgeHandle); -SIMPLE_BINARY(OpenMesh::HalfedgeHandle); -SIMPLE_BINARY(OpenMesh::VertexHandle); -SIMPLE_BINARY(OpenMesh::MeshHandle); +SIMPLE_BINARY(FaceHandle); +SIMPLE_BINARY(EdgeHandle); +SIMPLE_BINARY(HalfedgeHandle); +SIMPLE_BINARY(VertexHandle); +SIMPLE_BINARY(MeshHandle); #undef SIMPLE_BINARY @@ -155,7 +155,7 @@ SIMPLE_BINARY(OpenMesh::MeshHandle); 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 std::string string_for_value_type(void) { return #T; } \ static size_t store( std::ostream& _os, const value_type& _val, \ bool _swap=false) { \ value_type tmp = _val; \ @@ -186,7 +186,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 std::string string_for_value_type(void) { return #T; } \ static size_t store( std::ostream& _os, const value_type& _val, \ bool _swap=false) { \ value_type tmp = _val; \ @@ -238,7 +238,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 std::string string_for_value_type(void) { return "std::string"; } static size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) { @@ -353,7 +353,7 @@ struct binary< std::vector< T > > { } } - static std::string string_for_value_type(void) { return get_string_for_type(value_type()); } + static std::string string_for_value_type(void) { return "std::vector<" + binary::string_for_value_type() + ">"; } static size_t store(std::ostream& _os, const value_type& _v, bool _swap=false, bool _store_size = true) { size_t bytes=0; 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 3c9b1143..37c60dcc 100644 --- a/src/OpenMesh/Core/IO/SR_binary_vector_of_bool.inl +++ b/src/OpenMesh/Core/IO/SR_binary_vector_of_bool.inl @@ -14,7 +14,7 @@ template <> struct binary< std::vector > size += binary::size_of(); return size; } - static std::string string_for_value_type(void) { return get_string_for_type(value_type()); } + static std::string string_for_value_type(void) { return "std::vector"; } static size_t store( std::ostream& _ostr, const value_type& _v, bool _swap, bool _store_size = true) { diff --git a/src/OpenMesh/Core/Utils/typename.hh b/src/OpenMesh/Core/Utils/typename.hh index 9b678711..0ac7c3cd 100644 --- a/src/OpenMesh/Core/Utils/typename.hh +++ b/src/OpenMesh/Core/Utils/typename.hh @@ -26,33 +26,4 @@ std::string get_type_name() #endif } -//----------------------get string for type recognition-- can be used in file format - -inline std::string get_string_for_type(OpenMesh::FaceHandle){ return "facehandle";} -inline std::string get_string_for_type(OpenMesh::EdgeHandle){ return "edgehandle";} -inline std::string get_string_for_type(OpenMesh::HalfedgeHandle){ return "halfedgehandle";} -inline std::string get_string_for_type(OpenMesh::VertexHandle){ return "vertexhandle";} -inline std::string get_string_for_type(OpenMesh::MeshHandle){ return "meshhandle";} - -inline std::string get_string_for_type(bool){ return "bool";} -inline std::string get_string_for_type(char){ return "char";} -inline std::string get_string_for_type(signed char){ return "signed char";} -inline std::string get_string_for_type(double){ return "double";} -inline std::string get_string_for_type(float){ return "float";} -inline std::string get_string_for_type(int){ return "int";} -inline std::string get_string_for_type(short){ return "short";} - -inline std::string get_string_for_type(unsigned char){ return "uchar";} -inline std::string get_string_for_type(unsigned int){ return "uint";} -inline std::string get_string_for_type(unsigned short){ return "ushort";} -inline std::string get_string_for_type(unsigned long){ return "ulong";} - -inline std::string get_string_for_type(std::string){ return "std::string";} - -template std::string get_string_for_type(T){return "unknown";} -template std::string get_string_for_type(std::vector){ return "std::vector<" + get_string_for_type(T()) + ">";} - -template std::string get_string_for_type(OpenMesh::VectorT) -{ return "VectorT<" + get_string_for_type(T()) + ", " + std::to_string(Dim) + ">";} - }//namespace OpenMesh