1 /**********************************************************************
3 FILENAME: uiuc_menu_mass.cpp
5 ----------------------------------------------------------------------
7 DESCRIPTION: reads input data for specified aircraft and creates
8 approporiate data storage space
10 ----------------------------------------------------------------------
14 ----------------------------------------------------------------------
16 REFERENCES: based on "menu reader" format of Michael Selig
18 ----------------------------------------------------------------------
20 HISTORY: 04/04/2003 initial release
21 06/30/2003 (RD) replaced istrstream with istringstream
22 to get rid of the annoying warning about
23 using the strstream header
25 ----------------------------------------------------------------------
27 AUTHOR(S): Robert Deters <rdeters@uiuc.edu>
28 Michael Selig <m-selig@uiuc.edu>
30 ----------------------------------------------------------------------
34 ----------------------------------------------------------------------
38 ----------------------------------------------------------------------
42 ----------------------------------------------------------------------
44 CALLED BY: uiuc_menu()
46 ----------------------------------------------------------------------
48 CALLS TO: check_float() if needed
54 ----------------------------------------------------------------------
56 COPYRIGHT: (C) 2003 by Michael Selig
58 This program is free software; you can redistribute it and/or
59 modify it under the terms of the GNU General Public License
60 as published by the Free Software Foundation.
62 This program is distributed in the hope that it will be useful,
63 but WITHOUT ANY WARRANTY; without even the implied warranty of
64 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
65 GNU General Public License for more details.
67 You should have received a copy of the GNU General Public License
68 along with this program; if not, write to the Free Software
69 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
71 **********************************************************************/
73 #include <simgear/compiler.h>
75 #if defined( __MWERKS__ )
76 // -dw- optimizer chokes (big-time) trying to optimize humongous
77 // loop/switch statements
78 #pragma optimization_level 0
85 #include "uiuc_menu_mass.h"
95 void parse_mass( const string& linetoken2, const string& linetoken3,
96 const string& linetoken4, const string& linetoken5,
97 const string& linetoken6, const string& linetoken7,
98 const string& linetoken8, const string& linetoken9,
99 const string& linetoken10, const string& aircraft_directory,
100 LIST command_line ) {
102 istringstream token3(linetoken3.c_str());
103 istringstream token4(linetoken4.c_str());
104 istringstream token5(linetoken5.c_str());
105 istringstream token6(linetoken6.c_str());
106 istringstream token7(linetoken7.c_str());
107 istringstream token8(linetoken8.c_str());
108 istringstream token9(linetoken9.c_str());
109 istringstream token10(linetoken10.c_str());
111 switch(mass_map[linetoken2])
115 if (check_float(linetoken3))
116 token3 >> token_value;
118 uiuc_warnings_errors(1, *command_line);
120 Weight = token_value;
121 Mass = Weight * INVG;
122 massParts -> storeCommands (*command_line);
127 if (check_float(linetoken3))
128 token3 >> token_value;
130 uiuc_warnings_errors(1, *command_line);
133 massParts -> storeCommands (*command_line);
138 if (check_float(linetoken3))
139 token3 >> token_value;
141 uiuc_warnings_errors(1, *command_line);
144 massParts -> storeCommands (*command_line);
149 if (check_float(linetoken3))
150 token3 >> token_value;
152 uiuc_warnings_errors(1, *command_line);
155 massParts -> storeCommands (*command_line);
160 if (check_float(linetoken3))
161 token3 >> token_value;
163 uiuc_warnings_errors(1, *command_line);
166 massParts -> storeCommands (*command_line);
171 if (check_float(linetoken3))
172 token3 >> token_value;
174 uiuc_warnings_errors(1, *command_line);
177 massParts -> storeCommands (*command_line);
180 case Mass_appMass_ratio_flag:
182 if (check_float(linetoken3))
183 token3 >> token_value;
185 uiuc_warnings_errors(1, *command_line);
187 Mass_appMass_ratio = token_value;
188 massParts -> storeCommands (*command_line);
191 case I_xx_appMass_ratio_flag:
193 if (check_float(linetoken3))
194 token3 >> token_value;
196 uiuc_warnings_errors(1, *command_line);
198 I_xx_appMass_ratio = token_value;
199 massParts -> storeCommands (*command_line);
202 case I_yy_appMass_ratio_flag:
204 if (check_float(linetoken3))
205 token3 >> token_value;
207 uiuc_warnings_errors(1, *command_line);
209 I_yy_appMass_ratio = token_value;
210 massParts -> storeCommands (*command_line);
213 case I_zz_appMass_ratio_flag:
215 if (check_float(linetoken3))
216 token3 >> token_value;
218 uiuc_warnings_errors(1, *command_line);
220 I_zz_appMass_ratio = token_value;
221 massParts -> storeCommands (*command_line);
224 case Mass_appMass_flag:
226 if (check_float(linetoken3))
227 token3 >> token_value;
229 uiuc_warnings_errors(1, *command_line);
231 Mass_appMass = token_value;
232 massParts -> storeCommands (*command_line);
235 case I_xx_appMass_flag:
237 if (check_float(linetoken3))
238 token3 >> token_value;
240 uiuc_warnings_errors(1, *command_line);
242 I_xx_appMass = token_value;
243 massParts -> storeCommands (*command_line);
246 case I_yy_appMass_flag:
248 if (check_float(linetoken3))
249 token3 >> token_value;
251 uiuc_warnings_errors(1, *command_line);
253 I_yy_appMass = token_value;
254 massParts -> storeCommands (*command_line);
257 case I_zz_appMass_flag:
259 if (check_float(linetoken3))
260 token3 >> token_value;
262 uiuc_warnings_errors(1, *command_line);
264 I_zz_appMass = token_value;
265 massParts -> storeCommands (*command_line);
270 if (ignore_unknown_keywords) {
273 // print error message
274 uiuc_warnings_errors(2, *command_line);