SpectMorph
smoutfile.hh
1 // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html
2 
3 #ifndef SPECTMORPH_OUT_FILE_HH
4 #define SPECTMORPH_OUT_FILE_HH
5 
6 #include <stdio.h>
7 #include <string>
8 #include <vector>
9 #include <set>
10 #include "smgenericout.hh"
11 
12 namespace SpectMorph
13 {
14 
15 class OutFile
16 {
17  GenericOut *file;
18  bool delete_file;
19  std::set<std::string> stored_blobs;
20 
21 protected:
22  void write_raw_string (const std::string& s);
23  void write_raw_int (int i);
24  void write_file_type_and_version (const std::string& file_type, int file_version);
25 
26 public:
27  OutFile (const std::string& filename, const std::string& file_type, int file_version);
28  OutFile (GenericOut *outfile, const std::string& file_type, int file_version);
29 
30  bool
31  open_ok()
32  {
33  return file != NULL;
34  }
35  ~OutFile();
36 
37  void begin_section (const std::string& s);
38  void end_section();
39 
40  void write_bool (const std::string& s, bool b);
41  void write_int (const std::string& s, int i);
42  void write_string (const std::string& s, const std::string& data);
43  void write_float (const std::string& s, double f);
44  void write_float_block (const std::string& s, const std::vector<float>& fb);
45  void write_uint16_block (const std::string& s, const std::vector<uint16_t>& ib);
46  void write_blob (const std::string& s, const void *data, size_t size);
47 };
48 
49 }
50 
51 #endif /* SPECTMORPH_OUT_FILE_HH */
Definition: smoutfile.hh:15
Definition: smalignedarray.cc:7
Generic Output Stream.
Definition: smgenericout.hh:17