head	1.2;
access;
symbols
	perseant-exfatfs-base-20250801:1.2
	perseant-exfatfs-base-20240630:1.2
	perseant-exfatfs:1.2.0.4
	perseant-exfatfs-base:1.2
	netbsd-8-3-RELEASE:1.1.1.1
	netbsd-9-4-RELEASE:1.1.1.1
	netbsd-9-3-RELEASE:1.1.1.1
	cjep_sun2x:1.2.0.2
	cjep_sun2x-base:1.2
	cjep_staticlib_x-base1:1.2
	netbsd-9-2-RELEASE:1.1.1.1
	cjep_staticlib_x:1.1.1.1.0.38
	cjep_staticlib_x-base:1.1.1.1
	netbsd-9-1-RELEASE:1.1.1.1
	phil-wifi-20200421:1.1.1.1
	phil-wifi-20200411:1.1.1.1
	is-mlppp:1.1.1.1.0.36
	is-mlppp-base:1.1.1.1
	phil-wifi-20200406:1.1.1.1
	netbsd-8-2-RELEASE:1.1.1.1
	netbsd-9-0-RELEASE:1.1.1.1
	netbsd-9-0-RC2:1.1.1.1
	netbsd-9-0-RC1:1.1.1.1
	phil-wifi-20191119:1.1.1.1
	netbsd-9:1.1.1.1.0.34
	netbsd-9-base:1.1.1.1
	phil-wifi-20190609:1.1.1.1
	netbsd-8-1-RELEASE:1.1.1.1
	netbsd-8-1-RC1:1.1.1.1
	pgoyette-compat-merge-20190127:1.1.1.1
	pgoyette-compat-20190127:1.1.1.1
	pgoyette-compat-20190118:1.1.1.1
	pgoyette-compat-1226:1.1.1.1
	pgoyette-compat-1126:1.1.1.1
	pgoyette-compat-1020:1.1.1.1
	pgoyette-compat-0930:1.1.1.1
	pgoyette-compat-0906:1.1.1.1
	netbsd-7-2-RELEASE:1.1.1.1
	pgoyette-compat-0728:1.1.1.1
	netbsd-8-0-RELEASE:1.1.1.1
	phil-wifi:1.1.1.1.0.32
	phil-wifi-base:1.1.1.1
	pgoyette-compat-0625:1.1.1.1
	netbsd-8-0-RC2:1.1.1.1
	pgoyette-compat-0521:1.1.1.1
	pgoyette-compat-0502:1.1.1.1
	pgoyette-compat-0422:1.1.1.1
	netbsd-8-0-RC1:1.1.1.1
	pgoyette-compat-0415:1.1.1.1
	pgoyette-compat-0407:1.1.1.1
	pgoyette-compat-0330:1.1.1.1
	pgoyette-compat-0322:1.1.1.1
	pgoyette-compat-0315:1.1.1.1
	netbsd-7-1-2-RELEASE:1.1.1.1
	pgoyette-compat:1.1.1.1.0.30
	pgoyette-compat-base:1.1.1.1
	netbsd-7-1-1-RELEASE:1.1.1.1
	matt-nb8-mediatek:1.1.1.1.0.28
	matt-nb8-mediatek-base:1.1.1.1
	perseant-stdc-iso10646:1.1.1.1.0.26
	perseant-stdc-iso10646-base:1.1.1.1
	netbsd-8:1.1.1.1.0.24
	netbsd-8-base:1.1.1.1
	prg-localcount2-base3:1.1.1.1
	prg-localcount2-base2:1.1.1.1
	prg-localcount2-base1:1.1.1.1
	prg-localcount2:1.1.1.1.0.22
	prg-localcount2-base:1.1.1.1
	pgoyette-localcount-20170426:1.1.1.1
	bouyer-socketcan-base1:1.1.1.1
	pgoyette-localcount-20170320:1.1.1.1
	netbsd-7-1:1.1.1.1.0.20
	netbsd-7-1-RELEASE:1.1.1.1
	netbsd-7-1-RC2:1.1.1.1
	netbsd-7-nhusb-base-20170116:1.1.1.1
	bouyer-socketcan:1.1.1.1.0.18
	bouyer-socketcan-base:1.1.1.1
	pgoyette-localcount-20170107:1.1.1.1
	netbsd-7-1-RC1:1.1.1.1
	pgoyette-localcount-20161104:1.1.1.1
	netbsd-7-0-2-RELEASE:1.1.1.1
	localcount-20160914:1.1.1.1
	netbsd-7-nhusb:1.1.1.1.0.16
	netbsd-7-nhusb-base:1.1.1.1
	pgoyette-localcount-20160806:1.1.1.1
	pgoyette-localcount-20160726:1.1.1.1
	pgoyette-localcount:1.1.1.1.0.14
	pgoyette-localcount-base:1.1.1.1
	netbsd-7-0-1-RELEASE:1.1.1.1
	netbsd-7-0:1.1.1.1.0.12
	netbsd-7-0-RELEASE:1.1.1.1
	libcxx-245547:1.1.1.1
	netbsd-7-0-RC3:1.1.1.1
	netbsd-7-0-RC2:1.1.1.1
	netbsd-7-0-RC1:1.1.1.1
	netbsd-7:1.1.1.1.0.10
	netbsd-7-base:1.1.1.1
	libcxx-215289:1.1.1.1
	libcxx-209785:1.1.1.1
	yamt-pagecache:1.1.1.1.0.8
	libcxx-208870:1.1.1.1
	yamt-pagecache-base9:1.1.1.1
	tls-earlyentropy:1.1.1.1.0.6
	tls-earlyentropy-base:1.1.1.1
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.1
	riastradh-drm2-base3:1.1.1.1
	libcxx-198773:1.1.1.1
	libcxx-198452:1.1.1.1
	libcxx-195694:1.1.1.1
	libcxx-194207:1.1.1.1
	libcxx-188475:1.1.1.1
	riastradh-drm2-base2:1.1.1.1
	riastradh-drm2-base1:1.1.1.1
	riastradh-drm2:1.1.1.1.0.4
	riastradh-drm2-base:1.1.1.1
	libcxx-185674:1.1.1.1
	tls-maxphys-base:1.1.1.1
	tls-maxphys:1.1.1.1.0.2
	libcxx-182162:1.1.1.1
	LLVM:1.1.1;
