std::basic_stringbuf::str
Da cppreference.com.
< cpp | io | basic stringbuf
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
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.
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.
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.
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 froms
.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 immediatamenteoverflow()
)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 followingsputc()
wouldn't immediately calloverflow()
)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 froms
(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 froms
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
Indice |
[modifica] 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. |
[modifica] 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.
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.
You can help to correct and verify the translation. Click here for instructions.
[modifica] 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.
You can help to correct and verify the translation. Click here for instructions.
[modifica] 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"
[modifica] 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) |