Tag Parser
9.1.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
diagnostics.cpp
Go to the documentation of this file.
1
#include "
./diagnostics.h
"
2
3
using namespace
std;
4
5
namespace
TagParser
{
6
22
const
char
*
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::None
:
32
default
:
33
return
""
;
34
}
35
}
36
40
bool
Diagnostics::has(
DiagLevel
level)
const
41
{
42
for
(
const
auto
&msg : *
this
) {
43
if
(msg.level() >= level) {
44
return
true
;
45
}
46
}
47
return
false
;
48
}
49
53
DiagLevel
Diagnostics::level()
const
54
{
55
auto
level =
DiagLevel::None
;
56
for
(
const
auto
&msg : *
this
) {
57
if
((level |= msg.level()) >=
worstDiagLevel
) {
58
return
level;
59
}
60
}
61
return
level;
62
}
63
67
string
DiagMessage::formatList(
const
std::vector<string> &values)
68
{
69
auto
size = values.size() * 4;
70
for
(
const
auto
&str : values) {
71
size += str.size();
72
}
73
std::string res;
74
res.reserve(size);
75
for
(
auto
value = values.cbegin(), end = values.cend(), last = values.cend() - 1; value != end; ++value) {
76
if
(value == last) {
77
res +=
" and "
;
78
}
else
if
(!res.empty()) {
79
res +=
", "
;
80
}
81
res +=
'\"'
;
82
res += *value;
83
res +=
'\"'
;
84
}
85
return
res;
86
}
87
88
}
// namespace TagParser
TagParser::diagLevelName
const TAG_PARSER_EXPORT char * diagLevelName(DiagLevel diagLevel)
Returns the string representation of the specified diagLevel.
Definition:
diagnostics.cpp:22
TagParser::SubFormats::None
Definition:
mediaformat.h:110
TagParser::DiagLevel
DiagLevel
Specifies the level of the diagnostic message.
Definition:
diagnostics.h:16
TagParser
Contains all classes and functions of the TagInfo library.
Definition:
aaccodebook.h:10
TagParser::worstDiagLevel
constexpr auto worstDiagLevel
The worst diag level.
Definition:
diagnostics.h:26
diagnostics.h
Generated on Wed Oct 2 2019 16:52:26 for Tag Parser by
1.8.16