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