close
Varianti

std::basic_stringbuf::str

Da cppreference.com.

<metanoindex/>

 
 
Ingresso / libreria di output
I / O manipolatori
C-style I / O
Buffer
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(deprecato)
Streams
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Astrazioni
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
File 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
String 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
Array 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(deprecato)
ostrstream(deprecato)
strstream(deprecato)
Tipi
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
Errore categoria interfaccia
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::basic_stringbuf
Funzioni membro pubbliche
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.
basic_stringbuf::basic_stringbuf
basic_stringbuf::operator=(C++11)
basic_stringbuf::swap(C++11)
basic_stringbuf::str
Protetto funzioni membro
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.
basic_stringbuf::underflow
basic_stringbuf::pbackfail
basic_stringbuf::overflow
basic_stringbuf::setbuf
basic_stringbuf::seekoff
basic_stringbuf::seekpos
Non membri funzioni
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap(std::basic_stringbuf)(C++11)
 
<tbody> </tbody>
std::basic_string<CharT, Traits, Allocator> str() const;
(1)
void str( const std::basic_string<CharT, Traits, Allocator>& s);
(2)
Ottiene e imposta la stringa sottostante.
Original:
Gets and sets the underlying string.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
Crea e restituisce un oggetto std::basic_string contenente una copia di questa sequenza di caratteri di base del std::basic_stringbuf. Per l'ingresso solo i flussi, la stringa restituita contiene i caratteri della [eback(), egptr()) gamma. Per i flussi di input / output o di sola scrittura, contiene i caratteri da pbase() all'ultimo carattere della sequenza, indipendentemente egptr() e epptr().
Original:
Creates and returns a std::basic_string object containing a copy of this std::basic_stringbuf's underlying character sequence. For input-only streams, the returned string contains the characters from the range [eback(), egptr()). For input/output or output-only streams, contains the characters from pbase() to the last character in the sequence regardless of egptr() and epptr().
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
Cancella l'intera sequenza di caratteri di fondo di questo std::basic_stringbuf e poi configura una nuova sequenza di caratteri di base contenente una copia del contenuto di s. I puntatori di std::basic_streambuf vengono inizializzate come segue:
Original:
Deletes the entire underlying character sequence of this std::basic_stringbuf and then configures a new underlying character sequence containing a copy of the contents of s. The pointers of std::basic_streambuf are initialized as follows:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Per i flussi di input (mode & ios_base::in == true), eback() punti al primo carattere, gptr() == eback(), e egptr() == eback() + s.size(): l'ingresso successivo leggerà il primo carattere copiato da s.
Original:
For input streams (mode & ios_base::in == true), eback() points at the first character, gptr() == eback(), and egptr() == eback() + s.size(): the subsequent input will read the first character copied from s.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Per i flussi di uscita (mode & ios_base::out == true), pbase() punti al primo carattere e epptr() >= pbase() + s.size() (epptr è consentito al punto più lontano in modo che il sputc() seguente non chiamare immediatamente overflow())
Original:
For output streams (mode & ios_base::out == true), pbase() points at the first character and epptr() >= pbase() + s.size() (epptr is allowed to point farther so that the following sputc() wouldn't immediately call overflow())
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Per i flussi di append (mode & ios_base::ate == true), pptr() == pbase() + s.size(), in modo che l'uscita successiva verrà aggiunto l'ultimo carattere copiato da s (dal C++11)
Original:
For append streams (mode & ios_base::ate == true), pptr() == pbase() + s.size(), so that subsequent output will be appended to the last character copied from s (dal C++11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Per nessun-aggiungendo i flussi in uscita, pptr() == pbase(), in modo che l'uscita successiva sovrascriverà i caratteri copiati da s.
Original:
For no-appending output streams, pptr() == pbase(), so that subsequent output will overwrite the characters copied from s.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parametri

s -
un oggetto stringa contenente la sequenza di caratteri di sostituzione
Original:
a string object holding the replacement character sequence
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Valore di ritorno

1)
Un oggetto stringa in possesso di una copia della sequenza di caratteri di fondo di questa buffer.
Original:
A string object holding a copy of this buffer's underlying character sequence.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
(Nessuno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Note

Questa funzione è in genere accessibile tramite std::basic_stringstream::str().
Original:
This function is typically accessed through std::basic_stringstream::str().
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Esempio

#include <sstream>
#include <iostream>
int main()
{
    int n;

    std::istringstream in;  // could also use in("1 2")
    in.rdbuf()->str("1 2"); // set the get area
    in >> n;
    std::cout << "after reading the first int from \"1 2\", the int is " 
              << n << ", str() = \"" << in.rdbuf()->str() << "\"\n"; // or in.str()

    std::ostringstream out("1 2");
    out << 3;
    std::cout << "after writing the int '3' to output stream \"1 2\""
              << ", str() = \"" << out.str() << "\"\n";

    std::ostringstream ate("1 2", std::ios_base::ate); // C++11
    ate << 3;
    std::cout << "after writing the int '3' to append stream \"1 2\""
              << ", str() = \"" << ate.str() << "\"\n";
}

Output:

after reading the first int from "1 2", the int is 1, str() = "1 2"
after writing the int '3' to output stream "1 2", str() = "3 2"
after writing the int '3' to append stream "1 2", str() = "1 23"

Vedi anche

ottiene o imposta il contenuto di oggetto sottostante dispositivo stringa
Original:
gets or sets the contents of underlying string device object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(metodo pubblico) [modifica]