Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bridgeIO.h
Go to the documentation of this file.
1 
14 #ifndef BRIDGEIO_INCLUDED
15 #define BRIDGEIO_INCLUDED
16 
17 #include <iostream>
18 #include <fstream>
19 #include <string>
20 #include <stack>
21 #include <cstdarg>
23 
25 
38 #define ENABLE_ILDG_TAG
39 
40 
41 namespace Bridge {
43  {
48  };
49 
50  class BridgeIO {
51  public:
52  static const std::string class_name;
53 
54  public:
55  // Constructor
56  BridgeIO(const std::string& filename = "stdout");
57  virtual ~BridgeIO();
58 
59  // set output to file or stream
60  void init(const std::string& filename);
61  void init(const std::ostream& os);
62 
63  // pop out current output stream
64  void unset();
65 
66  // verbose output for c style
67  // default verbose level, node 0
68  void crucial(const char *format, ...);
69  void general(const char *format, ...);
70  void detailed(const char *format, ...);
71  void paranoiac(const char *format, ...);
72 
73  // input verbose level, node 0
74  void crucial(VerboseLevel vl, const char *format, ...);
75  void general(VerboseLevel vl, const char *format, ...);
76  void detailed(VerboseLevel vl, const char *format, ...);
77  void paranoiac(VerboseLevel vl, const char *format, ...);
78 
79  // input verbose level, input node
80  void crucial(VerboseLevel vl, int node, const char *format, ...);
81  void general(VerboseLevel vl, int node, const char *format, ...);
82  void detailed(VerboseLevel vl, int node, const char *format, ...);
83  void paranoiac(VerboseLevel vl, int node, const char *format, ...);
84 
85 
86  bool isOpen();
87 
88  std::ostream& getStream();
89 
90 #ifdef ENABLE_ILDG_TAG
91  void ildg_init(const std::ostream& os);
92  void ildg_init(const std::string& filename);
93 
94  void ildg(const char *format, ...);
95 
96  std::ostream& getILDGStream();
97 #endif
98 
99  // convert between VerboseLevel and string expression
100  static VerboseLevel set_verbose_level(const std::string& str);
101  static std::string get_verbose_level(const VerboseLevel vl);
102 
103  private:
104 
105  // Hide copy constructor and assignment.
106  BridgeIO(const BridgeIO&);
107  BridgeIO& operator=(const BridgeIO&);
108 
109  // main method for verbose output for c style
110  inline void print(VerboseLevel level, VerboseLevel write_level,
111  int node, const char *format, va_list& arg);
112 
113  // internal methods
114  void rewind_();
115  void tidyup_();
116 
117  private:
118 
119  // current output target
120  std::ostream *os_;
121 
122  // previous output targets
123  std::stack<std::ostream *> stack_;
124 
125  // workarea
126  char buff_[1024];
127 
128 #ifdef ENABLE_ILDG_TAG
129  std::ostream *ildg_os_;
130 #endif
131  };
132 
133  extern BridgeIO vout;
134 }
135 #endif //BRIDGE_IO_INCLUDED
BridgeIO vout
Definition: bridgeIO.cpp:503
void detailed(const char *format,...)
Definition: bridgeIO.cpp:216
void general(const char *format,...)
Definition: bridgeIO.cpp:197
virtual ~BridgeIO()
Definition: bridgeIO.cpp:44
std::ostream * ildg_os_
Definition: bridgeIO.h:129
void ildg_init(const std::ostream &os)
Definition: bridgeIO.cpp:434
void init(const std::string &filename)
Definition: bridgeIO.cpp:51
std::stack< std::ostream * > stack_
Definition: bridgeIO.h:123
void ildg(const char *format,...)
Definition: bridgeIO.cpp:467
BridgeIO(const std::string &filename="stdout")
Definition: bridgeIO.cpp:27
void paranoiac(const char *format,...)
Definition: bridgeIO.cpp:235
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
Bridge::VerboseLevel vl
BridgeIO & operator=(const BridgeIO &)
VerboseLevel
Definition: bridgeIO.h:42
std::ostream & getStream()
Definition: bridgeIO.cpp:391
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:152
void print(VerboseLevel level, VerboseLevel write_level, int node, const char *format, va_list &arg)
Definition: bridgeIO.cpp:407
static const std::string class_name
Definition: bridgeIO.h:52
char buff_[1024]
Definition: bridgeIO.h:126
std::ostream * os_
Definition: bridgeIO.h:120
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
std::ostream & getILDGStream()
Definition: bridgeIO.cpp:494