From 7a7c17092fcdd4772fb6e499ef13429f96ac04bb Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 16 Aug 2018 23:36:38 +0900 Subject: [PATCH] Switch from strstream to sstream. Signed-off-by: Michele Calgaro --- filters/kspread/qpro/libqpro/src/formula.cc | 14 ++---- filters/kspread/qpro/libqpro/src/record.cc | 8 +-- filters/kspread/qpro/libqpro/src/stream.cc | 4 +- lib/kross/python/cxx/Config.hxx | 41 ---------------- lib/kross/python/cxx/Extensions.hxx | 10 ++-- lib/kross/python/cxx/Objects.hxx | 54 ++++++++++----------- 6 files changed, 43 insertions(+), 88 deletions(-) diff --git a/filters/kspread/qpro/libqpro/src/formula.cc b/filters/kspread/qpro/libqpro/src/formula.cc index 13e3a4574..aab0bb8d4 100644 --- a/filters/kspread/qpro/libqpro/src/formula.cc +++ b/filters/kspread/qpro/libqpro/src/formula.cc @@ -1,7 +1,7 @@ #include #include -#include +#include #include @@ -474,30 +474,26 @@ void QpFormula::floatFuncReal(const char*) { TQP_INT64 lFloat; - std::ostrstream lNum; + std::ostringstream lNum; cFormula >> lFloat; lNum << lFloat << ends; - cStack.push( lNum.str() ); - - lNum.rdbuf()->freeze(0); + cStack.push( lNum.str().c_str() ); } void QpFormula::intFuncReal(const char*) { TQP_INT16 lInt; - std::ostrstream lNum; + std::ostringstream lNum; cFormula >> lInt; lNum << lInt << ends; - cStack.push( lNum.str() ); - - lNum.rdbuf()->freeze(0); + cStack.push( lNum.str().c_str() ); } void diff --git a/filters/kspread/qpro/libqpro/src/record.cc b/filters/kspread/qpro/libqpro/src/record.cc index 8aa877c68..461b65d34 100644 --- a/filters/kspread/qpro/libqpro/src/record.cc +++ b/filters/kspread/qpro/libqpro/src/record.cc @@ -10,7 +10,7 @@ // ----------------------------------------------------------------------- #include -#include +#include void Charout(ostream& pOut, unsigned char pChar) @@ -32,7 +32,7 @@ Hexout(ostream& pOut, unsigned char pChar) int Hexout(char* pChar, int pLen) { - std::ostrstream* lOStr = new std::ostrstream; + std::ostringstream* lOStr = new std::ostringstream; while( pLen ) { @@ -57,7 +57,7 @@ Hexout(char* pChar, int pLen) cerr << lOStr->rdbuf() << endl; delete lOStr; - lOStr = new std::ostrstream; + lOStr = new std::ostringstream; } delete lOStr; @@ -200,7 +200,7 @@ QpRecCell::cellRef(char* pText, QpTableNames& pTable, TQP_INT16 /*pNoteBook*/, T { //??? cope with relative/absolute references - std::strstream lOut(pText, 20, ios::out); // ??? ard coded len + std::stringstream lOut(pText, ios::out); int lPageRelative = pRow & 0x8000; int lColRelative = pRow & 0x4000; int lRowRelative = pRow & 0x2000; diff --git a/filters/kspread/qpro/libqpro/src/stream.cc b/filters/kspread/qpro/libqpro/src/stream.cc index 012e18bbd..390fc3703 100644 --- a/filters/kspread/qpro/libqpro/src/stream.cc +++ b/filters/kspread/qpro/libqpro/src/stream.cc @@ -32,7 +32,7 @@ QpIStream::~QpIStream() #else #include #include -#include +#include // For IRIX namespace std {} @@ -61,7 +61,7 @@ QpIStream::QpIStream(unsigned char* pBuffer, unsigned int pLen) , cOffset(0L) , cStreamBuf(0) { - cStreamBuf = new std::strstreambuf (pBuffer, pLen); + cStreamBuf = new std::stringbuf ((char*)(pBuffer)); //cIn will read into char anyway.... cIn = new istream(cStreamBuf); } diff --git a/lib/kross/python/cxx/Config.hxx b/lib/kross/python/cxx/Config.hxx index 65bbc2d3b..7959c4039 100644 --- a/lib/kross/python/cxx/Config.hxx +++ b/lib/kross/python/cxx/Config.hxx @@ -30,45 +30,4 @@ # define random_access_iterator_parent(itemtype) std::random_access_iterator #endif -// -// Which C++ standard is in use? -// -#if defined( _MSC_VER ) -# if _MSC_VER <= 1200 -// MSVC++ 6.0 -# define PYCXX_ISO_CPP_LIB 0 -# define STR_STREAM -# define TEMPLATE_TYPENAME class -# else -# define PYCXX_ISO_CPP_LIB 1 -# define STR_STREAM -# define TEMPLATE_TYPENAME typename -# endif -#elif defined( __GNUC__ ) -# if __GNUC__ >= 3 -# define PYCXX_ISO_CPP_LIB 1 -# define STR_STREAM -# define TEMPLATE_TYPENAME typename -# else -# define PYCXX_ISO_CPP_LIB 0 -# define STR_STREAM -# define TEMPLATE_TYPENAME class -# endif -#endif - -#if PYCXX_ISO_CPP_LIB -# define STR_STREAM -# define OSTRSTREAM ostringstream -# define EXPLICIT_TYPENAME typename -# define EXPLICIT_CLASS class -# define TEMPLATE_TYPENAME typename -#else -# define STR_STREAM -# define OSTRSTREAM ostrstream -# define EXPLICIT_TYPENAME -# define EXPLICIT_CLASS -# define TEMPLATE_TYPENAME class -#endif - - #endif // __PyCXX_config_hh__ diff --git a/lib/kross/python/cxx/Extensions.hxx b/lib/kross/python/cxx/Extensions.hxx index 69ce9a14b..99889ec7b 100644 --- a/lib/kross/python/cxx/Extensions.hxx +++ b/lib/kross/python/cxx/Extensions.hxx @@ -158,7 +158,7 @@ namespace Py extern "C" void do_not_dealloc( void * ); - template + template class ExtensionModule : public ExtensionModuleBase { public: @@ -213,7 +213,7 @@ namespace Py // so that we get called back at the function in T. // method_map_t &mm = methods(); - EXPLICIT_TYPENAME method_map_t::iterator i; + typename method_map_t::iterator i; for( i=mm.begin(); i != mm.end(); ++i ) { @@ -434,7 +434,7 @@ namespace Py static PyObject *method_call_handler( PyObject *self, PyObject *args ); }; - template + template class PythonExtension: public PythonExtensionBase { public: @@ -548,7 +548,7 @@ namespace Py { List methods; - for( EXPLICIT_TYPENAME method_map_t::iterator i = mm.begin(); i != mm.end(); ++i ) + for( typename method_map_t::iterator i = mm.begin(); i != mm.end(); ++i ) methods.append( String( (*i).first ) ); return methods; @@ -701,7 +701,7 @@ namespace Py // // ExtensionObject is an Object that will accept only T's. // - template + template class ExtensionObject: public Object { public: diff --git a/lib/kross/python/cxx/Objects.hxx b/lib/kross/python/cxx/Objects.hxx index 416483206..28662d4fa 100644 --- a/lib/kross/python/cxx/Objects.hxx +++ b/lib/kross/python/cxx/Objects.hxx @@ -17,7 +17,7 @@ #include -#include STR_STREAM +#include #include #include #include @@ -30,10 +30,10 @@ namespace Py // Forward declarations class Object; class Type; - template class SeqBase; + template class SeqBase; class String; class List; - template class MapBase; + template class MapBase; // new_reference_to also overloaded below on Object inline PyObject* new_reference_to(PyObject* p) @@ -837,7 +837,7 @@ namespace Py // Changing them to Object(x[i]) helps the compiler to understand that the // conversion of a seqref to an Object is wanted. - template + template class seqref { protected: @@ -1027,7 +1027,7 @@ namespace Py // class SeqBase // ...the base class for all sequence types - template + template class SeqBase: public Object { public: @@ -1289,7 +1289,7 @@ namespace Py std::string diagnose() const { - std::OSTRSTREAM oss; + std::ostringstream oss; oss << "iterator diagnosis " << seq << ", " << count << std::ends; return std::string(oss.str()); } @@ -1436,19 +1436,19 @@ namespace Py // Here's an important typedef you might miss if reading too fast... typedef SeqBase Sequence; - template bool operator==(const EXPLICIT_TYPENAME SeqBase::iterator& left, const EXPLICIT_TYPENAME SeqBase::iterator& right); - template bool operator!=(const EXPLICIT_TYPENAME SeqBase::iterator& left, const EXPLICIT_TYPENAME SeqBase::iterator& right); - template bool operator< (const EXPLICIT_TYPENAME SeqBase::iterator& left, const EXPLICIT_TYPENAME SeqBase::iterator& right); - template bool operator> (const EXPLICIT_TYPENAME SeqBase::iterator& left, const EXPLICIT_TYPENAME SeqBase::iterator& right); - template bool operator<=(const EXPLICIT_TYPENAME SeqBase::iterator& left, const EXPLICIT_TYPENAME SeqBase::iterator& right); - template bool operator>=(const EXPLICIT_TYPENAME SeqBase::iterator& left, const EXPLICIT_TYPENAME SeqBase::iterator& right); + template bool operator==(const typename SeqBase::iterator& left, const typename SeqBase::iterator& right); + template bool operator!=(const typename SeqBase::iterator& left, const typename SeqBase::iterator& right); + template bool operator< (const typename SeqBase::iterator& left, const typename SeqBase::iterator& right); + template bool operator> (const typename SeqBase::iterator& left, const typename SeqBase::iterator& right); + template bool operator<=(const typename SeqBase::iterator& left, const typename SeqBase::iterator& right); + template bool operator>=(const typename SeqBase::iterator& left, const typename SeqBase::iterator& right); - template bool operator==(const EXPLICIT_TYPENAME SeqBase::const_iterator& left, const EXPLICIT_TYPENAME SeqBase::const_iterator& right); - template bool operator!=(const EXPLICIT_TYPENAME SeqBase::const_iterator& left, const EXPLICIT_TYPENAME SeqBase::const_iterator& right); - template bool operator< (const EXPLICIT_TYPENAME SeqBase::const_iterator& left, const EXPLICIT_TYPENAME SeqBase::const_iterator& right); - template bool operator> (const EXPLICIT_TYPENAME SeqBase::const_iterator& left, const EXPLICIT_TYPENAME SeqBase::const_iterator& right); - template bool operator<=(const EXPLICIT_TYPENAME SeqBase::const_iterator& left, const EXPLICIT_TYPENAME SeqBase::const_iterator& right); - template bool operator>=(const EXPLICIT_TYPENAME SeqBase::const_iterator& left, const EXPLICIT_TYPENAME SeqBase::const_iterator& right); + template bool operator==(const typename SeqBase::const_iterator& left, const typename SeqBase::const_iterator& right); + template bool operator!=(const typename SeqBase::const_iterator& left, const typename SeqBase::const_iterator& right); + template bool operator< (const typename SeqBase::const_iterator& left, const typename SeqBase::const_iterator& right); + template bool operator> (const typename SeqBase::const_iterator& left, const typename SeqBase::const_iterator& right); + template bool operator<=(const typename SeqBase::const_iterator& left, const typename SeqBase::const_iterator& right); + template bool operator>=(const typename SeqBase::const_iterator& left, const typename SeqBase::const_iterator& right); extern bool operator==(const Sequence::iterator& left, const Sequence::iterator& right); @@ -1916,7 +1916,7 @@ namespace Py // Mappings // ================================================== - template + template class mapref { protected: @@ -2085,7 +2085,7 @@ namespace Py return true; // not completed. } - template + template class MapBase: public Object { protected: @@ -2372,7 +2372,7 @@ namespace Py std::string diagnose() const { - std::OSTRSTREAM oss; + std::ostringstream oss; oss << "iterator diagnosis " << map << ", " << pos << std::ends; return std::string(oss.str()); } @@ -2477,10 +2477,10 @@ namespace Py typedef MapBase Mapping; - template bool operator==(const EXPLICIT_TYPENAME MapBase::iterator& left, const EXPLICIT_TYPENAME MapBase::iterator& right); - template bool operator!=(const EXPLICIT_TYPENAME MapBase::iterator& left, const EXPLICIT_TYPENAME MapBase::iterator& right); - template bool operator==(const EXPLICIT_TYPENAME MapBase::const_iterator& left, const EXPLICIT_TYPENAME MapBase::const_iterator& right); - template bool operator!=(const EXPLICIT_TYPENAME MapBase::const_iterator& left, const EXPLICIT_TYPENAME MapBase::const_iterator& right); + template bool operator==(const typename MapBase::iterator& left, const typename MapBase::iterator& right); + template bool operator!=(const typename MapBase::iterator& left, const typename MapBase::iterator& right); + template bool operator==(const typename MapBase::const_iterator& left, const typename MapBase::const_iterator& right); + template bool operator!=(const typename MapBase::const_iterator& left, const typename MapBase::const_iterator& right); extern bool operator==(const Mapping::iterator& left, const Mapping::iterator& right); extern bool operator!=(const Mapping::iterator& left, const Mapping::iterator& right); @@ -2787,13 +2787,13 @@ namespace Py -template +template String seqref::str () const { return the_item.str(); } -template +template String seqref::repr () const { return the_item.repr();