DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
LongvolWriter.h
1 
17 #pragma once
18 
31 #if defined(LongvolWriter_RECURSES)
32 #error Recursive header files inclusion detected in LongvolWriter.h
33 #else // defined(LongvolWriter_RECURSES)
34 
35 #define LongvolWriter_RECURSES
36 
37 #if !defined LongvolWriter_h
38 
39 #define LongvolWriter_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <string>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/base/CUnaryFunctor.h"
47 #include "DGtal/base/BasicFunctors.h"
49 
50 namespace DGtal
51 {
52 
54  // template class LongvolWriter
68  template <typename TImage, typename TFunctor = DefaultFunctor>
70  {
71  // ----------------------- Standard services ------------------------------
72 
73  typedef TImage Image;
74  typedef typename TImage::Value Value;
75  typedef TFunctor Functor;
77 
79 
80 
90  static bool exportLongvol(const std::string & filename, const Image &aImage,
91  const Functor & aFunctor = Functor()) throw(DGtal::IOException);
92 
93 
94  private:
95 
104  template <typename Word>
105  static
106  ostream& write_word( ostream& outs, Word value )
107  {
108  for (unsigned size = sizeof( Word ); size; --size, value >>= 8)
109  outs.put( static_cast <char> (value & 0xFF) );
110  return outs;
111  }
112 
113  };
114 }//namespace
115 
117 // Includes inline functions.
118 #include "DGtal/io/writers/LongvolWriter.ih"
119 
120 // //
122 
123 #endif // !defined LongvolWriter_h
124 
125 #undef LongvolWriter_RECURSES
126 #endif // else defined(LongvolWriter_RECURSES)