nec2++  1.7.0
nec_output.h
1 #ifndef __nec_output__
2 #define __nec_output__
3 
4 /*
5  Copyright (C) 2004 Timothy C.A. Molteno
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 
22 #include <stdio.h>
23 #include "math_util.h"
24 #include "nec_debug.h"
25 
27 {
28 public:
30  {
31  do_gain = false;
32  do_nec_output = true;
33  }
34 
35  void set_gain_only(bool in_gain_only)
36  {
37  do_gain = in_gain_only;
38  do_nec_output = !in_gain_only;
39  }
40 
41  bool get_nec_flag()
42  {
43  return do_nec_output;
44  }
45 
46  bool get_gain_flag()
47  {
48  return do_gain;
49  }
50 
51 private:
52  bool do_gain;
53  bool do_nec_output;
54 };
55 
57 {
58 public:
60 
61  void set_file(FILE* in_fp);
62 
63  void endl(int n_lines = 1);
64 
65  void end_section();
66 
67  void set_indent(int n = 0);
68 
69  void line(const char* in_str);
70  void string(const char* in_str, bool require_endl = false);
71  void real(nec_float in_nec_float);
72  void real_out(int w, int p, nec_float f, bool sci = true);
73  void integer(long in_integer);
74 
75  void set_error_mode(bool f);
76 
77  void nec_printf(const char* fmt, ...);
78 
79  FILE* get_fp()
80  {
81  return m_output_fp;
82  }
83 
84 private:
85  void indent();
86  void do_output(const char* str);
87 
88  FILE* m_output_fp;
89  bool m_require_indent;
90  int m_indent;
91 
92  bool m_error_mode;
93 };
94 
95 
109 {
110 public:
112  : m_of(of)
113  {
114  of.set_error_mode(true);
115  }
116 
117  ~nec_error_mode()
118  {
119  m_of.set_error_mode(false);
120  }
121 private:
122  nec_output_file& m_of;
123 };
124 
125 #endif /* __nec_output__ */
Definition: nec_output.h:56
Definition: nec_output.h:26
Definition: nec_output.h:108