Use stringstream instead of strstream (#431)

* replace strstream with string stream

* all change

Signed-off-by: tomosu <tomosu@users.noreply.github.com>

* small changes
This commit is contained in:
tomosu 2016-06-13 21:50:05 +09:00 committed by Keisuke Ogaki
parent ee259ffaf7
commit eea0acf6fa
7 changed files with 50 additions and 62 deletions

View file

@ -24,7 +24,7 @@ TOfflineGL::Imp *MacOfflineGenerator1(const TDimension &dim)
#endif
#include <map>
#include <strstream>
#include <sstream>
using namespace TEnv;
@ -636,21 +636,17 @@ std::istream &operator>>(std::istream &is, TRect &rect)
template <class T>
std::string toString2(T value)
{
std::ostrstream ss;
std::ostringstream ss;
ss << value << '\0';
std::string s(ss.str());
ss.freeze(false);
return s;
return ss.str();
}
template <>
std::string toString2(TRect value)
{
std::ostrstream ss;
std::ostringstream ss;
ss << value.x0 << " " << value.y0 << " " << value.x1 << " " << value.y1 << '\0';
std::string s = ss.str();
ss.freeze(false);
return s;
return ss.str();
}
template <class T>
@ -658,7 +654,7 @@ void fromString(std::string s, T &value)
{
if (s.empty())
return;
std::istrstream is(s.c_str(), s.size());
std::istringstream is(s);
is >> value;
}

View file

@ -2,7 +2,7 @@
#include "tstopwatch.h"
#include <strstream>
#include <sstream>
#ifdef _WIN32
#include <stdlib.h>
@ -353,10 +353,9 @@ TUINT32 TStopWatch::getSystemTime()
TStopWatch::operator string()
{
char buffer[256];
ostrstream out(buffer, sizeof(buffer));
ostringstream out;
out << m_name.c_str() << ": " << (int)getTotalTime() << " u" << (int)getUserTime() << " s" << (TINT32)getSystemTime();
return string(buffer, out.pcount());
return out.str();
}
//------------------------------------------------------------

View file

@ -1,4 +1,4 @@
#include <sstream>
#include "tsystem.h"
#include "tcachedlevel.h"
@ -169,9 +169,8 @@ private:
default:
char *sysErr = strerror(errorCode);
ostrstream os;
ostringstream os;
os << errorCode << '\0';
os.freeze(false);
return string(sysErr) + "(" + os.str() + ")";
break;
}

View file

@ -22,7 +22,7 @@ const char wauxslash = '\\';
#include "tconvert.h"
#include <cmath>
#include <cctype>
#include <strstream>
#include <sstream>
bool TFilePath::m_underscoreFormatAllowed = true;
@ -49,8 +49,7 @@ std::string TFrameId::expand(FrameFormat format) const
return "";
else if (m_frame == NO_FRAME)
return "-";
char buffer[80];
std::ostrstream o_buff(buffer, sizeof(buffer));
std::ostringstream o_buff;
if (format == FOUR_ZEROS || format == UNDERSCORE_FOUR_ZEROS) {
o_buff.fill('0');
o_buff.width(4);
@ -61,8 +60,7 @@ std::string TFrameId::expand(FrameFormat format) const
}
if (m_letter != '\0')
o_buff << m_letter;
int len = o_buff.pcount();
return std::string(buffer, len);
return o_buff.str();
}
//-------------------------------------------------------------------
@ -183,7 +181,7 @@ void append(string &out, wchar_t c)
else if(c=='&') out.append("&amp;");
else
{
ostrstream ss;
ostringstream ss;
ss << "&#" << c << ";" << '\0';
out += ss.str();
ss.freeze(0);

View file

@ -14,7 +14,7 @@
#include "tcolorstyles.h"
#include <set>
#include <strstream>
#include <sstream>
#if defined(LINUX)
#include <typeinfo>
@ -173,7 +173,7 @@ void TTest::runTests(string name)
cout << "Test file : '" << testFile << "'" << endl;
char buffer[1024];
while (is.getline(buffer, sizeof(buffer))) {
std::istrstream ss(buffer);
std::istringstream ss(buffer);
while (ss) {
string s;
ss >> s;

View file

@ -2022,12 +2022,11 @@ void printStrokes1(vector<VIStroke *> &v, int size)
#ifdef _DEBUG
static void printTime(TStopWatch &sw, string name)
{
ostrstream ss;
ostringstream ss;
ss << name << " : ";
sw.print(ss);
ss << '\n' << '\0';
string s = ss.str();
ss.freeze(false);
string s(ss.str());
//TSystem::outputDebug(s);
}
#endif

View file

@ -3,7 +3,7 @@
#include "autopos.h"
#include "cleanupcommon.h"
#include <strstream>
#include <sstream>
using namespace CleanupTypes;
@ -711,10 +711,9 @@ static int find_dots_bw(const TRasterP &img, int strip_width, PEGS_SIDE pegs_sid
break;
default: {
ostrstream os;
std::ostringstream os;
os << "find dots internal error: pegs_side = " << std::hex << pegs_side << '\0';
os.freeze(false);
throw TCleanupException(os.str());
throw TCleanupException(os.str().c_str());
x0 = y0 = xsize = ysize = vertical = 0;
}
}
@ -844,10 +843,9 @@ static int find_dots_gr8(const TRasterGR8P &img, int strip_width, PEGS_SIDE pegs
vertical = TRUE;
break;
default: {
std::ostrstream os;
std::ostringstream os;
os << "find dots internal error: pegs_side = " << std::hex << pegs_side << '\0';
os.freeze(false);
throw TCleanupException(os.str());
throw TCleanupException(os.str().c_str());
x0 = y0 = xsize = ysize = vertical = 0;
}
}
@ -973,10 +971,9 @@ static int find_dots_rgb(const TRaster32P &img, int strip_width, PEGS_SIDE pegs_
vertical = TRUE;
break;
default: {
std::ostrstream os;
std::ostringstream os;
os << "find dots internal error: pegs_side = " << std::hex << pegs_side << '\0';
os.freeze(false);
throw TCleanupException(os.str());
throw TCleanupException(os.str().c_str());
x0 = y0 = xsize = ysize = vertical = 0;
break;
}