OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SR_binary.hh
1 /*===========================================================================*\
2  * *
3  * OpenMesh *
4  * Copyright (C) 2001-2014 by Computer Graphics Group, RWTH Aachen *
5  * www.openmesh.org *
6  * *
7  *---------------------------------------------------------------------------*
8  * This file is part of OpenMesh. *
9  * *
10  * OpenMesh is free software: you can redistribute it and/or modify *
11  * it under the terms of the GNU Lesser General Public License as *
12  * published by the Free Software Foundation, either version 3 of *
13  * the License, or (at your option) any later version with the *
14  * following exceptions: *
15  * *
16  * If other files instantiate templates or use macros *
17  * or inline functions from this file, or you compile this file and *
18  * link it with other files to produce an executable, this file does *
19  * not by itself cause the resulting executable to be covered by the *
20  * GNU Lesser General Public License. This exception does not however *
21  * invalidate any other reasons why the executable file might be *
22  * covered by the GNU Lesser General Public License. *
23  * *
24  * OpenMesh is distributed in the hope that it will be useful, *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27  * GNU Lesser General Public License for more details. *
28  * *
29  * You should have received a copy of the GNU LesserGeneral Public *
30  * License along with OpenMesh. If not, *
31  * see <http://www.gnu.org/licenses/>. *
32  * *
33 \*===========================================================================*/
34 
35 /*===========================================================================*\
36  * *
37  * $Revision: 990 $ *
38  * $Date: 2014-02-05 10:01:07 +0100 (Mi, 05 Feb 2014) $ *
39  * *
40 \*===========================================================================*/
41 
42 
43 //=============================================================================
44 //
45 // Helper Functions for binary reading / writing
46 //
47 //=============================================================================
48 
49 #ifndef OPENMESH_SR_BINARY_HH
50 #define OPENMESH_SR_BINARY_HH
51 
52 
53 //== INCLUDES =================================================================
54 
55 #include <OpenMesh/Core/System/config.h>
56 // -------------------- STL
57 #include <typeinfo>
58 #include <stdexcept>
59 #include <sstream>
60 #include <numeric> // accumulate
61 // -------------------- OpenMesh
62 
63 
64 //== NAMESPACES ===============================================================
65 
66 namespace OpenMesh {
67 namespace IO {
68 
69 
70 //=============================================================================
71 
72 
73 //-----------------------------------------------------------------------------
74 
75  const static size_t UnknownSize(size_t(-1));
76 
77 
78 //-----------------------------------------------------------------------------
79 // struct binary, helper for storing/restoring
80 
81 #define X \
82  std::ostringstream msg; \
83  msg << "Type not supported: " << typeid(value_type).name(); \
84  throw std::logic_error(msg.str())
85 
98 template < typename T > struct binary
99 {
100  typedef T value_type;
101 
102  static const bool is_streamable = false;
103 
104  static size_t size_of(void) { return UnknownSize; }
105  static size_t size_of(const value_type&) { return UnknownSize; }
106 
107  static
108  size_t store( std::ostream& /* _os */,
109  const value_type& /* _v */,
110  bool /* _swap=false */)
111  { X; return 0; }
112 
113  static
114  size_t restore( std::istream& /* _is */,
115  value_type& /* _v */,
116  bool /* _swap=false */)
117  { X; return 0; }
118 };
119 
120 #undef X
121 
122 
123 //=============================================================================
124 } // namespace IO
125 } // namespace OpenMesh
126 //=============================================================================
127 #endif // OPENMESH_SR_RBO_HH defined
128 //=============================================================================
129 
The struct defines how to store and restore the type T.
Definition: SR_binary.hh:98

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .