| 1 | /********************************************************************** |
| 2 | |
| 3 | FILENAME: uiuc_menu_mass.cpp |
| 4 | |
| 5 | ---------------------------------------------------------------------- |
| 6 | |
| 7 | DESCRIPTION: reads input data for specified aircraft and creates |
| 8 | approporiate data storage space |
| 9 | |
| 10 | ---------------------------------------------------------------------- |
| 11 | |
| 12 | STATUS: alpha version |
| 13 | |
| 14 | ---------------------------------------------------------------------- |
| 15 | |
| 16 | REFERENCES: based on "menu reader" format of Michael Selig |
| 17 | |
| 18 | ---------------------------------------------------------------------- |
| 19 | |
| 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 |
| 24 | |
| 25 | ---------------------------------------------------------------------- |
| 26 | |
| 27 | AUTHOR(S): Robert Deters <[email protected]> |
| 28 | Michael Selig <[email protected]> |
| 29 | |
| 30 | ---------------------------------------------------------------------- |
| 31 | |
| 32 | VARIABLES: |
| 33 | |
| 34 | ---------------------------------------------------------------------- |
| 35 | |
| 36 | INPUTS: n/a |
| 37 | |
| 38 | ---------------------------------------------------------------------- |
| 39 | |
| 40 | OUTPUTS: n/a |
| 41 | |
| 42 | ---------------------------------------------------------------------- |
| 43 | |
| 44 | CALLED BY: uiuc_menu() |
| 45 | |
| 46 | ---------------------------------------------------------------------- |
| 47 | |
| 48 | CALLS TO: check_float() if needed |
| 49 | d_2_to_3() if needed |
| 50 | d_1_to_2() if needed |
| 51 | i_1_to_2() if needed |
| 52 | d_1_to_1() if needed |
| 53 | |
| 54 | ---------------------------------------------------------------------- |
| 55 | |
| 56 | COPYRIGHT: (C) 2003 by Michael Selig |
| 57 | |
| 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. |
| 61 | |
| 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. |
| 66 | |
| 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. |
| 70 | |
| 71 | **********************************************************************/ |
| 72 | |
| 73 | #include <simgear/compiler.h> |
| 74 | |
| 75 | |
| 76 | #include <cstdlib> |
| 77 | #include <string> |
| 78 | #include <iostream> |
| 79 | |
| 80 | #include "uiuc_menu_mass.h" |
| 81 | |
| 82 | using std::string; |
| 83 | using std::istringstream; |
| 84 | using std::cerr; |
| 85 | using std::cout; |
| 86 | using std::endl; |
| 87 | |
| 88 | #ifndef _MSC_VER |
| 89 | using std::exit; |
| 90 | #endif |
| 91 | |
| 92 | void parse_mass( const string& linetoken2, const string& linetoken3, |
| 93 | const string& linetoken4, const string& linetoken5, |
| 94 | const string& linetoken6, const string& linetoken7, |
| 95 | const string& linetoken8, const string& linetoken9, |
| 96 | const string& linetoken10, const string& aircraft_directory, |
| 97 | LIST command_line ) { |
| 98 | double token_value; |
| 99 | istringstream token3(linetoken3.c_str()); |
| 100 | istringstream token4(linetoken4.c_str()); |
| 101 | istringstream token5(linetoken5.c_str()); |
| 102 | istringstream token6(linetoken6.c_str()); |
| 103 | istringstream token7(linetoken7.c_str()); |
| 104 | istringstream token8(linetoken8.c_str()); |
| 105 | istringstream token9(linetoken9.c_str()); |
| 106 | istringstream token10(linetoken10.c_str()); |
| 107 | |
| 108 | switch(mass_map[linetoken2]) |
| 109 | { |
| 110 | case Weight_flag: |
| 111 | { |
| 112 | if (check_float(linetoken3)) |
| 113 | token3 >> token_value; |
| 114 | else |
| 115 | uiuc_warnings_errors(1, *command_line); |
| 116 | |
| 117 | Weight = token_value; |
| 118 | Mass = Weight * INVG; |
| 119 | massParts -> storeCommands (*command_line); |
| 120 | break; |
| 121 | } |
| 122 | case Mass_flag: |
| 123 | { |
| 124 | if (check_float(linetoken3)) |
| 125 | token3 >> token_value; |
| 126 | else |
| 127 | uiuc_warnings_errors(1, *command_line); |
| 128 | |
| 129 | Mass = token_value; |
| 130 | massParts -> storeCommands (*command_line); |
| 131 | break; |
| 132 | } |
| 133 | case I_xx_flag: |
| 134 | { |
| 135 | if (check_float(linetoken3)) |
| 136 | token3 >> token_value; |
| 137 | else |
| 138 | uiuc_warnings_errors(1, *command_line); |
| 139 | |
| 140 | I_xx = token_value; |
| 141 | massParts -> storeCommands (*command_line); |
| 142 | break; |
| 143 | } |
| 144 | case I_yy_flag: |
| 145 | { |
| 146 | if (check_float(linetoken3)) |
| 147 | token3 >> token_value; |
| 148 | else |
| 149 | uiuc_warnings_errors(1, *command_line); |
| 150 | |
| 151 | I_yy = token_value; |
| 152 | massParts -> storeCommands (*command_line); |
| 153 | break; |
| 154 | } |
| 155 | case I_zz_flag: |
| 156 | { |
| 157 | if (check_float(linetoken3)) |
| 158 | token3 >> token_value; |
| 159 | else |
| 160 | uiuc_warnings_errors(1, *command_line); |
| 161 | |
| 162 | I_zz = token_value; |
| 163 | massParts -> storeCommands (*command_line); |
| 164 | break; |
| 165 | } |
| 166 | case I_xz_flag: |
| 167 | { |
| 168 | if (check_float(linetoken3)) |
| 169 | token3 >> token_value; |
| 170 | else |
| 171 | uiuc_warnings_errors(1, *command_line); |
| 172 | |
| 173 | I_xz = token_value; |
| 174 | massParts -> storeCommands (*command_line); |
| 175 | break; |
| 176 | } |
| 177 | case Mass_appMass_ratio_flag: |
| 178 | { |
| 179 | if (check_float(linetoken3)) |
| 180 | token3 >> token_value; |
| 181 | else |
| 182 | uiuc_warnings_errors(1, *command_line); |
| 183 | |
| 184 | Mass_appMass_ratio = token_value; |
| 185 | massParts -> storeCommands (*command_line); |
| 186 | break; |
| 187 | } |
| 188 | case I_xx_appMass_ratio_flag: |
| 189 | { |
| 190 | if (check_float(linetoken3)) |
| 191 | token3 >> token_value; |
| 192 | else |
| 193 | uiuc_warnings_errors(1, *command_line); |
| 194 | |
| 195 | I_xx_appMass_ratio = token_value; |
| 196 | massParts -> storeCommands (*command_line); |
| 197 | break; |
| 198 | } |
| 199 | case I_yy_appMass_ratio_flag: |
| 200 | { |
| 201 | if (check_float(linetoken3)) |
| 202 | token3 >> token_value; |
| 203 | else |
| 204 | uiuc_warnings_errors(1, *command_line); |
| 205 | |
| 206 | I_yy_appMass_ratio = token_value; |
| 207 | massParts -> storeCommands (*command_line); |
| 208 | break; |
| 209 | } |
| 210 | case I_zz_appMass_ratio_flag: |
| 211 | { |
| 212 | if (check_float(linetoken3)) |
| 213 | token3 >> token_value; |
| 214 | else |
| 215 | uiuc_warnings_errors(1, *command_line); |
| 216 | |
| 217 | I_zz_appMass_ratio = token_value; |
| 218 | massParts -> storeCommands (*command_line); |
| 219 | break; |
| 220 | } |
| 221 | case Mass_appMass_flag: |
| 222 | { |
| 223 | if (check_float(linetoken3)) |
| 224 | token3 >> token_value; |
| 225 | else |
| 226 | uiuc_warnings_errors(1, *command_line); |
| 227 | |
| 228 | Mass_appMass = token_value; |
| 229 | massParts -> storeCommands (*command_line); |
| 230 | break; |
| 231 | } |
| 232 | case I_xx_appMass_flag: |
| 233 | { |
| 234 | if (check_float(linetoken3)) |
| 235 | token3 >> token_value; |
| 236 | else |
| 237 | uiuc_warnings_errors(1, *command_line); |
| 238 | |
| 239 | I_xx_appMass = token_value; |
| 240 | massParts -> storeCommands (*command_line); |
| 241 | break; |
| 242 | } |
| 243 | case I_yy_appMass_flag: |
| 244 | { |
| 245 | if (check_float(linetoken3)) |
| 246 | token3 >> token_value; |
| 247 | else |
| 248 | uiuc_warnings_errors(1, *command_line); |
| 249 | |
| 250 | I_yy_appMass = token_value; |
| 251 | massParts -> storeCommands (*command_line); |
| 252 | break; |
| 253 | } |
| 254 | case I_zz_appMass_flag: |
| 255 | { |
| 256 | if (check_float(linetoken3)) |
| 257 | token3 >> token_value; |
| 258 | else |
| 259 | uiuc_warnings_errors(1, *command_line); |
| 260 | |
| 261 | I_zz_appMass = token_value; |
| 262 | massParts -> storeCommands (*command_line); |
| 263 | break; |
| 264 | } |
| 265 | default: |
| 266 | { |
| 267 | if (ignore_unknown_keywords) { |
| 268 | // do nothing |
| 269 | } else { |
| 270 | // print error message |
| 271 | uiuc_warnings_errors(2, *command_line); |
| 272 | } |
| 273 | break; |
| 274 | } |
| 275 | }; |
| 276 | } |