本文整理汇总了C++中std::iostream类的典型用法代码示例。如果您正苦于以下问题:C++ iostream类的具体用法?C++ iostream怎么用?C++ iostream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了iostream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: request
std::shared_ptr<Response> request(const std::string& request_type, const std::string& path, std::iostream& content,
const std::map<std::string, std::string>& header = std::map<std::string, std::string>()) {
std::string corrected_path = path;
if (corrected_path == "")
corrected_path = "/";
content.seekp(0, std::ios::end);
auto content_length = content.tellp();
content.seekp(0, std::ios::beg);
boost::asio::streambuf write_buffer;
std::ostream write_stream(&write_buffer);
write_stream << request_type << " " << corrected_path << " HTTP/1.1\r\n";
write_stream << "Host: " << host << "\r\n";
for (auto& h : header) {
write_stream << h.first << ": " << h.second << "\r\n";
}
if (content_length>0)
write_stream << "Content-Length: " << content_length << "\r\n";
write_stream << "\r\n";
if (content_length>0)
write_stream << content.rdbuf();
try {
connect();
boost::asio::write(*socket, write_buffer);
}
catch (const std::exception& e) {
socket_error = true;
throw std::invalid_argument(e.what());
}
return request_read();
}
示例2: inttostr
void Client::setResponseContentLength(Transaction& trans, std::iostream& os)
{
os.seekg(0, std::ios::end);
int os_length = os.tellg();
os_length--;
os.seekg(0, std::ios::beg);
trans.getResponse().getHeaders().setValue("CONTENT-LENGTH", inttostr(os_length));
}
示例3: save
void SkillLevelEvent::save( std::iostream& ios )
{
Event::save(ios);
// Save bonus
ios.write( (char*) &bonus, sizeof( bonus ) );
// Save skill
ios.write( (char*) &skill, sizeof( skill ) );
}
示例4: Event
SkillLevelEvent::SkillLevelEvent( std::iostream& ios )
: Event(ios)
{
// Read bonus
ios.read( (char*) &bonus, sizeof( bonus ) );
// Read skill
ios.read( (char*) &skill, sizeof( skill ) );
}
示例5: toFile
void Ammo::toFile( std::iostream& outFile )
{
// Write Item base information:
Item::toFile( outFile );
// Write char form
outFile.write( (char*) &form, sizeof(form) );
// Write bool fired
outFile.write( (char*) &fired, sizeof(fired) );
}
示例6: Item
Ammo::Ammo( std::iostream& inFile, TargetValue* TVP )
// Read Item base information:
: Item (inFile, TVP)
{
// Read char form
inFile.read( (char*) &form, sizeof(form) );
// Read bool fired
inFile.read( (char*) &fired, sizeof(fired) );
}
示例7: FillStream
void FillStream(std::iostream& strm, RawData& expression)
{
static const std::string s_smallExpression("0123456789abcdefghijklmnopqrstuvwxyz");
static const int iterationsCount = 10;
for (int i = 0; i < iterationsCount; ++i)
{
strm << s_smallExpression;
}
size_t expressionSize = iterationsCount * s_smallExpression.size();
expression.resize(expressionSize);
strm.read(reinterpret_cast<char*>(&expression[0]), expressionSize);
strm.seekg(0);
}
示例8:
gzstream::gzstream( std::iostream & strm,
unsigned int buffer_size )
: std::iostream( static_cast< std::streambuf * >( 0 ) )
, M_gzstreambuf( *(strm.rdbuf()), buffer_size )
{
this->init( &M_gzstreambuf );
}
示例9: sizeof
Event::Event( std::iostream& ios )
{
ios.read( (char*) &time, sizeof(time) );
Timeline::add( this );
}
示例10: _serialize
void _serialize(std::iostream &fs, serialization_context &context) {
assert(target > 0);
assert(context.ss.objects.count(target) > 0);
fs << target << " ";
target = 0;
assert(fs.good());
context.is_leaf = false;
}
示例11: grab_content
void grab_content(const char* file_name, std::iostream& in) {
parser p(file_name);
interpreter_DAG ipt(p.get_problem_representation(), in);
if (!in.good())
error("unexpected error");
}
示例12: Item
Fluid::Fluid( std::iostream& inFile, TargetValue* TVP )
// Read Item base information:
: Item (inFile, TVP)
{
// Read materialClass f_material
inFile.read( (char*) &f_material, sizeof(f_material) );
}
示例13: readExactly
void readExactly(size_t toread, std::iostream& result)
{
size_t hasread = 0;
while(toread > hasread && std::cin.good()) {
char a[1];
std::cin.read(a,1);
result.write(a,1);
hasread++;
}
}
示例14: toFile
void Fluid::toFile( std::iostream& outFile )
{
// Write Item base information:
Item::toFile( outFile );
// Write materialClass f_material
outFile.write( (char*) &f_material, sizeof(f_material) );
}
示例15:
/*!
*/
gzfilterstream::gzfilterstream( std::iostream & strm,
int level,
std::size_t buf_size )
: std::iostream( static_cast< std::streambuf* >( 0 ) )
, M_filter_buf( *(strm.rdbuf()), level, buf_size )
{
// std::basic_ios::init( basic_streambuf<charT,traits>* sb );
this->init( &M_filter_buf );
}