From 541f14039b7ca0adabba853ee2a6ff1d91bcee62 Mon Sep 17 00:00:00 2001 From: Martchus Date: Fri, 27 Jan 2017 18:59:22 +0100 Subject: [PATCH] Make use of string builder --- CMakeLists.txt | 2 +- backuphelper.cpp | 7 ++--- id3/id3v2frame.cpp | 9 ++++--- id3/id3v2tag.cpp | 3 ++- matroska/ebmlelement.cpp | 5 ++-- matroska/matroskaattachment.cpp | 3 ++- matroska/matroskachapter.cpp | 6 +++-- matroska/matroskacontainer.cpp | 45 ++++++++++++++++--------------- matroska/matroskaeditionentry.cpp | 4 ++- matroska/matroskaseekinfo.cpp | 5 ++-- mp4/mp4atom.cpp | 5 ++-- mp4/mp4container.cpp | 9 ++++--- mp4/mp4tagfield.cpp | 7 ++--- mp4/mp4track.cpp | 6 +++-- mp4/mpeg4descriptor.cpp | 7 ++--- ogg/oggcontainer.cpp | 8 +++--- statusprovider.cpp | 5 +++- 17 files changed, 79 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7aafd6..9473309 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,7 +166,7 @@ set(META_PUBLIC_STATIC_LIB_DEPENDS c++utilities_static) set(META_PRIVATE_COMPILE_DEFINITIONS LEGACY_API) # find c++utilities -find_package(c++utilities 4.4.0 REQUIRED) +find_package(c++utilities 4.5.0 REQUIRED) use_cpp_utilities() # find 3rd party libraries diff --git a/backuphelper.cpp b/backuphelper.cpp index 86e0271..38e9dc4 100644 --- a/backuphelper.cpp +++ b/backuphelper.cpp @@ -2,6 +2,7 @@ #include "./mediafileinfo.h" #include +#include #include #ifdef PLATFORM_WINDOWS @@ -90,7 +91,7 @@ void restoreOriginalFileFromBackupFile(const std::string &originalPath, const st // TODO: callback for progress updates } catch(...) { catchIoFailure(); - throwIoFailure(("Unable to restore original file from backup file \"" + backupPath + "\" after failure.").data()); + throwIoFailure(("Unable to restore original file from backup file \"" % backupPath + "\" after failure.").data()); } } } @@ -127,7 +128,7 @@ void createBackupFile(const std::string &originalPath, std::string &backupPath, for(unsigned int i = 0; ; ++i) { if(backupDir.empty()) { if(i) { - backupPath = originalPath + '.' + numberToString(i) + ".bak"; + backupPath = originalPath % '.' % numberToString(i) + ".bak"; } else { backupPath = originalPath + ".bak"; } @@ -226,7 +227,7 @@ void createBackupFile(const std::string &originalPath, std::string &backupPath, // can't open the new file // -> try to re-rename backup file in the error case to restore previous state if(std::rename(backupPath.c_str(), originalPath.c_str()) != 0) { - throwIoFailure(("Unable to restore original file from backup file \"" + backupPath + "\" after failure.").data()); + throwIoFailure(("Unable to restore original file from backup file \"" % backupPath + "\" after failure.").data()); } else { throwIoFailure("Unable to open backup file."); } diff --git a/id3/id3v2frame.cpp b/id3/id3v2frame.cpp index 57577a0..eb4355c 100644 --- a/id3/id3v2frame.cpp +++ b/id3/id3v2frame.cpp @@ -5,6 +5,7 @@ #include "../exceptions.h" #include +#include #include #include @@ -126,13 +127,13 @@ void Id3v2Frame::parse(BinaryReader &reader, const uint32 version, const uint32 } // -> update context - context = "parsing " + frameIdString() + " frame"; + context = "parsing " % frameIdString() + " frame"; // -> read size, check whether frame is truncated m_dataSize = reader.readUInt24BE(); m_totalSize = m_dataSize + 6; if(m_totalSize > maximalSize) { - addNotification(NotificationType::Warning, "The frame is truncated and will be ignored.", "parsing " + frameIdString() + " frame"); + addNotification(NotificationType::Warning, "The frame is truncated and will be ignored.", context); throw TruncatedDataException(); } @@ -154,7 +155,7 @@ void Id3v2Frame::parse(BinaryReader &reader, const uint32 version, const uint32 } // -> update context - context = "parsing " + frameIdString() + " frame"; + context = "parsing " % frameIdString() + " frame"; // -> read size, check whether frame is truncated m_dataSize = version >= 4 @@ -357,7 +358,7 @@ Id3v2FrameMaker::Id3v2FrameMaker(Id3v2Frame &frame, const byte version) : m_version(version) { m_frame.invalidateStatus(); - const string context("making " + m_frame.frameIdString() + " frame"); + const string context("making " % m_frame.frameIdString() + " frame"); // validate assigned data if(m_frame.value().isEmpty()) { diff --git a/id3/id3v2tag.cpp b/id3/id3v2tag.cpp index 4e4557f..eb2b2ac 100644 --- a/id3/id3v2tag.cpp +++ b/id3/id3v2tag.cpp @@ -4,6 +4,7 @@ #include "../exceptions.h" #include +#include using namespace std; using namespace IoUtilities; @@ -228,7 +229,7 @@ void Id3v2Tag::parse(istream &stream, const uint64 maximalSize) if(frame.id()) { // add frame if parsing was successfull if(Id3v2FrameIds::isTextFrame(frame.id()) && fields().count(frame.id()) == 1) { - addNotification(NotificationType::Warning, "The text frame " + frame.frameIdString() + " exists more than once.", context); + addNotification(NotificationType::Warning, "The text frame " % frame.frameIdString() + " exists more than once.", context); } fields().insert(make_pair(frame.id(), frame)); } diff --git a/matroska/ebmlelement.cpp b/matroska/ebmlelement.cpp index c745a28..abdc235 100644 --- a/matroska/ebmlelement.cpp +++ b/matroska/ebmlelement.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -54,7 +55,7 @@ EbmlElement::EbmlElement(EbmlElement &parent, uint64 startOffset) : */ string EbmlElement::parsingContext() const { - return "parsing header of EBML element " + idToString() + " at " + numberToString(startOffset()); + return "parsing header of EBML element " % idToString() % " at " + numberToString(startOffset()); } /*! @@ -69,7 +70,7 @@ void EbmlElement::internalParse() for(skipped = 0; /* TODO: add a sane limit here */; ++m_startOffset, --m_maxSize, ++skipped) { // check whether max size is valid if(maxTotalSize() < 2) { - addNotification(NotificationType::Critical, "The EBML element at " + numberToString(startOffset()) + " is truncated or does not exist.", context); + addNotification(NotificationType::Critical, "The EBML element at " % numberToString(startOffset()) + " is truncated or does not exist.", context); throw TruncatedDataException(); } stream().seekg(startOffset()); diff --git a/matroska/matroskaattachment.cpp b/matroska/matroskaattachment.cpp index 5cdb68c..f438bf8 100644 --- a/matroska/matroskaattachment.cpp +++ b/matroska/matroskaattachment.cpp @@ -4,6 +4,7 @@ #include "./matroskaid.h" #include +#include #include using namespace std; @@ -75,7 +76,7 @@ void MatroskaAttachment::parse(EbmlElement *attachedFileElement) case EbmlIds::Void: break; default: - addNotification(NotificationType::Warning, "Unknown child element \"" + subElement->idToString() + "\" found.", context); + addNotification(NotificationType::Warning, "Unknown child element \"" % subElement->idToString() + "\" found.", context); } subElement = subElement->nextSibling(); } diff --git a/matroska/matroskachapter.cpp b/matroska/matroskachapter.cpp index 958d7d2..5eb51c5 100644 --- a/matroska/matroskachapter.cpp +++ b/matroska/matroskachapter.cpp @@ -2,10 +2,12 @@ #include "./ebmlelement.h" #include "./matroskaid.h" +#include #include using namespace std; using namespace ChronoUtilities; +using namespace ConversionUtilities; namespace Media { @@ -74,7 +76,7 @@ void MatroskaChapter::internalParse() m_tracks.emplace_back(chapterTrackElement->readUInteger()); break; default: - addNotification(NotificationType::Warning, "\"ChapterTrack\"-element contains unknown child element \"" + chapterAtomChild->idToString() + "\". It will be ignored.", context); + addNotification(NotificationType::Warning, "\"ChapterTrack\"-element contains unknown child element \"" % chapterAtomChild->idToString() + "\". It will be ignored.", context); } } break; @@ -104,7 +106,7 @@ void MatroskaChapter::internalParse() case MatroskaIds::ChapterAtom: m_nestedChapters.emplace_back(make_unique(chapterAtomChild)); default: - addNotification(NotificationType::Warning, "\"ChapterAtom\"-element contains unknown child element \"" + chapterAtomChild->idToString() + "\". It will be ignored.", context); + addNotification(NotificationType::Warning, "\"ChapterAtom\"-element contains unknown child element \"" % chapterAtomChild->idToString() + "\". It will be ignored.", context); } } // "eng" is default language diff --git a/matroska/matroskacontainer.cpp b/matroska/matroskacontainer.cpp index 9352c96..b8f1c86 100644 --- a/matroska/matroskacontainer.cpp +++ b/matroska/matroskacontainer.cpp @@ -12,6 +12,7 @@ #include "resources/config.h" #include +#include #include #include @@ -141,7 +142,7 @@ void MatroskaContainer::validateIndex() case MatroskaIds::CueCodecState: // validate uniqueness if(ids.count(subElement->id())) { - addNotification(NotificationType::Warning, "\"CueTrackPositions\"-element contains multiple \"" + subElement->idToString() + "\" elements.", context); + addNotification(NotificationType::Warning, "\"CueTrackPositions\"-element contains multiple \"" % subElement->idToString() + "\" elements.", context); } else { ids.insert(subElement->id()); } @@ -151,7 +152,7 @@ void MatroskaContainer::validateIndex() case MatroskaIds::CueReference: break; default: - addNotification(NotificationType::Warning, "\"CueTrackPositions\"-element contains unknown element \"" + subElement->idToString() + "\".", context); + addNotification(NotificationType::Warning, "\"CueTrackPositions\"-element contains unknown element \"" % subElement->idToString() + "\".", context); } switch(subElement->id()) { case EbmlIds::Void: @@ -164,7 +165,7 @@ void MatroskaContainer::validateIndex() try { clusterElement->parse(); if(clusterElement->id() != MatroskaIds::Cluster) { - addNotification(NotificationType::Critical, "\"CueClusterPosition\" element at " + numberToString(subElement->startOffset()) + " does not point to \"Cluster\"-element (points to " + numberToString(clusterElement->startOffset()) + ").", context); + addNotification(NotificationType::Critical, "\"CueClusterPosition\" element at " % numberToString(subElement->startOffset()) + " does not point to \"Cluster\"-element (points to " + numberToString(clusterElement->startOffset()) + ").", context); } } catch(const Failure &) { addNotifications(context, *clusterElement); @@ -204,7 +205,7 @@ void MatroskaContainer::validateIndex() case MatroskaIds::BlockGroup: break; default: - addNotification(NotificationType::Critical, "\"CueRelativePosition\" element does not point to \"Block\"-, \"BlockGroup\", or \"SimpleBlock\"-element (points to " + numberToString(referenceElement.startOffset()) + ").", context); + addNotification(NotificationType::Critical, "\"CueRelativePosition\" element does not point to \"Block\"-, \"BlockGroup\", or \"SimpleBlock\"-element (points to " % numberToString(referenceElement.startOffset()) + ").", context); } } catch(const Failure &) { addNotifications(context, referenceElement); @@ -216,7 +217,7 @@ void MatroskaContainer::validateIndex() case EbmlIds::Void: break; default: - addNotification(NotificationType::Warning, "\"CuePoint\"-element contains unknown element \"" + cuePointElement->idToString() + "\".", context); + addNotification(NotificationType::Warning, "\"CuePoint\"-element contains unknown element \"" % cuePointElement->idToString() + "\".", context); } } // validate existence of mandatory elements @@ -243,13 +244,13 @@ void MatroskaContainer::validateIndex() case MatroskaIds::Position: // validate position if((pos = clusterElementChild->readUInteger()) > 0 && (segmentChildElement->startOffset() - segmentElement->dataOffset() + currentOffset) != pos) { - addNotification(NotificationType::Critical, "\"Position\"-element at " + numberToString(clusterElementChild->startOffset()) + " points to " + numberToString(pos) + " which is not the offset of the containing \"Cluster\"-element.", context); + addNotification(NotificationType::Critical, "\"Position\"-element at " % numberToString(clusterElementChild->startOffset()) % " points to " % numberToString(pos) + " which is not the offset of the containing \"Cluster\"-element.", context); } break; case MatroskaIds::PrevSize: // validate prev size if(clusterElementChild->readUInteger() != prevClusterSize) { - addNotification(NotificationType::Critical, "\"PrevSize\"-element at " + numberToString(clusterElementChild->startOffset()) + " has invalid value.", context); + addNotification(NotificationType::Critical, "\"PrevSize\"-element at " % numberToString(clusterElementChild->startOffset()) + " has invalid value.", context); } break; default: @@ -411,7 +412,7 @@ void MatroskaContainer::internalParseHeader() m_maxIdLength = subElement->readUInteger(); if(m_maxIdLength > EbmlElement::maximumIdLengthSupported()) { addNotification(NotificationType::Critical, "Maximum EBML element ID length greather then " - + numberToString(EbmlElement::maximumIdLengthSupported()) + % numberToString(EbmlElement::maximumIdLengthSupported()) + " bytes is not supported.", context); throw InvalidDataException(); } @@ -420,7 +421,7 @@ void MatroskaContainer::internalParseHeader() m_maxSizeLength = subElement->readUInteger(); if(m_maxSizeLength > EbmlElement::maximumSizeLengthSupported()) { addNotification(NotificationType::Critical, "Maximum EBML element size length greather then " - + numberToString(EbmlElement::maximumSizeLengthSupported()) + % numberToString(EbmlElement::maximumSizeLengthSupported()) + " bytes is not supported.", context); throw InvalidDataException(); } @@ -477,13 +478,13 @@ void MatroskaContainer::internalParseHeader() for(const auto &infoPair : (*i)->info()) { uint64 offset = currentOffset + topLevelElement->dataOffset() + infoPair.second; if(offset >= fileInfo().size()) { - addNotification(NotificationType::Critical, "Offset (" + numberToString(offset) + ") denoted by \"SeekHead\" element is invalid.", context); + addNotification(NotificationType::Critical, "Offset (" % numberToString(offset) + ") denoted by \"SeekHead\" element is invalid.", context); } else { auto element = make_unique(*this, offset); try { element->parse(); if(element->id() != infoPair.first) { - addNotification(NotificationType::Critical, "ID of element " + element->idToString() + " at " + numberToString(offset) + " does not match the ID denoted in the \"SeekHead\" element (0x" + numberToString(infoPair.first, 16) + ").", context); + addNotification(NotificationType::Critical, "ID of element " % element->idToString() % " at " % numberToString(offset) % " does not match the ID denoted in the \"SeekHead\" element (0x" % numberToString(infoPair.first, 16) + ").", context); } switch(element->id()) { case MatroskaIds::SegmentInfo: @@ -520,7 +521,7 @@ void MatroskaContainer::internalParseHeader() ; } } catch(const Failure &) { - addNotification(NotificationType::Critical, "Can not parse element at " + numberToString(offset) + " (denoted using \"SeekHead\" element).", context); + addNotification(NotificationType::Critical, "Can not parse element at " % numberToString(offset) + " (denoted using \"SeekHead\" element).", context); } } } @@ -548,7 +549,7 @@ void MatroskaContainer::internalParseHeader() addNotifications(*topLevelElement); } catch(const Failure &) { addNotifications(*topLevelElement); - addNotification(NotificationType::Critical, "Unable to parse top-level element at " + numberToString(topLevelElement->startOffset()) + ".", context); + addNotification(NotificationType::Critical, "Unable to parse top-level element at " % numberToString(topLevelElement->startOffset()) + ".", context); break; } } @@ -625,7 +626,7 @@ void MatroskaContainer::internalParseTags() } catch(NoDataFoundException &) { m_tags.pop_back(); } catch(const Failure &) { - addNotification(NotificationType::Critical, "Unable to parse tag " + ConversionUtilities::numberToString(m_tags.size()) + ".", context); + addNotification(NotificationType::Critical, "Unable to parse tag " % ConversionUtilities::numberToString(m_tags.size()) + ".", context); } break; case EbmlIds::Crc32: @@ -659,14 +660,14 @@ void MatroskaContainer::internalParseTracks() } catch(const NoDataFoundException &) { m_tracks.pop_back(); } catch(const Failure &) { - addNotification(NotificationType::Critical, "Unable to parse track " + ConversionUtilities::numberToString(m_tracks.size()) + ".", context); + addNotification(NotificationType::Critical, "Unable to parse track " % ConversionUtilities::numberToString(m_tracks.size()) + ".", context); } break; case EbmlIds::Crc32: case EbmlIds::Void: break; default: - addNotification(NotificationType::Warning, "\"Tracks\"-element contains unknown child element \"" + subElement->idToString() + "\". It will be ignored.", context); + addNotification(NotificationType::Warning, "\"Tracks\"-element contains unknown child element \"" % subElement->idToString() + "\". It will be ignored.", context); } } } catch(const Failure &) { @@ -693,14 +694,14 @@ void MatroskaContainer::internalParseChapters() } catch(const NoDataFoundException &) { m_editionEntries.pop_back(); } catch(const Failure &) { - addNotification(NotificationType::Critical, "Unable to parse edition entry " + ConversionUtilities::numberToString(m_editionEntries.size()) + ".", context); + addNotification(NotificationType::Critical, "Unable to parse edition entry " % ConversionUtilities::numberToString(m_editionEntries.size()) + ".", context); } break; case EbmlIds::Crc32: case EbmlIds::Void: break; default: - addNotification(NotificationType::Warning, "\"Chapters\"-element contains unknown child element \"" + subElement->idToString() + "\". It will be ignored.", context); + addNotification(NotificationType::Warning, "\"Chapters\"-element contains unknown child element \"" % subElement->idToString() + "\". It will be ignored.", context); } } } catch(const Failure &) { @@ -727,14 +728,14 @@ void MatroskaContainer::internalParseAttachments() } catch(const NoDataFoundException &) { m_attachments.pop_back(); } catch(const Failure &) { - addNotification(NotificationType::Critical, "Unable to parse attached file " + ConversionUtilities::numberToString(m_attachments.size()) + ".", context); + addNotification(NotificationType::Critical, "Unable to parse attached file " % ConversionUtilities::numberToString(m_attachments.size()) + ".", context); } break; case EbmlIds::Crc32: case EbmlIds::Void: break; default: - addNotification(NotificationType::Warning, "\"Attachments\"-element contains unknown child element \"" + subElement->idToString() + "\". It will be ignored.", context); + addNotification(NotificationType::Warning, "\"Attachments\"-element contains unknown child element \"" % subElement->idToString() + "\". It will be ignored.", context); } } } catch(const Failure &) { @@ -942,7 +943,7 @@ void MatroskaContainer::internalMakeFile() } } catch(const Failure &) { - addNotification(NotificationType::Critical, "Unable to parse content in top-level element at " + numberToString(level0Element->startOffset()) + " of original file.", context); + addNotification(NotificationType::Critical, "Unable to parse content in top-level element at " % numberToString(level0Element->startOffset()) + " of original file.", context); throw; } @@ -1342,7 +1343,7 @@ nonRewriteCalculations: } default: // just copy any unknown top-level elements - addNotification(NotificationType::Warning, "The top-level element \"" + level0Element->idToString() + "\" of the original file is unknown and will just be copied.", context); + addNotification(NotificationType::Warning, "The top-level element \"" % level0Element->idToString() + "\" of the original file is unknown and will just be copied.", context); currentOffset += level0Element->totalSize(); readOffset += level0Element->totalSize(); } diff --git a/matroska/matroskaeditionentry.cpp b/matroska/matroskaeditionentry.cpp index 3bb11f6..72bbe31 100644 --- a/matroska/matroskaeditionentry.cpp +++ b/matroska/matroskaeditionentry.cpp @@ -2,11 +2,13 @@ #include "./ebmlelement.h" #include "./matroskaid.h" +#include #include #include using namespace std; +using namespace ConversionUtilities; namespace Media { @@ -76,7 +78,7 @@ void MatroskaEditionEntry::parse() m_chapters.emplace_back(make_unique(entryChild)); break; default: - addNotification(NotificationType::Warning, "\"EditionEntry\"-element contains unknown child element \"" + entryChild->idToString() + "\" which will be ingored.", context); + addNotification(NotificationType::Warning, "\"EditionEntry\"-element contains unknown child element \"" % entryChild->idToString() + "\" which will be ingored.", context); } entryChild = entryChild->nextSibling(); } diff --git a/matroska/matroskaseekinfo.cpp b/matroska/matroskaseekinfo.cpp index f7c00b6..cbba2bd 100644 --- a/matroska/matroskaseekinfo.cpp +++ b/matroska/matroskaseekinfo.cpp @@ -3,6 +3,7 @@ #include "../exceptions.h" +#include #include #include @@ -68,7 +69,7 @@ void MatroskaSeekInfo::parse(EbmlElement *seekHeadElement) break; default: addNotification(NotificationType::Warning, "The element \"" - + seekElementChild->idToString() + % seekElementChild->idToString() + "\" within the \"Seek\" element is not a \"SeekID\"-element nor a \"SeekPosition\"-element and will be ignored.", context); } seekElementChild = seekElementChild->nextSibling(); @@ -83,7 +84,7 @@ void MatroskaSeekInfo::parse(EbmlElement *seekHeadElement) case EbmlIds::Void: break; default: - addNotification(NotificationType::Warning, "The element " + seekElement->idToString() + " is not a seek element and will be ignored.", context); + addNotification(NotificationType::Warning, "The element " % seekElement->idToString() + " is not a seek element and will be ignored.", context); } seekElement = seekElement->nextSibling(); } diff --git a/mp4/mp4atom.cpp b/mp4/mp4atom.cpp index 3aeefd9..46be2eb 100644 --- a/mp4/mp4atom.cpp +++ b/mp4/mp4atom.cpp @@ -6,6 +6,7 @@ #include "../exceptions.h" +#include #include #include @@ -48,7 +49,7 @@ Mp4Atom::Mp4Atom(GenericFileElement::implementationType &parent, uint64 startOff */ string Mp4Atom::parsingContext() const { - return "parsing " + idToString() + " atom at " + numberToString(startOffset()); + return "parsing " % idToString() % " atom at " + numberToString(startOffset()); } /*! @@ -59,7 +60,7 @@ void Mp4Atom::internalParse() invalidateStatus(); static const string context("parsing MP4 atom"); if(maxTotalSize() < minimumElementSize()) { - addNotification(NotificationType::Critical, "Atom is smaller then 8 byte and hence invalid. The remaining size within the parent atom is " + numberToString(maxTotalSize()) + ".", context); + addNotification(NotificationType::Critical, "Atom is smaller then 8 byte and hence invalid. The remaining size within the parent atom is " % numberToString(maxTotalSize()) + ".", context); throw TruncatedDataException(); } stream().seekg(startOffset()); diff --git a/mp4/mp4container.cpp b/mp4/mp4container.cpp index 7a4b6dc..3fe4ab5 100644 --- a/mp4/mp4container.cpp +++ b/mp4/mp4container.cpp @@ -5,6 +5,7 @@ #include "../mediafileinfo.h" #include "../backuphelper.h" +#include #include #include #include @@ -714,7 +715,7 @@ calculatePadding: const vector &chunkOffsetTable = get<1>(trackInfos.back()); const vector &chunkSizesTable = get<2>(trackInfos.back()); if(track->chunkCount() != chunkOffsetTable.size() || track->chunkCount() != chunkSizesTable.size()) { - addNotification(NotificationType::Critical, "Chunks of track " + numberToString(track->id()) + " could not be parsed correctly.", context); + addNotification(NotificationType::Critical, "Chunks of track " % numberToString(track->id()) + " could not be parsed correctly.", context); } // increase total chunk count and size @@ -848,7 +849,7 @@ calculatePadding: if(track->chunkCount() == chunkOffsetTable.size()) { track->updateChunkOffsets(chunkOffsetTable); } else { - addNotification(NotificationType::Critical, "Unable to update chunk offsets of track " + numberToString(trackIndex + 1) + ": Number of chunks in the output file differs from the number of chunks in the orignal file.", context); + addNotification(NotificationType::Critical, "Unable to update chunk offsets of track " % numberToString(trackIndex + 1) + ": Number of chunks in the output file differs from the number of chunks in the orignal file.", context); throw Failure(); } } @@ -953,7 +954,7 @@ void Mp4Container::updateOffsets(const std::vector &oldMdatOffsets, const try { track->parseHeader(); } catch(const Failure &) { - addNotification(NotificationType::Warning, "The chunk offsets of track " + track->name() + " couldn't be updated because the track seems to be invalid..", context); + addNotification(NotificationType::Warning, "The chunk offsets of track " % track->name() + " couldn't be updated because the track seems to be invalid..", context); throw; } } @@ -961,7 +962,7 @@ void Mp4Container::updateOffsets(const std::vector &oldMdatOffsets, const try { track->updateChunkOffsets(oldMdatOffsets, newMdatOffsets); } catch(const Failure &) { - addNotification(NotificationType::Warning, "The chunk offsets of track " + track->name() + " couldn't be updated.", context); + addNotification(NotificationType::Warning, "The chunk offsets of track " % track->name() + " couldn't be updated.", context); throw; } } diff --git a/mp4/mp4tagfield.cpp b/mp4/mp4tagfield.cpp index 4222f04..b3a365a 100644 --- a/mp4/mp4tagfield.cpp +++ b/mp4/mp4tagfield.cpp @@ -5,6 +5,7 @@ #include "../exceptions.h" +#include #include #include #include @@ -243,7 +244,7 @@ void Mp4TagField::reparse(Mp4Atom &ilstChild) stream.seekg(dataAtom->dataOffset() + 4); m_name = reader.readString(dataAtom->dataSize() - 4); } else { - addNotification(NotificationType::Warning, "Unkown child atom \"" + dataAtom->idToString() + "\" in tag atom (ilst child) found. (will be ignored)", context); + addNotification(NotificationType::Warning, "Unkown child atom \"" % dataAtom->idToString() + "\" in tag atom (ilst child) found. (will be ignored)", context); } } catch(const Failure &) { addNotification(NotificationType::Warning, "Unable to parse all childs atom in tag atom (ilst child) found. (will be ignored)", context); @@ -466,7 +467,7 @@ Mp4TagFieldMaker::Mp4TagFieldMaker(Mp4TagField &field) : } else if(number > 0) { m_writer.writeUInt32BE(number); } else { - throw ConversionException("Negative integer can not be assigned to the field with the id \"" + interpretIntegerAsString(m_field.id()) + "\"."); + throw ConversionException("Negative integer can not be assigned to the field with the id \"" % interpretIntegerAsString(m_field.id()) + "\"."); } break; } case RawDataType::Bmp: case RawDataType::Jpeg: case RawDataType::Png: @@ -481,7 +482,7 @@ Mp4TagFieldMaker::Mp4TagFieldMaker(Mp4TagField &field) : if(pos.total() <= numeric_limits::max()) { m_writer.writeInt16BE(static_cast(pos.total())); } else { - throw ConversionException("Integer can not be assigned to the field with the id \"" + interpretIntegerAsString(m_field.id()) + "\" because it is to big."); + throw ConversionException("Integer can not be assigned to the field with the id \"" % interpretIntegerAsString(m_field.id()) + "\" because it is to big."); } m_writer.writeUInt16BE(0); break; diff --git a/mp4/mp4track.cpp b/mp4/mp4track.cpp index 41c1167..759b399 100644 --- a/mp4/mp4track.cpp +++ b/mp4/mp4track.cpp @@ -12,6 +12,7 @@ #include "../exceptions.h" #include "../mediaformat.h" +#include #include #include #include @@ -1025,7 +1026,7 @@ void Mp4Track::makeMedia() if(m_language[charIndex] >= 'a' && m_language[charIndex] <= 'z') { language |= static_cast(m_language[charIndex]) << (0xA - charIndex * 0x5); } else { // invalid character - addNotification(NotificationType::Warning, "Assigned language \"" + m_language + "\" is of an invalid format and will be ignored.", "making mdhd atom"); + addNotification(NotificationType::Warning, "Assigned language \"" % m_language + "\" is of an invalid format and will be ignored.", "making mdhd atom"); language = 0x55C4; // und break; } @@ -1469,7 +1470,8 @@ void Mp4Track::internalParseHeader() if(m_format.general == GeneralMediaFormat::Mpeg4Video && m_esInfo->videoSpecificConfig->profile) { m_format.sub = m_esInfo->videoSpecificConfig->profile; if(!m_esInfo->videoSpecificConfig->userData.empty()) { - m_formatId += " / " + m_esInfo->videoSpecificConfig->userData; + m_formatId += " / "; + m_formatId += m_esInfo->videoSpecificConfig->userData; } } } diff --git a/mp4/mpeg4descriptor.cpp b/mp4/mpeg4descriptor.cpp index 2b136c8..53a5faf 100644 --- a/mp4/mpeg4descriptor.cpp +++ b/mp4/mpeg4descriptor.cpp @@ -2,8 +2,9 @@ #include "./mp4container.h" #include "./mp4ids.h" -#include #include +#include +#include using namespace std; using namespace ConversionUtilities; @@ -35,7 +36,7 @@ Mpeg4Descriptor::Mpeg4Descriptor(implementationType &parent, uint64 startOffset) */ string Mpeg4Descriptor::parsingContext() const { - return "parsing " + idToString() + " descriptor at " + numberToString(startOffset()); + return "parsing " % idToString() % " descriptor at " + numberToString(startOffset()); } /*! @@ -54,7 +55,7 @@ void Mpeg4Descriptor::internalParse() { invalidateStatus(); if(maxTotalSize() < minimumElementSize()) { - addNotification(NotificationType::Critical, "Descriptor is smaller then 2 byte and hence invalid. The maximum size within the encloding element is " + numberToString(maxTotalSize()) + ".", "parsing MPEG-4 descriptor"); + addNotification(NotificationType::Critical, "Descriptor is smaller then 2 byte and hence invalid. The maximum size within the encloding element is " % numberToString(maxTotalSize()) + '.', "parsing MPEG-4 descriptor"); throw TruncatedDataException(); } stream().seekg(startOffset()); diff --git a/ogg/oggcontainer.cpp b/ogg/oggcontainer.cpp index 8225dac..c8db4b5 100644 --- a/ogg/oggcontainer.cpp +++ b/ogg/oggcontainer.cpp @@ -5,12 +5,14 @@ #include "../mediafileinfo.h" #include "../backuphelper.h" +#include #include #include #include using namespace std; using namespace IoUtilities; +using namespace ConversionUtilities; namespace Media { @@ -189,7 +191,7 @@ void OggContainer::internalParseHeader() const OggPage &page = m_iterator.currentPage(); if(m_validateChecksums) { if(page.checksum() != OggPage::computeChecksum(stream(), page.startOffset())) { - addNotification(NotificationType::Warning, "The denoted checksum of the OGG page at " + ConversionUtilities::numberToString(m_iterator.currentSegmentOffset()) + " does not match the computed checksum.", context); + addNotification(NotificationType::Warning, "The denoted checksum of the OGG page at " % ConversionUtilities::numberToString(m_iterator.currentSegmentOffset()) + " does not match the computed checksum.", context); } } OggStream *stream; @@ -215,7 +217,7 @@ void OggContainer::internalParseHeader() addNotification(NotificationType::Critical, "The OGG file is truncated.", context); } catch(const InvalidDataException &) { // thrown when first 4 byte do not match capture pattern - addNotification(NotificationType::Critical, "Capture pattern \"OggS\" at " + ConversionUtilities::numberToString(m_iterator.currentSegmentOffset()) + " expected.", context); + addNotification(NotificationType::Critical, "Capture pattern \"OggS\" at " % numberToString(m_iterator.currentSegmentOffset()) + " expected.", context); } } @@ -275,7 +277,7 @@ void OggContainer::internalParseTracks() m_duration = stream->duration(); } } catch(const Failure &) { - addNotification(NotificationType::Critical, "Unable to parse stream at " + ConversionUtilities::numberToString(stream->startOffset()) + ".", context); + addNotification(NotificationType::Critical, "Unable to parse stream at " % numberToString(stream->startOffset()) + ".", context); } } } diff --git a/statusprovider.cpp b/statusprovider.cpp index c283f87..b38ccce 100644 --- a/statusprovider.cpp +++ b/statusprovider.cpp @@ -1,6 +1,9 @@ #include "./statusprovider.h" +#include + using namespace std; +using namespace ConversionUtilities; namespace Media { @@ -91,7 +94,7 @@ void StatusProvider::addNotifications(const string &higherContext, const StatusP return; } for(const auto ¬ification : from.m_notifications) { - addNotification(notification.type(), notification.message(), higherContext + ", " + notification.context()); + addNotification(notification.type(), notification.message(), higherContext % ',' % ' ' + notification.context()); } }