locks; strict;
comment	@# @;


1.2
date	2021.05.30.03.26.34;	author joerg;	state dead;
branches;
next	1.1;
commitid	Z2BWNc6JrDmRz7VC;

1.1
date	2013.05.17.23.02.28;	author joerg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	5RZzZYRawlqwq2Qw;

1.1.1.1
date	2013.05.17.23.02.28;	author joerg;	state Exp;
branches
	1.1.1.1.2.1
	1.1.1.1.8.1
	1.1.1.1.38.1;
next	;
commitid	5RZzZYRawlqwq2Qw;

1.1.1.1.2.1
date	2013.05.17.23.02.28;	author tls;	state dead;
branches;
next	1.1.1.1.2.2;
commitid	OnlO1cBgtQRcIHUw;

1.1.1.1.2.2
date	2013.06.23.06.26.40;	author tls;	state Exp;
branches;
next	;
commitid	OnlO1cBgtQRcIHUw;

1.1.1.1.8.1
date	2013.05.17.23.02.28;	author yamt;	state dead;
branches;
next	1.1.1.1.8.2;
commitid	5gylMoBTXvvB7yBx;

1.1.1.1.8.2
date	2014.05.22.15.46.10;	author yamt;	state Exp;
branches;
next	;
commitid	5gylMoBTXvvB7yBx;

1.1.1.1.38.1
date	2021.05.31.22.10.15;	author cjep;	state dead;
branches;
next	;
commitid	eWz9SBW0XqKjJlVC;


desc
@@


1.2
log
@Remove old version of libc++, migrated to external/apache2/dist/libcxx
to match the rest of the mono-repo imports.
@
text
@// -*- C++ -*-
//===--------------------------- strstream --------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_STRSTREAM
#define _LIBCPP_STRSTREAM

/*
    strstream synopsis

class strstreambuf
    : public basic_streambuf<char>
{
public:
    explicit strstreambuf(streamsize alsize_arg = 0);
    strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
    strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
    strstreambuf(const char* gnext_arg, streamsize n);

    strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0);
    strstreambuf(const signed char* gnext_arg, streamsize n);
    strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);
    strstreambuf(const unsigned char* gnext_arg, streamsize n);

    strstreambuf(strstreambuf&& rhs);
    strstreambuf& operator=(strstreambuf&& rhs);

    virtual ~strstreambuf();

    void swap(strstreambuf& rhs);

    void freeze(bool freezefl = true);
    char* str();
    int pcount() const;

protected:
    virtual int_type overflow (int_type c = EOF);
    virtual int_type pbackfail(int_type c = EOF);
    virtual int_type underflow();
    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
                             ios_base::openmode which = ios_base::in | ios_base::out);
    virtual pos_type seekpos(pos_type sp,
                             ios_base::openmode which = ios_base::in | ios_base::out);
    virtual streambuf* setbuf(char* s, streamsize n);

private:
    typedef T1 strstate;                // exposition only
    static const strstate allocated;    // exposition only
    static const strstate constant;     // exposition only
    static const strstate dynamic;      // exposition only
    static const strstate frozen;       // exposition only
    strstate strmode;                   // exposition only
    streamsize alsize;                  // exposition only
    void* (*palloc)(size_t);            // exposition only
    void (*pfree)(void*);               // exposition only
};

class istrstream
    : public basic_istream<char>
{
public:
    explicit istrstream(const char* s);
    explicit istrstream(char* s);
    istrstream(const char* s, streamsize n);
    istrstream(char* s, streamsize n);

    virtual ~istrstream();

    strstreambuf* rdbuf() const;
    char *str();

private:
    strstreambuf sb; // exposition only
};

class ostrstream
    : public basic_ostream<char>
{
public:
    ostrstream();
    ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);

    virtual ~ostrstream();

    strstreambuf* rdbuf() const;
    void freeze(bool freezefl = true);
    char* str();
    int pcount() const;

private:
    strstreambuf sb; // exposition only
};

class strstream
    : public basic_iostream<char>
{
public:
    // Types
    typedef char                        char_type;
    typedef char_traits<char>::int_type int_type;
    typedef char_traits<char>::pos_type pos_type;
    typedef char_traits<char>::off_type off_type;

    // constructors/destructor
    strstream();
    strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out);

    virtual ~strstream();

    // Members:
    strstreambuf* rdbuf() const;
    void freeze(bool freezefl = true);
    int pcount() const;
    char* str();

private:
    strstreambuf sb; // exposition only
};

}  // std

*/

#include <__config>
#include <ostream>
#include <istream>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

class _LIBCPP_TYPE_VIS strstreambuf
    : public streambuf
{
public:
    explicit strstreambuf(streamsize __alsize = 0);
    strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
    strstreambuf(char* __gnext, streamsize __n, char* __pbeg = 0);
    strstreambuf(const char* __gnext, streamsize __n);

    strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = 0);
    strstreambuf(const signed char* __gnext, streamsize __n);
    strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = 0);
    strstreambuf(const unsigned char* __gnext, streamsize __n);

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    strstreambuf(strstreambuf&& __rhs);
    _LIBCPP_INLINE_VISIBILITY
    strstreambuf& operator=(strstreambuf&& __rhs);
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~strstreambuf();

    void swap(strstreambuf& __rhs);

    void freeze(bool __freezefl = true);
    char* str();
    int pcount() const;

protected:
    virtual int_type overflow (int_type __c = EOF);
    virtual int_type pbackfail(int_type __c = EOF);
    virtual int_type underflow();
    virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
                             ios_base::openmode __which = ios_base::in | ios_base::out);
    virtual pos_type seekpos(pos_type __sp,
                             ios_base::openmode __which = ios_base::in | ios_base::out);

private:
    typedef unsigned __mode_type;
    static const __mode_type __allocated = 0x01;
    static const __mode_type __constant  = 0x02;
    static const __mode_type __dynamic   = 0x04;
    static const __mode_type __frozen    = 0x08;
    static const streamsize    __default_alsize = 4096;

    __mode_type __strmode_;
    streamsize __alsize_;
    void* (*__palloc_)(size_t);
    void (*__pfree_)(void*);

    void __init(char* __gnext, streamsize __n, char* __pbeg);
};

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES

inline _LIBCPP_INLINE_VISIBILITY
strstreambuf::strstreambuf(strstreambuf&& __rhs)
    : streambuf(__rhs),
      __strmode_(__rhs.__strmode_),
      __alsize_(__rhs.__alsize_),
      __palloc_(__rhs.__palloc_),
      __pfree_(__rhs.__pfree_)
{
    __rhs.setg(nullptr, nullptr, nullptr);
    __rhs.setp(nullptr, nullptr);
}

inline _LIBCPP_INLINE_VISIBILITY
strstreambuf&
strstreambuf::operator=(strstreambuf&& __rhs)
{
    if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0)
    {
        if (__pfree_)
            __pfree_(eback());
        else
            delete [] eback();
    }
    streambuf::operator=(__rhs);
    __strmode_ = __rhs.__strmode_;
    __alsize_ = __rhs.__alsize_;
    __palloc_ = __rhs.__palloc_;
    __pfree_ = __rhs.__pfree_;
    __rhs.setg(nullptr, nullptr, nullptr);
    __rhs.setp(nullptr, nullptr);
    return *this;
}

#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

