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