Tag Parser
12.5.3
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Toggle main menu visibility
Loading...
Searching...
No Matches
diagnostics.cpp
Go to the documentation of this file.
1
#include "
./diagnostics.h
"
2
3
using namespace
std;
4
5
namespace
TagParser
{
6
11
18
22
std::string_view
diagLevelName
(
DiagLevel
diagLevel)
23
{
24
switch
(diagLevel) {
25
case
DiagLevel::Information
:
26
return
"information"
;
27
case
DiagLevel::Warning
:
28
return
"warning"
;
29
case
DiagLevel::Critical
:
30
return
"critical"
;
31
case
DiagLevel::Debug
:
32
return
"debug"
;
33
case
DiagLevel::None
:
34
default
:
35
return
std::string_view();
36
}
37
}
38
42
bool
Diagnostics::has
(
DiagLevel
level
)
const
43
{
44
for
(
const
auto
&msg : *
this
) {
45
if
(msg.level() >=
level
) {
46
return
true
;
47
}
48
}
49
return
false
;
50
}
51
55
DiagLevel
Diagnostics::level
()
const
56
{
57
auto
level
=
DiagLevel::None
;
58
for
(
const
auto
&msg : *
this
) {
59
if
((
level
|= msg.level()) >=
worstDiagLevel
) {
60
return
level
;
61
}
62
}
63
return
level
;
64
}
65
69
string
DiagMessage::formatList
(
const
std::vector<string> &values)
70
{
71
auto
size = values.size() * 4;
72
for
(
const
auto
&str : values) {
73
size += str.size();
74
}
75
std::string res;
76
res.reserve(size);
77
for
(
auto
value = values.cbegin(), end = values.cend(), last = values.cend() - 1; value != end; ++value) {
78
if
(value == last) {
79
res +=
" and "
;
80
}
else
if
(!res.empty()) {
81
res +=
", "
;
82
}
83
res +=
'\"'
;
84
res += *value;
85
res +=
'\"'
;
86
}
87
return
res;
88
}
89
90
}
// namespace TagParser
TagParser::DiagMessage::formatList
static std::string formatList(const std::vector< std::string > &values)
Concatenates the specified string values to a list.
Definition
diagnostics.cpp:69
TagParser::Diagnostics::has
bool has(DiagLevel level) const
Returns whether there's at least one DiagMessage which is at least as worse as level.
Definition
diagnostics.cpp:42
TagParser::Diagnostics::level
DiagLevel level() const
Returns the worst diag level present in the container.
Definition
diagnostics.cpp:55
diagnostics.h
TagParser
Contains all classes and functions of the TagInfo library.
Definition
aaccodebook.h:10
TagParser::diagLevelName
TAG_PARSER_EXPORT std::string_view diagLevelName(DiagLevel diagLevel)
Returns the string representation of the specified diagLevel.
Definition
diagnostics.cpp:22
TagParser::DiagLevel
DiagLevel
Specifies the level of the diagnostic message.
Definition
diagnostics.h:16
TagParser::DiagLevel::Warning
@ Warning
Definition
diagnostics.h:20
TagParser::DiagLevel::Critical
@ Critical
Definition
diagnostics.h:21
TagParser::DiagLevel::None
@ None
Definition
diagnostics.h:17
TagParser::DiagLevel::Debug
@ Debug
Definition
diagnostics.h:18
TagParser::DiagLevel::Information
@ Information
Definition
diagnostics.h:19
TagParser::worstDiagLevel
constexpr auto worstDiagLevel
The worst diag level.
Definition
diagnostics.h:26
Generated on
for Tag Parser by
1.18.0