Audacity 3.2.0
JournalOutput.cpp
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file JournalOutput.cpp
6
7 Paul Licameli
8
9**********************************************************************/
10
11#include "JournalOutput.h"
12
13#include <wx/textfile.h>
14#include "wxArrayStringEx.h"
15
16namespace Journal {
17
18namespace {
19
20struct FlushingTextFile : wxTextFile {
21 // Flush output when the program quits, even if that makes an incomplete
22 // journal file without an exit
23 ~FlushingTextFile() { if ( IsOpened() ) { Write(); Close(); } }
25
26}
27
29{
30 return sFileOut.IsOpened();
31}
32
33bool OpenOut( const wxString &fullPath )
34{
35 sFileOut.Open( fullPath );
36 if ( sFileOut.IsOpened() )
37 sFileOut.Clear();
38 else {
39 sFileOut.Create();
40 sFileOut.Open( fullPath );
41 }
42 return sFileOut.IsOpened();
43}
44
45void Output( const wxString &string )
46{
47 if ( IsRecording() )
48 sFileOut.AddLine( string );
49}
50
51void Output( const wxArrayString &strings )
52{
53 if ( IsRecording() )
54 Output( ::wxJoin( strings, SeparatorCharacter, EscapeCharacter ) );
55}
56
57void Output( std::initializer_list< const wxString > strings )
58{
59 return Output( wxArrayStringEx( strings ) );
60}
61
62void Comment( const wxString &string )
63{
64 if ( IsRecording() )
65 sFileOut.AddLine( CommentCharacter + string );
66}
67
68}
The output stream of the journal system.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Journal::anonymous_namespace{JournalOutput.cpp}::FlushingTextFile sFileOut
Facilities for recording and playback of sequences of user interaction.
void Comment(const wxString &string)
constexpr auto EscapeCharacter
Definition: JournalOutput.h:23
void Output(const wxString &string)
constexpr auto SeparatorCharacter
Definition: JournalOutput.h:22
constexpr auto CommentCharacter
Definition: JournalOutput.h:24
bool OpenOut(const wxString &fullPath)
bool IsRecording()