DiaDes  0.1
DIAgnosis of Discrete-Event System
LiterateProgramming.hh
Go to the documentation of this file.
1 
8 #ifndef __DIADES__UTILS__LITERATEPROGRAMMING_HH
9 #define __DIADES__UTILS__LITERATEPROGRAMMING_HH
10 #include <string>
11 #include <stdexcept>
12 #include<exception>
13 #include<fstream>
14 #include <boost/format.hpp>
15 
16 
17 namespace Diades {
18  namespace Utils {
19 
20  class FileReporting {
21  private:
22  std::unique_ptr< std::ofstream > _file;
23  std::ostream * _os;
24  bool _latexMode;
25  void preambleLatex();
26  void epilogLatex();
27  public:
28  using Fmt = boost::format;
29 
30  FileReporting() : _file(new std::ofstream()), _os(nullptr),_latexMode(false) {
31  }
32  void open(const std::string& name);
33  void open(std::ostream & os);
34  void openLatex(const std::string& name);
35  void openLatex(std::ostream & os);
36 
37  void close();
38  void write(const std::string& msg);
39  void write(const Fmt & msg);
40  virtual ~FileReporting();
41  };
42  }
43 }
44 
45 #ifdef LITT_PROG
46 namespace Diades {
47  namespace Utils {
48  extern FileReporting report;
49  }
50 }
51 using Msg = boost::format;
52 #define LPOPENLATEX Diades::Utils::report.openLatex
53 #define LPOPEN Diades::Utils::report.open
54 #define LPCLOSE Diades::Utils::report.close
55 #define LP Diades::Utils::report.write
56 #else
57 #define LPOPENLATEX(...)
58 #define LPOPEN(...)
59 #define LPCLOSE(...)
60 #define LP(...)
61 #endif /* LITT_PROG */
62 
63 #endif
64 
STL namespace.
std::unique_ptr< std::ofstream > _file
Namespace of the Diades project.
void openLatex(const std::string &name)
void write(const std::string &msg)
void open(const std::string &name)
boost::format Msg
Definition: Verbose.hh:42