00001 //============================================================================= 00002 // 00003 // OpenMesh 00004 // Copyright (C) 2003 by Computer Graphics Group, RWTH Aachen 00005 // www.openmesh.org 00006 // 00007 //----------------------------------------------------------------------------- 00008 // 00009 // License 00010 // 00011 // This library is free software; you can redistribute it and/or modify it 00012 // under the terms of the GNU Lesser General Public License as published 00013 // by the Free Software Foundation, version 2.1. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00023 // 00024 //----------------------------------------------------------------------------- 00025 // 00026 // $Revision: 1801 $ 00027 // $Date: 2008-05-19 11:53:56 +0200 (Mon, 19 May 2008) $ 00028 // 00029 //============================================================================= 00030 00031 00032 //============================================================================= 00033 // 00034 // Helper Functions for binary reading / writing 00035 // 00036 //============================================================================= 00037 00038 #ifndef OPENMESH_SR_BINARY_HH 00039 #define OPENMESH_SR_BINARY_HH 00040 00041 00042 //== INCLUDES ================================================================= 00043 00044 #include <OpenMesh/Core/System/config.h> 00045 // -------------------- STL 00046 #include <typeinfo> 00047 #include <stdexcept> 00048 #include <sstream> 00049 #include <numeric> // accumulate 00050 // -------------------- OpenMesh 00051 00052 00053 //== NAMESPACES =============================================================== 00054 00055 namespace OpenMesh { 00056 namespace IO { 00057 00058 00059 //============================================================================= 00060 00061 00062 //----------------------------------------------------------------------------- 00063 00064 const static size_t UnknownSize(size_t(-1)); 00065 00066 00067 //----------------------------------------------------------------------------- 00068 // struct binary, helper for storing/restoring 00069 00070 #define X \ 00071 std::ostringstream msg; \ 00072 msg << "Type not supported: " << typeid(value_type).name(); \ 00073 throw std::logic_error(msg.str()) 00074 00087 template < typename T > struct binary 00088 { 00089 typedef T value_type; 00090 00091 static const bool is_streamable = false; 00092 00093 static size_t size_of(void) { return UnknownSize; } 00094 static size_t size_of(const value_type&) { return UnknownSize; } 00095 00096 static 00097 size_t store( std::ostream& /* _os */, 00098 const value_type& /* _v */, 00099 bool /* _swap=false */) 00100 { X; return 0; } 00101 00102 static 00103 size_t restore( std::istream& /* _is */, 00104 value_type& /* _v */, 00105 bool /* _swap=false */) 00106 { X; return 0; } 00107 }; 00108 00109 #undef X 00110 00111 00112 //============================================================================= 00113 } // namespace IO 00114 } // namespace OpenMesh 00115 //============================================================================= 00116 #endif // OPENMESH_SR_RBO_HH defined 00117 //============================================================================= 00118