MFEM  v4.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
binaryio.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_BINARYIO
13 #define MFEM_BINARYIO
14 
15 #include "../config/config.hpp"
16 
17 #include <iostream>
18 
19 namespace mfem
20 {
21 
22 // binary I/O helpers
23 
24 namespace bin_io
25 {
26 
27 template<typename T>
28 inline void write(std::ostream& os, T value)
29 {
30  os.write((char*) &value, sizeof(T));
31 }
32 
33 template<typename T>
34 inline T read(std::istream& is)
35 {
36  T value;
37  is.read((char*) &value, sizeof(T));
38  return value;
39 }
40 
41 } // namespace mfem::bin_io
42 
43 } // namespace mfem
44 
45 #endif
void write(std::ostream &os, T value)
Definition: binaryio.hpp:28
T read(std::istream &is)
Definition: binaryio.hpp:34