added static function string_for_value_type (void) to binary struct

and adapted each instance
This commit is contained in:
Alexandra Heuschling
2021-01-05 17:50:52 +01:00
parent d835958b6b
commit 6932a33414
6 changed files with 15 additions and 3 deletions

View File

@@ -106,6 +106,8 @@ template < typename T > struct binary
static size_t size_of(void) { return UnknownSize; } static size_t size_of(void) { return UnknownSize; }
static size_t size_of(const value_type&) { return UnknownSize; } static size_t size_of(const value_type&) { return UnknownSize; }
static std::string string_for_value_type (void) { return "UnknownType"; }
static static
size_t store( std::ostream& /* _os */, size_t store( std::ostream& /* _os */,
const value_type& /* _v */, const value_type& /* _v */,

View File

@@ -72,6 +72,9 @@
#include <OpenMesh/Core/IO/SR_rbo.hh> #include <OpenMesh/Core/IO/SR_rbo.hh>
#include <OpenMesh/Core/IO/SR_binary.hh> #include <OpenMesh/Core/IO/SR_binary.hh>
#include <OpenMesh/Core/Utils/typename.hh>
//== NAMESPACES =============================================================== //== NAMESPACES ===============================================================
namespace OpenMesh { namespace OpenMesh {
@@ -91,6 +94,7 @@ namespace IO {
static const bool is_streamable = true; \ static const bool is_streamable = true; \
static size_t size_of(const value_type&) { return sizeof(value_type); } \ static size_t size_of(const value_type&) { return sizeof(value_type); } \
static size_t size_of(void) { 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, \ static size_t store( std::ostream& _os, const value_type& _val, \
bool _swap=false) { \ bool _swap=false) { \
value_type tmp = _val; \ value_type tmp = _val; \
@@ -142,6 +146,7 @@ SIMPLE_BINARY(uint64_t);
static const bool is_streamable = true; \ static const bool is_streamable = true; \
static size_t size_of(const value_type&) { return sizeof(value_type); } \ static size_t size_of(const value_type&) { return sizeof(value_type); } \
static size_t size_of(void) { 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, \ static size_t store( std::ostream& _os, const value_type& _val, \
bool _swap=false) { \ bool _swap=false) { \
value_type tmp = _val; \ value_type tmp = _val; \
@@ -172,6 +177,7 @@ SIMPLE_BINARY(unsigned long);
static const bool is_streamable = true; \ static const bool is_streamable = true; \
static size_t size_of(void) { return sizeof(value_type); } \ static size_t size_of(void) { return sizeof(value_type); } \
static size_t size_of(const value_type&) { return size_of(); } \ 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, \ static size_t store( std::ostream& _os, const value_type& _val, \
bool _swap=false) { \ bool _swap=false) { \
value_type tmp = _val; \ 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() { return UnknownSize; }
static size_t size_of(const value_type &_v) static size_t size_of(const value_type &_v)
{ return sizeof(length_t) + _v.size(); } { return sizeof(length_t) + _v.size(); }
static std::string string_for_value_type(void) { return get_string_for_type(value_type()); }
static static
size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) size_t store(std::ostream& _os, const value_type& _v, bool _swap=false)
{ {
@@ -264,6 +270,7 @@ template <> struct binary<OpenMesh::Attributes::StatusInfo>
static size_t size_of() { return sizeof(status_t); } static size_t size_of() { return sizeof(status_t); }
static size_t size_of(const value_type&) { return size_of(); } 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) static size_t n_bytes(size_t _n_elem)
{ return _n_elem*sizeof(status_t); } { return _n_elem*sizeof(status_t); }

View File

@@ -12,7 +12,7 @@ template <> struct binary< std::vector<bool> >
{ {
return _v.size() / 8 + ((_v.size() % 8)!=0); return _v.size() / 8 + ((_v.size() % 8)!=0);
} }
static std::string string_for_value_type(void) { return get_string_for_type(value_type()); }
static static
size_t store( std::ostream& _ostr, const value_type& _v, bool ) size_t store( std::ostream& _ostr, const value_type& _v, bool )
{ {

View File

@@ -11,7 +11,7 @@ template <> struct binary< std::vector< T > > { \
\ \
static size_t size_of(const value_type& _v) \ static size_t size_of(const value_type& _v) \
{ return sizeof(elem_type)*_v.size(); } \ { return sizeof(elem_type)*_v.size(); } \
\ static std::string string_for_value_type(void) { return get_string_for_type(value_type()); }\
static \ static \
size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) { \ size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) { \
size_t bytes=0; \ size_t bytes=0; \

View File

@@ -23,6 +23,7 @@ template <> struct binary< std::vector< std::string > >
static size_t size_of(const value_type& _v) static size_t size_of(const value_type& _v)
{ return std::accumulate( _v.begin(), _v.end(), size_t(0), Sum() ); } { 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 static
size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) size_t store(std::ostream& _os, const value_type& _v, bool _swap=false)
{ {

View File

@@ -79,6 +79,7 @@ namespace OpenMesh {
return size_of(); 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) static size_t store(std::ostream& _os, const value_type& _v, bool _swap=false)
{ {
size_t bytes; size_t bytes;
@@ -125,6 +126,7 @@ namespace OpenMesh {
return bytes; return bytes;
} }
static std::string string_for_value_type(void) { return "MyMap"; }
static static
size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) size_t store(std::ostream& _os, const value_type& _v, bool _swap=false)
{ {