Tag Parser  10.0.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
helper.h
Go to the documentation of this file.
1 #ifndef TAGPARSER_TEST_HELPER
2 #define TAGPARSER_TEST_HELPER
3 
4 #include "../diagnostics.h"
5 #include "../localehelper.h"
6 #include "../size.h"
7 #include "../tagvalue.h"
8 
9 #include <ostream>
10 
11 namespace CppUtilities {
12 
13 std::ostream &operator<<(std::ostream &os, const TagParser::TagTextEncoding &encoding);
14 
18 inline std::ostream &operator<<(std::ostream &os, const TagParser::TagValue &tagValue)
19 {
21  if (!tagValue.description().empty()) {
22  os << ", description: " << tagValue.description();
23  }
24  return os << " (encoding: " << tagValue.dataEncoding() << ", description encoding: " << tagValue.descriptionEncoding() << ')';
25 }
26 
30 inline std::ostream &operator<<(std::ostream &os, const TagParser::PositionInSet &pos)
31 {
32  return os << pos.toString();
33 }
34 
38 inline std::ostream &operator<<(std::ostream &os, const TagParser::Size &size)
39 {
40  return os << size.toString();
41 }
42 
46 inline std::ostream &operator<<(std::ostream &os, const TagParser::DiagMessage &diagMessage)
47 {
48  return os << diagMessage.levelName() << ':' << ' ' << diagMessage.message() << ' ' << '(' << diagMessage.context() << ')';
49 }
50 
54 inline std::ostream &operator<<(std::ostream &os, const TagParser::Locale &locale)
55 {
56  return os << locale.toString();
57 }
58 
59 } // namespace CppUtilities
60 
61 #endif // TAGPARSER_TEST_HELPER
The DiagMessage class holds an information, warning or error gathered during parsing or making.
Definition: diagnostics.h:41
std::string_view levelName() const
Returns the string representation of the level().
Definition: diagnostics.h:119
const std::string & context() const
Returns the context.
Definition: diagnostics.h:135
const std::string & message() const
Returns the message.
Definition: diagnostics.h:127
The PositionInSet class describes the position of an element in a set which consists of a certain num...
Definition: positioninset.h:21
StringType toString() const
Returns the string representation of the current PositionInSet.
The Size class defines the size of a two-dimensional object using integer point precision.
Definition: size.h:17
std::string toString() const
Returns the string representation of the current size.
Definition: size.h:125
The TagValue class wraps values of different types.
Definition: tagvalue.h:95
TagTextEncoding dataEncoding() const
Returns the data encoding.
Definition: tagvalue.h:755
TagTextEncoding descriptionEncoding() const
Returns the description encoding.
Definition: tagvalue.h:765
std::string toString(TagTextEncoding encoding=TagTextEncoding::Unspecified) const
Converts the value of the current TagValue object to its equivalent std::string representation.
Definition: tagvalue.h:485
const std::string & description() const
Returns the description.
Definition: tagvalue.h:598
std::ostream & operator<<(std::ostream &os, const TagParser::TagTextEncoding &encoding)
Prints a TagTextEncoding to enable CPPUNIT_ASSERT_EQUAL for tag values.
Definition: helper.cpp:8
TagTextEncoding
Specifies the text encoding.
Definition: tagvalue.h:28
The Locale struct specifies a language and/or a country using one or more LocaleDetail objects.
Definition: localehelper.h:61
std::string toString() const
Returns all details as comma-separated string.