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();
51 bool tagDefaultFound =
false;
63 context =
"parsing Matroska tag field " +
id();
70 if(
value().isEmpty()) {
71 unique_ptr<char[]> buffer = make_unique<char []>(child->
dataSize());
97 if(!tagDefaultFound) {
99 tagDefaultFound =
true;
105 if(parseNestedFields) {
134 static const string context(
"making Matroska \"SimpleTag\" element.");
142 }
catch(
const ConversionException &) {
175 m_stringValue = m_field.value().toString();
176 }
catch(
const ConversionException &) {
177 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.");
180 size_t languageSize = m_field.value().language().size();
195 m_nestedMaker.emplace_back(nestedField.prepareMaking());
196 m_simpleTagSize += m_nestedMaker.back().m_totalSize;
210 BinaryWriter writer(&stream);
215 stream.write(buff, sizeDenotationLen);
219 stream.write(buff, sizeDenotationLen);
220 stream.write(m_field.id().c_str(), m_field.id().size());
223 if(m_field.value().language().empty()) {
224 stream.put(static_cast<ostream::char_type>(0x80 | 3));
225 stream.write(
"und", 3);
228 stream.write(buff, sizeDenotationLen);
229 stream.write(m_field.value().language().c_str(), m_field.value().language().size());
233 stream.put(static_cast<ostream::char_type>(0x80 | 1));
234 stream.put(m_field.isDefault() ? 1 : 0);
239 stream.write(buff, sizeDenotationLen);
240 stream.write(m_field.value().dataPointer(), m_field.value().dataSize());
244 stream.write(buff, sizeDenotationLen);
245 stream.write(m_stringValue.data(), m_stringValue.size());
248 for(
const auto &maker : m_nestedMaker) {
Contains utility classes helping to read and write streams.