5 #include "../exceptions.h" 7 #include <c++utilities/io/binarywriter.h> 25 MatroskaTagField::MatroskaTagField()
31 MatroskaTagField::MatroskaTagField(
const string &
id,
const TagValue &value) :
47 string context(
"parsing Matroska tag field");
49 simpleTagElement.
parse();
50 bool tagDefaultFound =
false;
61 setId(child->readString());
62 context =
"parsing Matroska tag field " +
id();
69 if(
value().isEmpty()) {
70 unique_ptr<char[]> buffer = make_unique<char []>(child->dataSize());
71 child->stream().seekg(child->dataOffset());
72 child->stream().read(buffer.get(), child->dataSize());
87 string lng = child->readString();
96 if(!tagDefaultFound) {
98 tagDefaultFound =
true;
104 if(parseNestedFields) {
132 static const string context(
"making Matroska \"SimpleTag\" element.");
140 }
catch(
const ConversionException &) {
173 m_stringValue = m_field.value().toString();
174 }
catch(
const ConversionException &) {
175 m_field.addNotification(
NotificationType::Warning,
"The assigned tag value can not be converted to a string and is treated as binary value (which is likely not what you want since official Matroska specifiecation doesn't list any binary fields).",
"making Matroska \"SimpleTag\" element.");
178 size_t languageSize = m_field.value().language().size();
193 m_nestedMaker.emplace_back(nestedField.prepareMaking());
194 m_simpleTagSize += m_nestedMaker.back().m_totalSize;
208 BinaryWriter writer(&stream);
213 stream.write(buff, sizeDenotationLen);
217 stream.write(buff, sizeDenotationLen);
218 stream.write(m_field.
id().c_str(), m_field.
id().size());
222 stream.put(static_cast<ostream::char_type>(0x80 | 3));
223 stream.write(
"und", 3);
226 stream.write(buff, sizeDenotationLen);
231 stream.put(static_cast<ostream::char_type>(0x80 | 1));
237 stream.write(buff, sizeDenotationLen);
242 stream.write(buff, sizeDenotationLen);
243 stream.write(m_stringValue.data(), m_stringValue.size());
246 for(
const auto &maker : m_nestedMaker) {
Contains utility classes helping to read and write streams.