Audacity 3.2.0
Classes | Functions | Variables
Journal::anonymous_namespace{Journal.cpp} Namespace Reference

Classes

class  JournalLogger
 

Functions

JournalLoggerGetLogger ()
 
std::string ToString (const wxString &str)
 
template<typename T >
std::string ToString (const T &arg)
 
template<typename... Args>
void Log (std::string_view message, const Args &... args)
 
void NextIn ()
 
wxArrayStringEx PeekTokens ()
 
wxString VersionString ()
 
bool VersionCheck (const wxString &value)
 True if value is an acceptable journal version number to be rerun. More...
 

Variables

wxString sFileNameIn
 
wxTextFile sFileIn
 
wxString sLine
 
int sLineNumber = -1
 
BoolSetting JournalEnabled { L"/Journal/Enabled", false }
 
constexpr auto VersionToken = wxT("Version")
 
int journalVersionNumbers []
 

Function Documentation

◆ GetLogger()

JournalLogger & Journal::anonymous_namespace{Journal.cpp}::GetLogger ( )

Definition at line 69 of file Journal.cpp.

70{
71 static JournalLogger logger;
72 return logger;
73}

Referenced by Log().

Here is the caller graph for this function:

◆ Log()

template<typename... Args>
void Journal::anonymous_namespace{Journal.cpp}::Log ( std::string_view  message,
const Args &...  args 
)

Definition at line 87 of file Journal.cpp.

88{
89 if (message.empty())
90 return;
91
92 constexpr auto n = sizeof...(Args);
93
94 std::string strings[n];
95 std::size_t i = 0;
96 ((strings[i++] = ToString(args)), ...);
97 i = 0;
98
99 auto& logger = GetLogger();
100
101 while (!message.empty())
102 {
103 const auto placeholderPos = message.find("{}");
104
105 if (placeholderPos == std::string_view::npos || i == n)
106 {
107 logger.WriteString(message);
108 break;
109 }
110
111 std::string_view arg = strings[i++];
112
113 logger.WriteString(message.substr(0, placeholderPos));
114 logger.WriteString(arg);
115
116 message = message.substr(placeholderPos + 2);
117 }
118
119 logger.FinalizeMessge();
120}
std::string ToString(const T &arg)
Definition: Journal.cpp:81
constexpr size_t npos(-1)

References GetLogger(), Tuple::detail::npos(), and ToString().

Referenced by Journal::Begin(), NextIn(), and Journal::SyncException::SyncException().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextIn()

void Journal::anonymous_namespace{Journal.cpp}::NextIn ( )
inline

Definition at line 122 of file Journal.cpp.

123{
124 if ( !sFileIn.Eof() ) {
125 sLine = sFileIn.GetNextLine();
126 ++sLineNumber;
127
128 Log("Journal: line {} is '{}'", sLineNumber, sLine);
129 }
130}
void Log(std::string_view message, const Args &... args)
Definition: Journal.cpp:87

References Log(), sFileIn, sLine, and sLineNumber.

Referenced by Journal::Begin(), Journal::GetExitCode(), Journal::GetTokens(), PeekTokens(), and Journal::Sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PeekTokens()

wxArrayStringEx Journal::anonymous_namespace{Journal.cpp}::PeekTokens ( )

Definition at line 132 of file Journal.cpp.

133{
134 wxArrayStringEx tokens;
135 if ( Journal::IsReplaying() )
136 for ( ; !sFileIn.Eof(); NextIn() ) {
137 if ( sLine.StartsWith( CommentCharacter ) )
138 continue;
139
140 tokens = wxSplit( sLine, SeparatorCharacter, EscapeCharacter );
141 if ( tokens.empty() )
142 // Ignore blank lines
143 continue;
144
145 break;
146 }
147 return tokens;
148}
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
bool IsReplaying()
Definition: Journal.cpp:216
constexpr auto SeparatorCharacter
Definition: JournalOutput.h:22
constexpr auto CommentCharacter
Definition: JournalOutput.h:24

