Operations related to boost: ASIO: streambuf

Source: Internet
Author: User

Boost: ASIO: streambuf is defined as follows:

Namespace boost {
Namespace ASIO {

/// Typedef for the typical usage of basic_streambuf.
Typedef basic_streambuf <> streambuf;

} // Namespace ASIO
} // Namespace boost

Basic_streambuf inherits from STD: streambuf, as follows:

Class basic_streambuf
: Public STD: streambuf,
Private noncopyable

----------------------------

STD: streambuf definition:

Typedef basic_streambuf <char> streambuf;

Internally, it is saved as a character array using the vector <char> type.

PRIVATE:
STD: size_t max_size _;
STD: vector <char_type, Allocator> buffer _;

 

Suppose response _ Is boost: ASIO: streambuf type, available

Char C1 = Response _. sgetc (); read the first character
Char C2 = Response _. snextc (); read the second character
Char C3 = Response _. snextc (); read the third character
Char C4 = Response _. snextc ();...
Char C5 = Response _. snextc ();...
Char C6 = Response _. snextc (); read the sixth character

 

How to convert it into a string:

Int size = Response _. Size (); returns the number of characters remaining.

Char buffer [size + 1];
Response _. sgetn (buffer, size );
Buffer [size] = '\ 0 ';
STD: String stemp (buffer );

You can also use another method to obtain its internal string:

STD: istream response_stream (& Response _);

Poco: streamcopier: copytostring (response_stream, result );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.