#ifndef SSTREAM_H
#define SSTREAM_H
-#include "LString.h"
+#include <string>
#include <iostream>
#include <streambuf.h>
-#ifdef CXX_WORKING_NAMESPACES
namespace std
{
-#endif
-
class stringbuf : public streambuf
{
public:
streambuf(which), buf(), mode(static_cast<ios::open_mode>(which)),
rpos(0), bufsize(1)
{ }
-
- explicit stringbuf(const string &s, int which=ios::in|ios::out) :
+
+ explicit stringbuf(const std::string &s, int which=ios::in|ios::out) :
streambuf(which), buf(s), mode(static_cast<ios::open_mode>(which)),
bufsize(1)
{
}
rpos = (mode & ios::ate ? s.size() : 0);
}
-
- string str() const
+
+ std::string str() const
{
const_cast<stringbuf*>(this)->sync(); // Sigh, really ugly hack
return buf;
};
- void str(const string& s)
+ void str(const std::string& s)
{
buf = s;
if(mode & ios::in)
inline virtual int overflow(int = EOF);
inline virtual int underflow();
private:
- string buf;
+ std::string buf;
ios::open_mode mode;
- string::size_type rpos;
+ std::string::size_type rpos;
streamsize bufsize;
char defbuf;
};
protected:
stringbuf __my_sb;
public:
- string str() const
+ std::string str() const
{
return static_cast<stringbuf*>(_strbuf)->str();
}
- void str(const string& s)
+ void str(const std::string& s)
{
clear();
static_cast<stringbuf*>(_strbuf)->str(s);
}
-
+
stringbuf* rdbuf()
{
return &__my_sb;
{
init (&__my_sb);
}
-
- stringstreambase(const string& s, int which) :
+
+ stringstreambase(const std::string& s, int which) :
__my_sb(s, which)
{
init (&__my_sb);
}
};
-
+
class istringstream : public stringstreambase, public istream {
public:
istringstream(int which=ios::in) :
stringstreambase(which)
{ }
-
- istringstream(const string& s, int which=ios::in) :
+
+ istringstream(const std::string& s, int which=ios::in) :
stringstreambase(s, which)
{ }
};
-
+
class ostringstream : public stringstreambase, public ostream {
public:
ostringstream(int which=ios::out) :
stringstreambase(which)
{ }
-
- ostringstream(const string& s, int which=ios::out) :
+
+ ostringstream(const std::string& s, int which=ios::out) :
stringstreambase(s, which)
{ }
};
-
+
class stringstream : public stringstreambase, public iostream {
public:
stringstream(int which=ios::in|ios::out) :
stringstreambase(which)
{ }
-
- stringstream(const string &s, int which=ios::in|ios::out) :
+
+ stringstream(const std::string &s, int which=ios::in|ios::out) :
stringstreambase(s, which)
{ }
};
-#ifdef CXX_WORKING_NAMESPACES
-}
-#endif
+} // namespace std
inline int stringbuf::sync()
{
streamsize n = pptr() - pbase();
if(n)
{
- buf.replace(rpos, string::npos, pbase(), n);
+ buf.replace(rpos, std::string::npos, pbase(), n);
//if(buf.size() - rpos != n)
if (buf.size() != n + rpos)
return EOF;
if(ch != EOF)
{
- string::size_type oldSize = buf.size();
-
- buf.replace(rpos, string::npos, 1, ch);
+ std::string::size_type oldSize = buf.size();
+
+ buf.replace(rpos, std::string::npos, 1, ch);
if(buf.size() - oldSize != 1)
return EOF;
++rpos;
{
return EOF;
}
-
- string::size_type n = egptr() - eback();
- string::size_type s;
+
+ std::string::size_type n = egptr() - eback();
+ std::string::size_type s;
s = buf.copy(eback(), n, rpos);
pbump(pbase() - pptr());