MCPcopy Create free account
hub / github.com/audacity/audacity / IfNotPlaying

Function IfNotPlaying

libraries/lib-wx-init/Journal.cpp:352–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350}
351
352int 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
386int GetExitCode()
387{

Callers 1

AudacityMessageBoxFunction · 0.85

Calls 8

SyncFunction · 0.85
IsReplayingFunction · 0.85
GetTokensFunction · 0.85
IsRecordingFunction · 0.85
OutputFunction · 0.85
sizeMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected