/ Parsing Event List File Format ////
| 385 | |
| 386 | //// Parsing Event List File Format //// |
| 387 | bool cEventList::AddEventFileFormat(const cString& in_line, Feedback& feedback) |
| 388 | { |
| 389 | cString cur_line = in_line; |
| 390 | |
| 391 | // Timing |
| 392 | eTriggerType trigger = UPDATE; |
| 393 | double start = TRIGGER_BEGIN; |
| 394 | double interval = TRIGGER_ONCE; |
| 395 | double stop = TRIGGER_END; |
| 396 | |
| 397 | cString name; |
| 398 | cString arg_list; |
| 399 | |
| 400 | cString tmp; |
| 401 | |
| 402 | cString cur_word = cur_line.PopWord(); |
| 403 | |
| 404 | // Get the trigger variable if there |
| 405 | if (cur_word == "i" || cur_word == "immediate") { |
| 406 | trigger = IMMEDIATE; |
| 407 | name = cur_line.PopWord(); |
| 408 | return AddEvent(IMMEDIATE, TRIGGER_BEGIN, TRIGGER_ONCE, TRIGGER_END, name, cur_line, feedback); |
| 409 | } else if (cur_word == "u" || cur_word == "update") { |
| 410 | trigger = UPDATE; |
| 411 | cur_word = cur_line.PopWord(); |
| 412 | } else if( cur_word == "g" || cur_word == "generation") { |
| 413 | trigger = GENERATION; |
| 414 | cur_word = cur_line.PopWord(); |
| 415 | } else if (cur_word == "b" || cur_word == "births") { |
| 416 | trigger = BIRTHS; |
| 417 | cur_word = cur_line.PopWord(); |
| 418 | } else if (cur_word == "o" || cur_word == "org_id") { |
| 419 | trigger = BIRTHS_INTERRUPT; |
| 420 | cur_word = cur_line.PopWord(); |
| 421 | } else { |
| 422 | cerr << "error: unrecognized event trigger '" << cur_word << "'" << endl; |
| 423 | return false; |
| 424 | } |
| 425 | |
| 426 | // Do we now have timing specified? |
| 427 | // Parse the Timing |
| 428 | cString timing_str = cur_word; |
| 429 | |
| 430 | // Get the start:interval:stop |
| 431 | tmp = timing_str.Pop(':'); |
| 432 | |
| 433 | // If first value is valid, we are getting a timing. |
| 434 | if (tmp.IsNumber() || tmp == "begin") { |
| 435 | |
| 436 | // First number is start |
| 437 | if (tmp == "begin") start = TRIGGER_BEGIN; |
| 438 | else start = tmp.AsDouble(); |
| 439 | |
| 440 | // If no other words... is "start" syntax |
| 441 | if (timing_str.GetSize() == 0) { |
| 442 | interval = TRIGGER_ONCE; |
| 443 | stop = TRIGGER_END; |
| 444 | } else { |