00001 //============================================================================= 00002 // 00003 // OpenMesh 00004 // Copyright (C) 2001-2005 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 Library General Public License as published 00013 // by the Free Software Foundation, version 2. 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 // Library General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Library 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: 1.1.1.1 $ 00027 // $Date: 2004/09/06 12:35:07 $ 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.hh> 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, const value_type& _v, bool _swap=false) 00098 { X; return 0; } 00099 00100 static 00101 size_t restore( std::istream& _is, value_type& _v, bool _swap=false) 00102 { X; return 0; } 00103 }; 00104 00105 #undef X 00106 00107 00108 //============================================================================= 00109 } // namespace IO 00110 } // namespace OpenMesh 00111 //============================================================================= 00112 #endif // OPENMESH_SR_RBO_HH defined 00113 //============================================================================= 00114