Use string builder rather than stringstream
This commit is contained in:
parent
541f14039b
commit
230a14fcf1
|
@ -313,9 +313,7 @@ void Id3v2Tag::setVersion(byte majorVersion, byte revisionVersion)
|
|||
{
|
||||
m_majorVersion = majorVersion;
|
||||
m_revisionVersion = revisionVersion;
|
||||
stringstream versionStream(stringstream::in | stringstream::out);
|
||||
versionStream << "2." << static_cast<int>(majorVersion) << "." << static_cast<int>(revisionVersion);
|
||||
m_version = versionStream.str();
|
||||
m_version = '2' % '.' % numberToString(majorVersion) % '.' + numberToString(revisionVersion);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
12
margin.h
12
margin.h
|
@ -4,9 +4,10 @@
|
|||
#include "./global.h"
|
||||
|
||||
#include <c++utilities/conversion/types.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace Media {
|
||||
|
||||
|
@ -122,10 +123,11 @@ inline constexpr bool Margin::isNull() const
|
|||
*/
|
||||
inline std::string Margin::toString() const
|
||||
{
|
||||
std::stringstream res;
|
||||
res << "top: " << m_top << "; left: " << m_left;
|
||||
res << "; bottom: " << m_bottom << "; right: " << m_right;
|
||||
return std::string(res.str());
|
||||
using namespace ConversionUtilities;
|
||||
return "top: " % numberToString(m_top)
|
||||
% "; left: " % numberToString(m_left)
|
||||
% "; bottom: " % numberToString(m_bottom)
|
||||
% "; right: " + numberToString(m_right);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
#include "../exceptions.h"
|
||||
|
||||
#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>
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
#include "../genericfileelement.h"
|
||||
|
||||
#include <c++utilities/conversion/types.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace Media {
|
||||
|
||||
|
@ -89,13 +89,13 @@ private:
|
|||
*/
|
||||
inline std::string EbmlElement::idToString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "0x" << std::hex << id();
|
||||
using namespace ConversionUtilities;
|
||||
const char *name = matroskaIdName(id());
|
||||
if(std::char_traits<char>::length(name)) {
|
||||
ss << " \"" << name << "\"";
|
||||
if(*name) {
|
||||
return '0' % 'x' % numberToString(id(), 16) % ' ' % '\"' % name + '\"';
|
||||
} else {
|
||||
return "0x" + numberToString(id(), 16);
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "./matroskaid.h"
|
||||
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
||||
#include <string>
|
||||
|
@ -39,9 +40,7 @@ MatroskaEditionEntry::~MatroskaEditionEntry()
|
|||
*/
|
||||
string MatroskaEditionEntry::label() const
|
||||
{
|
||||
stringstream ss;
|
||||
ss << "ID: " << id();
|
||||
return ss.str();
|
||||
return "ID: " + numberToString(id());
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -833,10 +833,12 @@ calculatePadding:
|
|||
if(rewriteRequired) {
|
||||
// check whether track count of new file equals track count of old file
|
||||
if(trackCount != tracks().size()) {
|
||||
stringstream error;
|
||||
error << "Unable to update chunk offsets (\"stco\"-atom): Number of tracks in the output file (" << tracks().size()
|
||||
<< ") differs from the number of tracks in the original file (" << trackCount << ").";
|
||||
addNotification(NotificationType::Critical, error.str(), context);
|
||||
addNotification(NotificationType::Critical,
|
||||
"Unable to update chunk offsets (\"stco\"-atom): Number of tracks in the output file ("
|
||||
% numberToString(tracks().size())
|
||||
% ") differs from the number of tracks in the original file ("
|
||||
% numberToString(trackCount)
|
||||
+ ").", context);
|
||||
throw Failure();
|
||||
}
|
||||
|
||||
|
|
8
size.h
8
size.h
|
@ -4,9 +4,10 @@
|
|||
#include "./global.h"
|
||||
|
||||
#include <c++utilities/conversion/types.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace Media {
|
||||
|
||||
|
@ -102,9 +103,8 @@ inline constexpr bool Size::operator==(const Size &other) const
|
|||
*/
|
||||
inline std::string Size::toString() const
|
||||
{
|
||||
std::stringstream res;
|
||||
res << "width: " << m_width << ", height: " << m_height;
|
||||
return std::string(res.str());
|
||||
using namespace ConversionUtilities;
|
||||
return "width: " % numberToString(m_width) % ", height: " + numberToString(m_height);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue