名前空間
変種
操作

std::strstreambuf::strstreambuf

提供: cppreference.com
< cpp‎ | io‎ | strstreambuf

 
 
入力/出力ライブラリ
I / Oのマニピュレータ
CスタイルのI / O
バッファ
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(廃止予定)
ストリーム
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
抽象化
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
ファイルI / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
文字列I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
アレイのI / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream(廃止予定)
ostrstream(廃止予定)
strstream(廃止予定)
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
エラーカテゴリインターフェース
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category(C++11)
io_errc(C++11)
 
std::strstreambuf
パブリックメンバ関数
Original:
Public member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
strstreambuf::strstreambuf
strstreambuf::~strstreambuf
strstreambuf::freeze
strstreambuf::str
strstreambuf::pcount
メンバ関数を保護しました
Original:
Protected member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
strstreambuf::underflow
strstreambuf::pbackfail
strstreambuf::overflow
strstreambuf::setbuf
strstreambuf::seekoff
strstreambuf::seekpos
 
explicit strstreambuf( std::streamsize alsize = 0 );
(1)
strstreambuf( void* (*palloc)(std::size_t), void (*pfree)(void*) );
(2)
strstreambuf( char* gnext, std::streamsize n, char* pbeg = 0 );
(3)
strstreambuf( signed char* gnext, std::streamsize n, signed char* pbeg = 0 );
(4)
strstreambuf( unsigned char* gnext, std::streamsize n, unsigned char* pbeg = 0 );
(5)
strstreambuf( const char* gnext, std::streamsize n );
(6)
strstreambuf( const signed char* gnext, std::streamsize n);
(7)
strstreambuf( const unsigned char* gnext, std::streamsize n );
(8)
1) Constructs a std::strstreambuf object: initializes the base class by calling the default constructor of std::streambuf, initializes the buffer state to "dynamic" (the buffer will be allocated as needed), initializes allocated size to the provided alsize, initializes the allocation and the deallocation functions to null (will use new[] and delete[])
2) Constructs a std::strstreambuf object: initializes the base class by calling the default constructor of std::streambuf, initializes the buffer state to "dynamic" (the buffer will be allocated as needed), initializes allocated size to unspecified value, initializes the allocation function to palloc and the deallocation function to pfree
3-5) Constructs a std::strstreambuf object in following steps:
a) Initializes the base class by calling the default constructor of std::streambuf
b) Initializes the buffer state to "constant" (the buffer is a user-provided fixed-size buffer)
c) Determines the number of elements in the user-provided array as follows: if n is greater than zero, n is used. If n is zero, std::strlen(gnext) is executed to determine the buffer size. If n is negative, INT_MAX is used.
d) Configures the std::basic_streambuf pointers as follows: If pbeg is a null pointer, calls setg(gnext, gnext, gnext + N). If pbeg is not a null pointer, executes setg(gnext, gnext, pbeg) and setp(pbeg, pbeg+N), where N is the number of elements in the array as determined earlier.
6-8) Same as strstreambuf((char*)gnext, n), except the "constant" bit is set in the buffer state bitmask (output to this buffer is not allowed)

目次

[編集] パラメータ

alsize - the initial size of the dynamically allocated buffer
palloc -
ユーザー提供の割り当て関数へのポインタ
Original:
pointer to user-provided allocation function
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pfree - pointer to user-provided deallocation function
gnext - pointer to the start of the get area in the user-provided array
pbeg - pointer to the start of the put area in the user-provided array
n - the number of bytes in the get area (if pbeg is null) or in the put area (if pbeg is not null) of the user-provided array

[編集] ノート

These constructors are typically called by the constructors of std::strstream

[編集]

#include <strstream>
#include <iostream>
 
int main()
{
    std::strstreambuf dyn; // dynamic
    std::strstream dyn_s; // equivalent stream
    dyn_s << 1.23;
    std::cout << dyn_s.str() << '\n'; dyn_s.freeze(false);
 
    char buf[10];
    std::strstreambuf user(buf, 10, buf); // user-provided output buffer
    std::ostrstream user_s(buf, 10); // equivalent stream
    user_s << 1.23 << std::ends;
    std::cout << buf << '\n';
 
    std::strstreambuf lit("1 2 3", 5); // constant
    std::istrstream lit_s("1 2 3"); // equivalent stream
    int i, j, k;
    lit_s >> i >> j >> k;
    std::cout << i << ' ' << j << ' ' << k << '\n';
}

Output:

1.23
1.23
1 2 3

[編集] も参照してください

必要に応じてバッファを割り当て、strstreamを構築します
Original:
constructs an strstream, optionally allocating the buffer
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数of std::strstream)