Tag Parser  9.0.0
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 "../size.h"
6 #include "../tagvalue.h"
7 
8 #include <ostream>
9 
10 namespace CppUtilities {
11 
12 std::ostream &operator<<(std::ostream &os, const TagParser::TagTextEncoding &encoding);
13 
17 inline std::ostream &operator<<(std::ostream &os, const TagParser::TagValue &tagValue)
18 {
20  if (!tagValue.description().empty()) {
21  os << ", description: " << tagValue.description();
22  }
23  return os << " (encoding: " << tagValue.dataEncoding() << ", description encoding: " << tagValue.descriptionEncoding() << ')';
24 }
25 
29 inline std::ostream &operator<<(std::ostream &os, const TagParser::PositionInSet &pos)
30 {
31  return os << pos.toString();
32 }
33 
37 inline std::ostream &operator<<(std::ostream &os, const TagParser::Size &size)
38 {
39  return os << size.toString();
40 }
41 
45 inline std::ostream &operator<<(std::ostream &os, const TagParser::DiagMessage &diagMessage)
46 {
47  return os << diagMessage.levelName() << ':' << ' ' << diagMessage.message() << ' ' << '(' << diagMessage.context() << ')';
48 }
49 
50 } // namespace CppUtilities
51 
52 #endif // TAGPARSER_TEST_HELPER
TagParser::TagTextEncoding::Utf8
TagParser::TagTextEncoding
TagTextEncoding
Specifies the text encoding.
Definition: tagvalue.h:25
TagParser::DiagMessage::context
const std::string & context() const
Returns the context.
Definition: diagnostics.h:135
TagParser::TagValue::descriptionEncoding
TagTextEncoding descriptionEncoding() const
Returns the description encoding.
Definition: tagvalue.h:613
TagParser::DiagMessage::levelName
const char * levelName() const
Returns the string representation of the level().
Definition: diagnostics.h:119
TagParser::TagValue::description
const std::string & description() const
Returns the description.
Definition: tagvalue.h:511
CppUtilities::operator<<
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
CppUtilities
Definition: abstractcontainer.h:15
TagParser::Size
The Size class defines the size of a two-dimensional object using integer point precision.
Definition: size.h:16
TagParser::DiagMessage
The DiagMessage class holds an information, warning or error gathered during parsing or making.
Definition: diagnostics.h:41
TagParser::TagValue
The TagValue class wraps values of different types. It is meant to be assigned to a tag field.
Definition: tagvalue.h:75
TagParser::TagValue::toString
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:407
TagParser::PositionInSet
The PositionInSet class describes the position of an element in a set which consists of a certain num...
Definition: positioninset.h:21
TagParser::DiagMessage::message
const std::string & message() const
Returns the message.
Definition: diagnostics.h:127
TagParser::TagValue::dataEncoding
TagTextEncoding dataEncoding() const
Returns the data encoding.
Definition: tagvalue.h:603
TagParser::Size::toString
std::string toString() const
Returns the string representation of the current size.
Definition: size.h:124
TagParser::PositionInSet::toString
StringType toString() const
Returns the string representation of the current PositionInSet.
Definition: positioninset.h:111