| 350 | } |
| 351 | |
| 352 | int IfNotPlaying( |
| 353 | const wxString &string, const InteractiveAction &action ) |
| 354 | { |
| 355 | // Special journal word |
| 356 | Sync(string); |
| 357 | |
| 358 | // Then read or write the return value on another journal line |
| 359 | if ( IsReplaying() ) { |
| 360 | auto tokens = GetTokens(); |
| 361 | if ( tokens.size() == 1 ) { |
| 362 | try { |
| 363 | std::wstring str{ tokens[0].wc_str() }; |
| 364 | size_t length = 0; |
| 365 | auto result = std::stoi(str, &length); |
| 366 | if (length == str.length()) { |
| 367 | if (IsRecording()) |
| 368 | Journal::Output( std::to_wstring(result) ); |
| 369 | return result; |
| 370 | } |
| 371 | } |
| 372 | catch ( const std::exception& ) {} |
| 373 | } |
| 374 | |
| 375 | throw SyncException(wxString::Format( |
| 376 | "unexpected tokens: %s", wxJoin(tokens, ',').ToStdString().c_str())); |
| 377 | } |
| 378 | else { |
| 379 | auto result = action ? action() : 0; |
| 380 | if ( IsRecording() ) |
| 381 | Output( std::to_wstring( result ) ); |
| 382 | return result; |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | int GetExitCode() |
| 387 | { |
no test coverage detected