class _LIBCPP_TYPE_VIS istrstream
    : public istream
{
public:
    _LIBCPP_INLINE_VISIBILITY
    explicit istrstream(const char* __s)
        : istream(&__sb_), __sb_(__s, 0) {}
    _LIBCPP_INLINE_VISIBILITY
    explicit istrstream(char* __s)
        : istream(&__sb_), __sb_(__s, 0) {}
    _LIBCPP_INLINE_VISIBILITY
    istrstream(const char* __s, streamsize __n)
        : istream(&__sb_), __sb_(__s, __n) {}
    _LIBCPP_INLINE_VISIBILITY
    istrstream(char* __s, streamsize __n)
        : istream(&__sb_), __sb_(__s, __n) {}

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    istrstream(istrstream&& __rhs)
        : istream(_VSTD::move(__rhs)),
          __sb_(_VSTD::move(__rhs.__sb_))
    {
        istream::set_rdbuf(&__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    istrstream& operator=(istrstream&& __rhs)
    {
        istream::operator=(_VSTD::move(__rhs));
        __sb_ = _VSTD::move(__rhs.__sb_);
        return *this;
    }
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~istrstream();

    _LIBCPP_INLINE_VISIBILITY
    void swap(istrstream& __rhs)
    {
        istream::swap(__rhs);
        __sb_.swap(__rhs.__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
    _LIBCPP_INLINE_VISIBILITY
    char *str() {return __sb_.str();}

private:
    strstreambuf __sb_;
};

class _LIBCPP_TYPE_VIS ostrstream
    : public ostream
{
public:
    _LIBCPP_INLINE_VISIBILITY
    ostrstream()
        : ostream(&__sb_) {}
    _LIBCPP_INLINE_VISIBILITY
    ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
        : ostream(&__sb_),
          __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
        {}

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    ostrstream(ostrstream&& __rhs)
        : ostream(_VSTD::move(__rhs)),
          __sb_(_VSTD::move(__rhs.__sb_))
    {
        ostream::set_rdbuf(&__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    ostrstream& operator=(ostrstream&& __rhs)
    {
        ostream::operator=(_VSTD::move(__rhs));
        __sb_ = _VSTD::move(__rhs.__sb_);
        return *this;
    }
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~ostrstream();

    _LIBCPP_INLINE_VISIBILITY
    void swap(ostrstream& __rhs)
    {
        ostream::swap(__rhs);
        __sb_.swap(__rhs.__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
    _LIBCPP_INLINE_VISIBILITY
    void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
    _LIBCPP_INLINE_VISIBILITY
    char* str()         {return __sb_.str();}
    _LIBCPP_INLINE_VISIBILITY
    int pcount() const  {return __sb_.pcount();}

private:
    strstreambuf __sb_; // exposition only
};

class _LIBCPP_TYPE_VIS strstream
    : public iostream
{
public:
    // Types
    typedef char                        char_type;
    typedef char_traits<char>::int_type int_type;
    typedef char_traits<char>::pos_type pos_type;
    typedef char_traits<char>::off_type off_type;

    // constructors/destructor
    _LIBCPP_INLINE_VISIBILITY
    strstream()
        : iostream(&__sb_) {}
    _LIBCPP_INLINE_VISIBILITY
    strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
        : iostream(&__sb_),
          __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
        {}

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    strstream(strstream&& __rhs)
        : iostream(_VSTD::move(__rhs)),
          __sb_(_VSTD::move(__rhs.__sb_))
    {
        iostream::set_rdbuf(&__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    strstream& operator=(strstream&& __rhs)
    {
        iostream::operator=(_VSTD::move(__rhs));
        __sb_ = _VSTD::move(__rhs.__sb_);
        return *this;
    }
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~strstream();

    _LIBCPP_INLINE_VISIBILITY
    void swap(strstream& __rhs)
    {
        iostream::swap(__rhs);
        __sb_.swap(__rhs.__sb_);
    }

    // Members:
    _LIBCPP_INLINE_VISIBILITY
    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
    _LIBCPP_INLINE_VISIBILITY
    void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
    _LIBCPP_INLINE_VISIBILITY
    int pcount() const {return __sb_.pcount();}
    _LIBCPP_INLINE_VISIBILITY
    char* str()        {return __sb_.str();}

private:
    strstreambuf __sb_; // exposition only
};

_LIBCPP_END_NAMESPACE_STD

#endif  // _LIBCPP_STRSTREAM
@


1.1
log
@Initial revision
@
text
@@


1.1.1.1
log
@Import libc++ from http://llvm.org/svn/llvm-project, r182162.
@
text
@@


1.1.1.1.38.1
log
@sync with head
@
text
@@


1.1.1.1.8.1
log
@file strstream was added on branch yamt-pagecache on 2014-05-22 15:46:10 +0000
@
text
@d1 400
@


1.1.1.1.8.2
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@a0 400
// -*- C++ -*-
//===--------------------------- strstream --------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_STRSTREAM
#define _LIBCPP_STRSTREAM

/*
    strstream synopsis

class strstreambuf
    : public basic_streambuf<char>
{
public:
    explicit strstreambuf(streamsize alsize_arg = 0);
    strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
    strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
    strstreambuf(const char* gnext_arg, streamsize n);

    strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0);
    strstreambuf(const signed char* gnext_arg, streamsize n);
    strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);
    strstreambuf(const unsigned char* gnext_arg, streamsize n);

    strstreambuf(strstreambuf&& rhs);
    strstreambuf& operator=(strstreambuf&& rhs);

    virtual ~strstreambuf();

    void swap(strstreambuf& rhs);

    void freeze(bool freezefl = true);
    char* str();
    int pcount() const;

protected:
    virtual int_type overflow (int_type c = EOF);
    virtual int_type pbackfail(int_type c = EOF);
    virtual int_type underflow();
    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
                             ios_base::openmode which = ios_base::in | ios_base::out);
    virtual pos_type seekpos(pos_type sp,
                             ios_base::openmode which = ios_base::in | ios_base::out);
    virtual streambuf* setbuf(char* s, streamsize n);

private:
    typedef T1 strstate;                // exposition only
    static const strstate allocated;    // exposition only
    static const strstate constant;     // exposition only
    static const strstate dynamic;      // exposition only
    static const strstate frozen;       // exposition only
    strstate strmode;                   // exposition only
    streamsize alsize;                  // exposition only
    void* (*palloc)(size_t);            // exposition only
    void (*pfree)(void*);               // exposition only
};

class istrstream
    : public basic_istream<char>
{
public:
    explicit istrstream(const char* s);
    explicit istrstream(char* s);
    istrstream(const char* s, streamsize n);
    istrstream(char* s, streamsize n);

    virtual ~istrstream();

    strstreambuf* rdbuf() const;
    char *str();

private:
    strstreambuf sb; // exposition only
};

class ostrstream
    : public basic_ostream<char>
{
public:
    ostrstream();
    ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);

    virtual ~ostrstream();

    strstreambuf* rdbuf() const;
    void freeze(bool freezefl = true);
    char* str();
    int pcount() const;

private:
    strstreambuf sb; // exposition only
};

class strstream
    : public basic_iostream<char>
{
public:
    // Types
    typedef char                        char_type;
    typedef char_traits<char>::int_type int_type;
    typedef char_traits<char>::pos_type pos_type;
    typedef char_traits<char>::off_type off_type;

    // constructors/destructor
    strstream();
    strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out);

    virtual ~strstream();

    // Members:
    strstreambuf* rdbuf() const;
    void freeze(bool freezefl = true);
    int pcount() const;
    char* str();

private:
    strstreambuf sb; // exposition only
};

}  // std

*/

#include <__config>
#include <ostream>
#include <istream>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

class _LIBCPP_TYPE_VIS strstreambuf
    : public streambuf
{
public:
    explicit strstreambuf(streamsize __alsize = 0);
    strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
    strstreambuf(char* __gnext, streamsize __n, char* __pbeg = 0);
    strstreambuf(const char* __gnext, streamsize __n);

    strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = 0);
    strstreambuf(const signed char* __gnext, streamsize __n);
    strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = 0);
    strstreambuf(const unsigned char* __gnext, streamsize __n);

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    strstreambuf(strstreambuf&& __rhs);
    _LIBCPP_INLINE_VISIBILITY
    strstreambuf& operator=(strstreambuf&& __rhs);
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~strstreambuf();

    void swap(strstreambuf& __rhs);

    void freeze(bool __freezefl = true);
    char* str();
    int pcount() const;

protected:
    virtual int_type overflow (int_type __c = EOF);
    virtual int_type pbackfail(int_type __c = EOF);
    virtual int_type underflow();
    virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
                             ios_base::openmode __which = ios_base::in | ios_base::out);
    virtual pos_type seekpos(pos_type __sp,
                             ios_base::openmode __which = ios_base::in | ios_base::out);

private:
    typedef unsigned __mode_type;
    static const __mode_type __allocated = 0x01;
    static const __mode_type __constant  = 0x02;
    static const __mode_type __dynamic   = 0x04;
    static const __mode_type __frozen    = 0x08;
    static const streamsize    __default_alsize = 4096;

    __mode_type __strmode_;
    streamsize __alsize_;
    void* (*__palloc_)(size_t);
    void (*__pfree_)(void*);

    void __init(char* __gnext, streamsize __n, char* __pbeg);
};

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES

inline _LIBCPP_INLINE_VISIBILITY
strstreambuf::strstreambuf(strstreambuf&& __rhs)
    : streambuf(__rhs),
      __strmode_(__rhs.__strmode_),
      __alsize_(__rhs.__alsize_),
      __palloc_(__rhs.__palloc_),
      __pfree_(__rhs.__pfree_)
{
    __rhs.setg(nullptr, nullptr, nullptr);
    __rhs.setp(nullptr, nullptr);
}

inline _LIBCPP_INLINE_VISIBILITY
strstreambuf&
strstreambuf::operator=(strstreambuf&& __rhs)
{
    if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0)
    {
        if (__pfree_)
            __pfree_(eback());
        else
            delete [] eback();
    }
    streambuf::operator=(__rhs);
    __strmode_ = __rhs.__strmode_;
    __alsize_ = __rhs.__alsize_;
    __palloc_ = __rhs.__palloc_;
    __pfree_ = __rhs.__pfree_;
    __rhs.setg(nullptr, nullptr, nullptr);
    __rhs.setp(nullptr, nullptr);
    return *this;
}

#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

class _LIBCPP_TYPE_VIS istrstream
    : public istream
{
public:
    _LIBCPP_INLINE_VISIBILITY
    explicit istrstream(const char* __s)
        : istream(&__sb_), __sb_(__s, 0) {}
    _LIBCPP_INLINE_VISIBILITY
    explicit istrstream(char* __s)
        : istream(&__sb_), __sb_(__s, 0) {}
    _LIBCPP_INLINE_VISIBILITY
    istrstream(const char* __s, streamsize __n)
        : istream(&__sb_), __sb_(__s, __n) {}
    _LIBCPP_INLINE_VISIBILITY
    istrstream(char* __s, streamsize __n)
        : istream(&__sb_), __sb_(__s, __n) {}

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    istrstream(istrstream&& __rhs)
        : istream(_VSTD::move(__rhs)),
          __sb_(_VSTD::move(__rhs.__sb_))
    {
        istream::set_rdbuf(&__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    istrstream& operator=(istrstream&& __rhs)
    {
        istream::operator=(_VSTD::move(__rhs));
        __sb_ = _VSTD::move(__rhs.__sb_);
        return *this;
    }
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~istrstream();

    _LIBCPP_INLINE_VISIBILITY
    void swap(istrstream& __rhs)
    {
        istream::swap(__rhs);
        __sb_.swap(__rhs.__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
    _LIBCPP_INLINE_VISIBILITY
    char *str() {return __sb_.str();}

private:
    strstreambuf __sb_;
};

class _LIBCPP_TYPE_VIS ostrstream
    : public ostream
{
public:
    _LIBCPP_INLINE_VISIBILITY
    ostrstream()
        : ostream(&__sb_) {}
    _LIBCPP_INLINE_VISIBILITY
    ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
        : ostream(&__sb_),
          __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
        {}

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    ostrstream(ostrstream&& __rhs)
        : ostream(_VSTD::move(__rhs)),
          __sb_(_VSTD::move(__rhs.__sb_))
    {
        ostream::set_rdbuf(&__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    ostrstream& operator=(ostrstream&& __rhs)
    {
        ostream::operator=(_VSTD::move(__rhs));
        __sb_ = _VSTD::move(__rhs.__sb_);
        return *this;
    }
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~ostrstream();

    _LIBCPP_INLINE_VISIBILITY
    void swap(ostrstream& __rhs)
    {
        ostream::swap(__rhs);
        __sb_.swap(__rhs.__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
    _LIBCPP_INLINE_VISIBILITY
    void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
    _LIBCPP_INLINE_VISIBILITY
    char* str()         {return __sb_.str();}
    _LIBCPP_INLINE_VISIBILITY
    int pcount() const  {return __sb_.pcount();}

private:
    strstreambuf __sb_; // exposition only
};

class _LIBCPP_TYPE_VIS strstream
    : public iostream
{
public:
    // Types
    typedef char                        char_type;
    typedef char_traits<char>::int_type int_type;
    typedef char_traits<char>::pos_type pos_type;
    typedef char_traits<char>::off_type off_type;

    // constructors/destructor
    _LIBCPP_INLINE_VISIBILITY
    strstream()
        : iostream(&__sb_) {}
    _LIBCPP_INLINE_VISIBILITY
    strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
        : iostream(&__sb_),
          __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
        {}

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    strstream(strstream&& __rhs)
        : iostream(_VSTD::move(__rhs)),
          __sb_(_VSTD::move(__rhs.__sb_))
    {
        iostream::set_rdbuf(&__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    strstream& operator=(strstream&& __rhs)
    {
        iostream::operator=(_VSTD::move(__rhs));
        __sb_ = _VSTD::move(__rhs.__sb_);
        return *this;
    }
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~strstream();

    _LIBCPP_INLINE_VISIBILITY
    void swap(strstream& __rhs)
    {
        iostream::swap(__rhs);
        __sb_.swap(__rhs.__sb_);
    }

    // Members:
    _LIBCPP_INLINE_VISIBILITY
    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
    _LIBCPP_INLINE_VISIBILITY
    void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
    _LIBCPP_INLINE_VISIBILITY
    int pcount() const {return __sb_.pcount();}
    _LIBCPP_INLINE_VISIBILITY
    char* str()        {return __sb_.str();}

private:
    strstreambuf __sb_; // exposition only
};

_LIBCPP_END_NAMESPACE_STD

#endif  // _LIBCPP_STRSTREAM
@


1.1.1.1.2.1
log
@file strstream was added on branch tls-maxphys on 2013-06-23 06:26:40 +0000
@
text
@d1 400
@


1.1.1.1.2.2
log
@resync from head
@
text
@a0 400
// -*- C++ -*-
//===--------------------------- strstream --------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_STRSTREAM
#define _LIBCPP_STRSTREAM

/*
    strstream synopsis

class strstreambuf
    : public basic_streambuf<char>
{
public:
    explicit strstreambuf(streamsize alsize_arg = 0);
    strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
    strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
    strstreambuf(const char* gnext_arg, streamsize n);

    strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0);
    strstreambuf(const signed char* gnext_arg, streamsize n);
    strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);
    strstreambuf(const unsigned char* gnext_arg, streamsize n);

    strstreambuf(strstreambuf&& rhs);
    strstreambuf& operator=(strstreambuf&& rhs);

    virtual ~strstreambuf();

    void swap(strstreambuf& rhs);

    void freeze(bool freezefl = true);
    char* str();
    int pcount() const;

protected:
    virtual int_type overflow (int_type c = EOF);
    virtual int_type pbackfail(int_type c = EOF);
    virtual int_type underflow();
    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
                             ios_base::openmode which = ios_base::in | ios_base::out);
    virtual pos_type seekpos(pos_type sp,
                             ios_base::openmode which = ios_base::in | ios_base::out);
    virtual streambuf* setbuf(char* s, streamsize n);

private:
    typedef T1 strstate;                // exposition only
    static const strstate allocated;    // exposition only
    static const strstate constant;     // exposition only
    static const strstate dynamic;      // exposition only
    static const strstate frozen;       // exposition only
    strstate strmode;                   // exposition only
    streamsize alsize;                  // exposition only
    void* (*palloc)(size_t);            // exposition only
    void (*pfree)(void*);               // exposition only
};

class istrstream
    : public basic_istream<char>
{
public:
    explicit istrstream(const char* s);
    explicit istrstream(char* s);
    istrstream(const char* s, streamsize n);
    istrstream(char* s, streamsize n);

    virtual ~istrstream();

    strstreambuf* rdbuf() const;
    char *str();

private:
    strstreambuf sb; // exposition only
};

class ostrstream
    : public basic_ostream<char>
{
public:
    ostrstream();
    ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);

    virtual ~ostrstream();

    strstreambuf* rdbuf() const;
    void freeze(bool freezefl = true);
    char* str();
    int pcount() const;

private:
    strstreambuf sb; // exposition only
};

class strstream
    : public basic_iostream<char>
{
public:
    // Types
    typedef char                        char_type;
    typedef char_traits<char>::int_type int_type;
    typedef char_traits<char>::pos_type pos_type;
    typedef char_traits<char>::off_type off_type;

    // constructors/destructor
    strstream();
    strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out);

    virtual ~strstream();

    // Members:
    strstreambuf* rdbuf() const;
    void freeze(bool freezefl = true);
    int pcount() const;
    char* str();

private:
    strstreambuf sb; // exposition only
};

}  // std

*/

#include <__config>
#include <ostream>
#include <istream>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

class _LIBCPP_TYPE_VIS strstreambuf
    : public streambuf
{
public:
    explicit strstreambuf(streamsize __alsize = 0);
    strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
    strstreambuf(char* __gnext, streamsize __n, char* __pbeg = 0);
    strstreambuf(const char* __gnext, streamsize __n);

    strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = 0);
    strstreambuf(const signed char* __gnext, streamsize __n);
    strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = 0);
    strstreambuf(const unsigned char* __gnext, streamsize __n);

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    strstreambuf(strstreambuf&& __rhs);
    _LIBCPP_INLINE_VISIBILITY
    strstreambuf& operator=(strstreambuf&& __rhs);
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~strstreambuf();

    void swap(strstreambuf& __rhs);

    void freeze(bool __freezefl = true);
    char* str();
    int pcount() const;

protected:
    virtual int_type overflow (int_type __c = EOF);
    virtual int_type pbackfail(int_type __c = EOF);
    virtual int_type underflow();
    virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
                             ios_base::openmode __which = ios_base::in | ios_base::out);
    virtual pos_type seekpos(pos_type __sp,
                             ios_base::openmode __which = ios_base::in | ios_base::out);

private:
    typedef unsigned __mode_type;
    static const __mode_type __allocated = 0x01;
    static const __mode_type __constant  = 0x02;
    static const __mode_type __dynamic   = 0x04;
    static const __mode_type __frozen    = 0x08;
    static const streamsize    __default_alsize = 4096;

    __mode_type __strmode_;
    streamsize __alsize_;
    void* (*__palloc_)(size_t);
    void (*__pfree_)(void*);

    void __init(char* __gnext, streamsize __n, char* __pbeg);
};

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES

inline _LIBCPP_INLINE_VISIBILITY
strstreambuf::strstreambuf(strstreambuf&& __rhs)
    : streambuf(__rhs),
      __strmode_(__rhs.__strmode_),
      __alsize_(__rhs.__alsize_),
      __palloc_(__rhs.__palloc_),
      __pfree_(__rhs.__pfree_)
{
    __rhs.setg(nullptr, nullptr, nullptr);
    __rhs.setp(nullptr, nullptr);
}

inline _LIBCPP_INLINE_VISIBILITY
strstreambuf&
strstreambuf::operator=(strstreambuf&& __rhs)
{
    if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0)
    {
        if (__pfree_)
            __pfree_(eback());
        else
            delete [] eback();
    }
    streambuf::operator=(__rhs);
    __strmode_ = __rhs.__strmode_;
    __alsize_ = __rhs.__alsize_;
    __palloc_ = __rhs.__palloc_;
    __pfree_ = __rhs.__pfree_;
    __rhs.setg(nullptr, nullptr, nullptr);
    __rhs.setp(nullptr, nullptr);
    return *this;
}

#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

class _LIBCPP_TYPE_VIS istrstream
    : public istream
{
public:
    _LIBCPP_INLINE_VISIBILITY
    explicit istrstream(const char* __s)
        : istream(&__sb_), __sb_(__s, 0) {}
    _LIBCPP_INLINE_VISIBILITY
    explicit istrstream(char* __s)
        : istream(&__sb_), __sb_(__s, 0) {}
    _LIBCPP_INLINE_VISIBILITY
    istrstream(const char* __s, streamsize __n)
        : istream(&__sb_), __sb_(__s, __n) {}
    _LIBCPP_INLINE_VISIBILITY
    istrstream(char* __s, streamsize __n)
        : istream(&__sb_), __sb_(__s, __n) {}

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    istrstream(istrstream&& __rhs)
        : istream(_VSTD::move(__rhs)),
          __sb_(_VSTD::move(__rhs.__sb_))
    {
        istream::set_rdbuf(&__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    istrstream& operator=(istrstream&& __rhs)
    {
        istream::operator=(_VSTD::move(__rhs));
        __sb_ = _VSTD::move(__rhs.__sb_);
        return *this;
    }
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~istrstream();

    _LIBCPP_INLINE_VISIBILITY
    void swap(istrstream& __rhs)
    {
        istream::swap(__rhs);
        __sb_.swap(__rhs.__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
    _LIBCPP_INLINE_VISIBILITY
    char *str() {return __sb_.str();}

private:
    strstreambuf __sb_;
};

class _LIBCPP_TYPE_VIS ostrstream
    : public ostream
{
public:
    _LIBCPP_INLINE_VISIBILITY
    ostrstream()
        : ostream(&__sb_) {}
    _LIBCPP_INLINE_VISIBILITY
    ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
        : ostream(&__sb_),
          __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
        {}

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    ostrstream(ostrstream&& __rhs)
        : ostream(_VSTD::move(__rhs)),
          __sb_(_VSTD::move(__rhs.__sb_))
    {
        ostream::set_rdbuf(&__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    ostrstream& operator=(ostrstream&& __rhs)
    {
        ostream::operator=(_VSTD::move(__rhs));
        __sb_ = _VSTD::move(__rhs.__sb_);
        return *this;
    }
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~ostrstream();

    _LIBCPP_INLINE_VISIBILITY
    void swap(ostrstream& __rhs)
    {
        ostream::swap(__rhs);
        __sb_.swap(__rhs.__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
    _LIBCPP_INLINE_VISIBILITY
    void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
    _LIBCPP_INLINE_VISIBILITY
    char* str()         {return __sb_.str();}
    _LIBCPP_INLINE_VISIBILITY
    int pcount() const  {return __sb_.pcount();}

private:
    strstreambuf __sb_; // exposition only
};

class _LIBCPP_TYPE_VIS strstream
    : public iostream
{
public:
    // Types
    typedef char                        char_type;
    typedef char_traits<char>::int_type int_type;
    typedef char_traits<char>::pos_type pos_type;
    typedef char_traits<char>::off_type off_type;

    // constructors/destructor
    _LIBCPP_INLINE_VISIBILITY
    strstream()
        : iostream(&__sb_) {}
    _LIBCPP_INLINE_VISIBILITY
    strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
        : iostream(&__sb_),
          __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
        {}

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    _LIBCPP_INLINE_VISIBILITY
    strstream(strstream&& __rhs)
        : iostream(_VSTD::move(__rhs)),
          __sb_(_VSTD::move(__rhs.__sb_))
    {
        iostream::set_rdbuf(&__sb_);
    }

    _LIBCPP_INLINE_VISIBILITY
    strstream& operator=(strstream&& __rhs)
    {
        iostream::operator=(_VSTD::move(__rhs));
        __sb_ = _VSTD::move(__rhs.__sb_);
        return *this;
    }
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

    virtual ~strstream();

    _LIBCPP_INLINE_VISIBILITY
    void swap(strstream& __rhs)
    {
        iostream::swap(__rhs);
        __sb_.swap(__rhs.__sb_);
    }

    // Members:
    _LIBCPP_INLINE_VISIBILITY
    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
    _LIBCPP_INLINE_VISIBILITY
    void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
    _LIBCPP_INLINE_VISIBILITY
    int pcount() const {return __sb_.pcount();}
    _LIBCPP_INLINE_VISIBILITY
    char* str()        {return __sb_.str();}

private:
    strstreambuf __sb_; // exposition only
};

_LIBCPP_END_NAMESPACE_STD

#endif  // _LIBCPP_STRSTREAM
@


