std::strstreambuf:: overflow
|
protected
:
virtual int_type overflow ( int_type c = EOF ) ; |
(in C++98 veraltet)
(in C++26 entfernt) |
|
Fügt das Zeichen c zum Put-Bereich des Puffers hinzu, wobei bei Möglichkeit eine Neuzuweisung erfolgt.
palloc
verwendet wurde, wird diese Funktion mit
(
*
palloc
)
(
n
)
aufgerufen, wobei
n
die Anzahl der zu allokierenden Bytes angibt, andernfalls wird
new
char
[
n
]
verwendet. Wenn im Konstruktor ein Zeiger auf die Deallokierungsfunktion
pfree
verwendet wurde, wird diese Funktion mit
(
*
pfree
)
(
p
)
aufgerufen, um das vorherige Array bei Bedarf zu deallokieren, andernfalls wird
delete
[
]
p
verwendet. Wenn die Allokierung fehlschlägt, schlägt die Funktion fehl und gibt
EOF
zurück.
Inhaltsverzeichnis |
Parameter
| c | - | das Zeichen, das im Put-Bereich gespeichert werden soll |
Rückgabewert
Wenn c == EOF , wird ein Wert ungleich EOF zurückgegeben. Andernfalls wird bei Erfolg ( unsigned char ) ( c ) zurückgegeben, bei Fehlschlag EOF .
Beispiel
#include <iostream> #include <strstream> struct mybuf : std::strstreambuf { int_type overflow(int_type c) { std::cout << "Before overflow(): size of the put area is " << epptr()-pbase() << " with " << epptr()-pptr() << " write positions available\n"; int_type rc = std::strstreambuf::overflow(c); std::cout << "After overflow(): size of the put area is " << epptr()-pbase() << " with " << epptr()-pptr() << " write positions available\n"; return rc; } }; int main() { mybuf sbuf; // read-write dynamic strstreambuf std::iostream stream(&sbuf); stream << "Sufficiently long string to overflow the initial allocation, at least " << " on some systems."; }
Mögliche Ausgabe:
Before overflow(): size of the put area is 16 with 0 write positions available After overflow(): size of the put area is 32 with 15 write positions available Before overflow(): size of the put area is 32 with 0 write positions available After overflow(): size of the put area is 64 with 31 write positions available Before overflow(): size of the put area is 64 with 0 write positions available After overflow(): size of the put area is 128 with 63 write positions available
Siehe auch
|
[virtual]
|
schreibt Zeichen in die zugeordnete Ausgabesequenz aus dem Put-Bereich
(virtuelle geschützte Elementfunktion von
std::basic_streambuf<CharT,Traits>
)
|
|
[virtual]
|
hängt ein Zeichen an die Ausgabesequenz an
(virtuelle geschützte Elementfunktion von
std::basic_stringbuf<CharT,Traits,Allocator>
)
|
|
[virtual]
|
schreibt Zeichen in die zugeordnete Datei aus dem Put-Bereich
(virtuelle geschützte Elementfunktion von
std::basic_filebuf<CharT,Traits>
)
|
|
schreibt ein Zeichen in den Put-Bereich und bewegt den nächsten Zeiger
(öffentliche Elementfunktion von
std::basic_streambuf<CharT,Traits>
)
|
|
|
fügt ein Zeichen ein
(öffentliche Elementfunktion von
std::basic_ostream<CharT,Traits>
)
|