5 #include "../exceptions.h" 7 #include <c++utilities/io/binarywriter.h> 8 #include <c++utilities/misc/memory.h> 24 MatroskaTagField::MatroskaTagField()
30 MatroskaTagField::MatroskaTagField(
const string &
id,
const TagValue &value) :
46 string context(
"parsing Matroska tag field");
48 simpleTagElement.
parse();
50 bool tagDefaultFound =
false;
62 context =
"parsing Matroska tag field " +
id();
69 if(
value().isEmpty()) {
70 unique_ptr<char[]> buffer = make_unique<char []>(child->
dataSize());
96 if(!tagDefaultFound) {
98 tagDefaultFound =
true;
104 if(parseNestedFields) {
133 static const string context(
"making Matroska \"SimpleTag\" element.");
141 }
catch(
const ConversionException &) {
174 m_stringValue = m_field.value().toString();
175 }
catch(
const ConversionException &) {
176 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.");
179 size_t languageSize = m_field.value().language().size();
194 m_nestedMaker.emplace_back(nestedField.prepareMaking());
195 m_simpleTagSize += m_nestedMaker.back().m_totalSize;
209 BinaryWriter writer(&stream);
214 stream.write(buff, sizeDenotationLen);
218 stream.write(buff, sizeDenotationLen);
219 stream.write(m_field.id().c_str(), m_field.id().size());
222 if(m_field.value().language().empty()) {
223 stream.put(static_cast<ostream::char_type>(0x80 | 3));
224 stream.write(
"und", 3);
227 stream.write(buff, sizeDenotationLen);
228 stream.write(m_field.value().language().c_str(), m_field.value().language().size());
232 stream.put(static_cast<ostream::char_type>(0x80 | 1));
233 stream.put(m_field.isDefault() ? 1 : 0);
238 stream.write(buff, sizeDenotationLen);
239 stream.write(m_field.value().dataPointer(), m_field.value().dataSize());
243 stream.write(buff, sizeDenotationLen);
244 stream.write(m_stringValue.data(), m_stringValue.size());
247 for(
const auto &maker : m_nestedMaker) {
Contains utility classes helping to read and write streams.