References Journal::CommentCharacter, Journal::EscapeCharacter, Journal::IsReplaying(), NextIn(), Journal::SeparatorCharacter, sFileIn, and sLine.

Referenced by Journal::Begin(), Journal::GetExitCode(), and Journal::GetTokens().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToString() [1/2]

template<typename T >
std::string Journal::anonymous_namespace{Journal.cpp}::ToString ( const T &  arg)

Definition at line 81 of file Journal.cpp.

82{
83 return std::to_string(arg);
84}

Referenced by Log().

Here is the caller graph for this function:

◆ ToString() [2/2]

std::string Journal::anonymous_namespace{Journal.cpp}::ToString ( const wxString &  str)

Definition at line 75 of file Journal.cpp.

76{
77 return str.ToStdString();
78}
#define str(a)

References str.

◆ VersionCheck()

bool Journal::anonymous_namespace{Journal.cpp}::VersionCheck ( const wxString &  value)

True if value is an acceptable journal version number to be rerun.

Definition at line 168 of file Journal.cpp.

169{
170 auto strings = wxSplit( value, '.' );
171 std::vector<int> numbers;
172 for ( auto &string : strings ) {
173 long value;
174 if ( !string.ToCLong( &value ) )
175 return false;
176 numbers.push_back( value );
177 }
178 // OK if the static version number is not less than the given value
179 // Maybe in the future there will be a compatibility break
180 return !std::lexicographical_compare(
182 numbers.begin(), numbers.end() );
183}
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101

References details::begin(), details::end(), and journalVersionNumbers.

Referenced by Journal::Begin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VersionString()

wxString Journal::anonymous_namespace{Journal.cpp}::VersionString ( )

Definition at line 157 of file Journal.cpp.

158{
159 wxString result;
160 for ( auto number : journalVersionNumbers ) {
161 auto str = wxString::Format( "%d", number );
162 result += ( result.empty() ? str : ( '.' + str ) );
163 }
164 return result;
165}

References journalVersionNumbers, and str.

Referenced by Journal::Begin().

Here is the caller graph for this function:

Variable Documentation

◆ JournalEnabled

BoolSetting Journal::anonymous_namespace{Journal.cpp}::JournalEnabled { L"/Journal/Enabled", false }

Definition at line 44 of file Journal.cpp.

Referenced by Journal::RecordEnabled(), and Journal::SetRecordEnabled().

◆ journalVersionNumbers

int Journal::anonymous_namespace{Journal.cpp}::journalVersionNumbers[]
Initial value:
= {
1
}

Definition at line 153 of file Journal.cpp.

Referenced by VersionCheck(), and VersionString().

◆ sFileIn

wxTextFile Journal::anonymous_namespace{Journal.cpp}::sFileIn

Definition at line 37 of file Journal.cpp.

Referenced by Journal::Begin(), Journal::IsReplaying(), NextIn(), PeekTokens(), and Journal::Sync().

◆ sFileNameIn

wxString Journal::anonymous_namespace{Journal.cpp}::sFileNameIn

Definition at line 36 of file Journal.cpp.

Referenced by Journal::Begin(), and Journal::SetInputFileName().

◆ sLine

wxString Journal::anonymous_namespace{Journal.cpp}::sLine

Definition at line 39 of file Journal.cpp.

Referenced by Journal::Begin(), NextIn(), PeekTokens(), and Journal::Sync().

◆ sLineNumber

int Journal::anonymous_namespace{Journal.cpp}::sLineNumber = -1

Definition at line 42 of file Journal.cpp.

Referenced by Journal::Begin(), Journal::GetExitCode(), and NextIn().

◆ VersionToken

constexpr auto Journal::anonymous_namespace{Journal.cpp}::VersionToken = wxT("Version")
constexpr

Definition at line 150 of file Journal.cpp.

Referenced by Journal::Begin().