Make use of string builder
This commit is contained in:
parent
b4e167bd71
commit
541f14039b
|
@ -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
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "./mediafileinfo.h"
|
||||
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/io/catchiofailure.h>
|
||||
|
||||
#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.");
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "../exceptions.h"
|
||||
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
||||
#include <zlib.h>
|
||||
|
@ -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()) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "../exceptions.h"
|
||||
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <c++utilities/conversion/types.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/conversion/binaryconversion.h>
|
||||
#include <c++utilities/io/binaryreader.h>
|
||||
#include <c++utilities/io/binarywriter.h>
|
||||
|
@ -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());
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "./matroskaid.h"
|
||||
|
||||
#include <c++utilities/conversion/binaryconversion.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
#include "./ebmlelement.h"
|
||||
#include "./matroskaid.h"
|
||||
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
||||
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<MatroskaChapter>(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
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "resources/config.h"
|
||||
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/io/catchiofailure.h>
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
||||
|
@ -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<uint32>(EbmlElement::maximumIdLengthSupported())
|
||||
% numberToString<uint32>(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<uint32>(EbmlElement::maximumSizeLengthSupported())
|
||||
% numberToString<uint32>(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<EbmlElement>(*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();
|
||||
}
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
#include "./ebmlelement.h"
|
||||
#include "./matroskaid.h"
|
||||
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace ConversionUtilities;
|
||||
|
||||
namespace Media {
|
||||
|
||||
|
@ -76,7 +78,7 @@ void MatroskaEditionEntry::parse()
|
|||
m_chapters.emplace_back(make_unique<MatroskaChapter>(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();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../exceptions.h"
|
||||
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/conversion/binaryconversion.h>
|
||||
|
||||
#include <string>
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "../exceptions.h"
|
||||
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/io/binaryreader.h>
|
||||
#include <c++utilities/io/binarywriter.h>
|
||||
|
||||
|
@ -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());
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "../mediafileinfo.h"
|
||||
#include "../backuphelper.h"
|
||||
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/io/binaryreader.h>
|
||||
#include <c++utilities/io/binarywriter.h>
|
||||
#include <c++utilities/io/copy.h>
|
||||
|
@ -714,7 +715,7 @@ calculatePadding:
|
|||
const vector<uint64> &chunkOffsetTable = get<1>(trackInfos.back());
|
||||
const vector<uint64> &chunkSizesTable = get<2>(trackInfos.back());
|
||||
if(track->chunkCount() != chunkOffsetTable.size() || track->chunkCount() != chunkSizesTable.size()) {
|
||||
addNotification(NotificationType::Critical, "Chunks of track " + numberToString<uint64, string>(track->id()) + " could not be parsed correctly.", context);
|
||||
addNotification(NotificationType::Critical, "Chunks of track " % numberToString<uint64, string>(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<int64> &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<int64> &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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "../exceptions.h"
|
||||
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/io/binaryreader.h>
|
||||
#include <c++utilities/io/binarywriter.h>
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
@ -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<uint32>(m_field.id()) + "\".");
|
||||
throw ConversionException("Negative integer can not be assigned to the field with the id \"" % interpretIntegerAsString<uint32>(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<int16>::max()) {
|
||||
m_writer.writeInt16BE(static_cast<int16>(pos.total()));
|
||||
} else {
|
||||
throw ConversionException("Integer can not be assigned to the field with the id \"" + interpretIntegerAsString<uint32>(m_field.id()) + "\" because it is to big.");
|
||||
throw ConversionException("Integer can not be assigned to the field with the id \"" % interpretIntegerAsString<uint32>(m_field.id()) + "\" because it is to big.");
|
||||
}
|
||||
m_writer.writeUInt16BE(0);
|
||||
break;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "../exceptions.h"
|
||||
#include "../mediaformat.h"
|
||||
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/io/binaryreader.h>
|
||||
#include <c++utilities/io/binarywriter.h>
|
||||
#include <c++utilities/io/bitreader.h>
|
||||
|
@ -1025,7 +1026,7 @@ void Mp4Track::makeMedia()
|
|||
if(m_language[charIndex] >= 'a' && m_language[charIndex] <= 'z') {
|
||||
language |= static_cast<uint16>(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#include "./mp4container.h"
|
||||
#include "./mp4ids.h"
|
||||
|
||||
#include <c++utilities/io/binaryreader.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/io/binaryreader.h>
|
||||
|
||||
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());
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
#include "../mediafileinfo.h"
|
||||
#include "../backuphelper.h"
|
||||
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/io/copy.h>
|
||||
#include <c++utilities/io/catchiofailure.h>
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#include "./statusprovider.h"
|
||||
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue