Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
fileData.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
23 #pragma once
24 
25 #include <string>
26 #include <vector>
27 #include <string_view>
28 #include <iostream>
29 #include <fstream>
30 #include <functional>
31 
32 namespace mty::doc {
33 
34 class FileData {
35 
36 public:
37 
38  enum Mode {
39  None,
40  Header,
41  Source
42  };
43 
44  enum Error {
45  TypeError,
46  IOErrorHeader,
47  IOErrorSource
48  };
49 
50  FileData();
51  FileData(
52  std::string_view headerName,
53  std::string_view sourceName
54  );
55 
56  FileData(FileData const &other) = delete;
57  FileData &operator=(FileData const &other) = delete;
58 
59  ~FileData();
60 
61  void openStream();
62 
63  size_t getIndentSize() const { return m_indent.size(); }
64  std::string const &indent() const;
65  void setIndentSize(size_t s);
66 
67  std::ostream &getStream(Mode mode);
68 
69 private:
70 
71  Mode mode;
72  std::ofstream header;
73  std::ofstream source;
74  std::string headerName;
75  std::string sourceName;
76  std::string m_indent;
77 };
78 
79 }
Definition: fileData.h:34
Definition: checkpoint.h:38