• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ostream函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ostream函数的典型用法代码示例。如果您正苦于以下问题:C++ ostream函数的具体用法?C++ ostream怎么用?C++ ostream使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ostream函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: TEST

TEST( io, local_stream )
{
    #ifndef WIN32
    {
        boost::filesystem::remove( "./test.localsocket" );
        boost::asio::local::stream_protocol::endpoint endpoint( "test.localsocket" );
        EXPECT_TRUE( !boost::asio::local::stream_protocol::iostream( endpoint ) );
        boost::asio::io_service service;
        boost::asio::local::stream_protocol::acceptor acceptor( service, endpoint );
        EXPECT_TRUE( boost::asio::local::stream_protocol::iostream( endpoint ) );
        comma::io::istream istream( "./test.localsocket" );
        comma::io::ostream ostream( "./test.localsocket" );
        istream.close();
        ostream.close();
        acceptor.close();
        EXPECT_TRUE( !boost::asio::local::stream_protocol::iostream( endpoint ) );
        EXPECT_TRUE( !boost::filesystem::is_regular_file( "./test.localsocket" ) );
        boost::filesystem::remove( "./test.localsocket" );
    }
    {
        boost::filesystem::remove( "./test.file" );
        comma::io::ostream ostream( "./test.file" );
        ostream.close();
        boost::asio::io_service service;
        boost::asio::local::stream_protocol::endpoint endpoint( "test.file" );
        try { boost::asio::local::stream_protocol::acceptor acceptor( service, endpoint ); EXPECT_TRUE( false ); } catch( ... ) {}
        boost::filesystem::remove( "./test.file" );
    }
    #endif
}
开发者ID:sheenzhaox,项目名称:comma,代码行数:30,代码来源:stream_test.cpp


示例2: qCDebug

void KGameProcessIO::sendAllMessages(QDataStream &stream,int msgid, quint32 receiver, quint32 sender, bool usermsg)
{
  qCDebug(GAMES_PRIVATE_KGAME) << "==============>  KGameProcessIO::sendMessage (usermsg="<<usermsg<<")";
  // if (!player()) return ;
  //if (!player()->isActive()) return ;

  if (usermsg)
  {
    msgid+=KGameMessage::IdUser;
  }

  qCDebug(GAMES_PRIVATE_KGAME) << "=============* ProcessIO (" << msgid << "," << receiver << "," << sender << ") ===========";

  QByteArray buffer;
  QDataStream ostream(&buffer,QIODevice::WriteOnly);
  QBuffer *device=(QBuffer *)stream.device();
  QByteArray data=device->buffer();;

  KGameMessage::createHeader(ostream,sender,receiver,msgid);
  // ostream.writeRawBytes(data.data()+device->at(),data.size()-device->at());
  ostream.writeRawData(data.data(),data.size());
  qCDebug(GAMES_PRIVATE_KGAME) << "   Adding user data from pos="<< device->pos() <<" amount=" << data.size() << "byte";
  //if (d->mMessageClient) d->mMessageClient->sendBroadcast(buffer);
  if (d->mProcessIO)
  {
    d->mProcessIO->send(buffer);
  }
}
开发者ID:alasin,项目名称:libkdegames,代码行数:28,代码来源:kgameio.cpp


示例3: ostream

void SolveVCs::checkInWhy3(){

  int counter = 0;

  for(ExprPtr e : exprs -> getExprs()){
    std :: cout << "\nWhy3 VC " << counter << "\n";

    //ExprPtr notE = Expression::mkNot(e);
    
    std::string errorMessage = ""; 
    std::string fileName = "./vcs/vc" + std::to_string(counter) + ".why";
    raw_fd_ostream ostream(fileName.c_str(), errorMessage);
    if(!errorMessage.empty()){
      errs() << "Error opening file to write VCs" << "\n";
      exit(1);
    }

    Why3Gen w3gen;
    w3gen.init();
    w3gen.addToTheory(std::to_string(counter),e);
    w3gen.prettyprintTheory(ostream);

    counter++;
  }
}
开发者ID:belolourenco,项目名称:sniper,代码行数:25,代码来源:SolveVCs.cpp


示例4: TransferProjectFile

    bool TransferProjectFile(wxString source, wxString target)
    {
        wxFileInputStream f_source(source);
        if (!f_source.Ok()) {
            wxLogMessage(wxT("Failed to read from %s"), source.c_str());
            return false;
        }
        wxFileOutputStream f_target(target);
        if (!f_target.Ok()) {
            wxLogMessage(wxT("Failed to write to %s"), target.c_str());
            return false;
        }

        wxTextInputStream istream(f_source);
        wxTextOutputStream ostream(f_target);
        for(;;) {
            wxString line = istream.ReadLine();

            if (f_source.Eof() && line.IsEmpty()) {
                break;
            }
            ostream.WriteString(line + wxT("\n"));
        }
        return true;
    }
开发者ID:niziak,项目名称:ethernut-4.9,代码行数:25,代码来源:nutconfdoc.cpp


示例5: TransferSourcesFile

    bool TransferSourcesFile(wxString source, wxString target)
    {
        wxFileInputStream f_source(source);
        if (!f_source.Ok()) {
            wxLogMessage(wxT("Failed to read from %s"), source.c_str());
            return false;
        }
        wxFileOutputStream f_target(target);
        if (!f_target.Ok()) {
            wxLogMessage(wxT("Failed to write to %s"), target.c_str());
            return false;
        }

        wxTextInputStream istream(f_source);
        wxTextOutputStream ostream(f_target);
        for(;;) {
            wxString line = istream.ReadLine();
            wxString rest;

            if (f_source.Eof() && line.IsEmpty()) {
                break;
            }
            if (line.StartsWith(wxT("..\\..\\app\\"), &rest)) {
                line = rest.AfterFirst('\\');
            }
            ostream.WriteString(line + wxT("\n"));
        }
        return true;
    }
开发者ID:niziak,项目名称:ethernut-4.9,代码行数:29,代码来源:nutconfdoc.cpp


示例6: file

/*!
 * \reimp
 */
QString UIParser::parseDisplayFile(QString filename, QMap<QString, QString> macros, bool partial)
{

    QFile file(filename);
    if (!file.open(QIODevice::ReadOnly))
        return "";

    QXmlStreamReader reader(&file);
    UI displayInfo;
    displayInfo.parse(reader);

    QString qml;
    QTextStream ostream(&qml);

    if (partial)
        displayInfo.toPartialQML(ostream);
    else
        displayInfo.toQML(ostream);

    for(auto it=macros.begin(); it != macros.end(); it++) {
        qml.replace("$("+it.key()+")", it.value());
    }

    return qml;
}
开发者ID:xiaoqiangwang,项目名称:CSDataQuick,代码行数:28,代码来源:UIParser.cpp


示例7: ostream

void util::writeFile(const std::string& file, const std::string& data) {
	std::ofstream ostream(file, std::ios::out);

	ostream << data;

	ostream.close();
}
开发者ID:Smeat,项目名称:gerber2gcode,代码行数:7,代码来源:Util.cpp


示例8: ostream

const std::string TypeUtil::getFormattedDescription(std::string &description) {
    std::string string;
    raw_string_ostream ostream(string);
    printFormattedTypeString(ostream, description, 0, description.size());
    ostream.flush();
    return string;
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:7,代码来源:TypeUtil.cpp


示例9: testXdr

  void testXdr()
  {
    ontologydto::TypeDTO* typeDTO = new ontologydto::TypeDTO(*_typeElement);
    ontology::Type type(*typeDTO);

    ontologydto::TypeDTO* otherTypeDTO = new ontologydto::TypeDTO(*_typeElement);
    ontology::Type otherType(*otherTypeDTO);

    Instance instance(type);

    std::string name("Instance name.");
    std::string otherName("other Instance name.");
    instance.setName(name);

    iostream::XdrOutputStream ostream("testfile");
    instance.encode(ostream);
    ostream.close();

    std::map <int, void*> addressMappings;
    addressMappings[(int) &type] = static_cast <void*> (&type);
    addressMappings[(int) &otherType] = static_cast <void*> (&otherType);

    iostream::XdrInputStream istream("testfile");
    Instance decodedInst(istream, addressMappings);
    istream.close();

    remove("testfile");

    assertTrue(decodedInst.getName() == name);
    assertFalse(decodedInst.getName() == otherName);
    assertTrue(&(decodedInst.getType()) == &type);
    assertFalse(&(decodedInst.getType()) == &otherType);
  }
开发者ID:williamwaterson,项目名称:protolayer,代码行数:33,代码来源:InstanceTest.hpp


示例10: istream

bool Util::copyFile(QFile *source, QFile *target)
{
    QStringList lines;
    if (source->open(IO_ReadOnly) && target->open(IO_WriteOnly)) {

        QTextStream istream(source);

        QString line;
        while (!istream.eof()) {
            line = istream.readLine();
            lines += line;
        }
        source->close();

        QTextStream ostream(target);
        for (QStringList::Iterator it = lines.begin(); it != lines.end(); ++it) {
            ostream << *it << "\n";
        }
        target->close();

        return true;
    }

    return false;
}
开发者ID:BackupTheBerlios,项目名称:poa,代码行数:25,代码来源:util.cpp


示例11: fstream

	/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
	{
		llifstream fstream(mFilename, std::ios::binary);
		if (!fstream.is_open())
		  throw AICurlNoBody(llformat("Failed to open \"%s\".", mFilename.c_str()));
		LLBufferStream ostream(channels, buffer.get());
		char tmpbuf[4096];
#ifdef SHOW_ASSERT
		size_t total_len = 0;
		fstream.seekg(0, std::ios::end);
		size_t file_size = fstream.tellg();
		fstream.seekg(0, std::ios::beg);
#endif
		while (fstream)
		{
			fstream.read(tmpbuf, sizeof(tmpbuf));
			std::streamsize len = fstream.gcount();
			if (len > 0)
			{
				ostream.write(tmpbuf, len);
#ifdef SHOW_ASSERT
				total_len += len;
#endif
			}
		}
		if (fstream.bad())
		  throw AICurlNoBody(llformat("An error occured while reading \"%s\".", mFilename.c_str()));
		fstream.close();
		ostream << std::flush;
		llassert(total_len == file_size && total_len == ostream.count_out());
		return ostream.count_out();
	}
开发者ID:diva,项目名称:SingularityViewer,代码行数:32,代码来源:llhttpclient.cpp


示例12: fOut

void modCalcEquinox::processLines( QTextStream &istream ) {
    QFile fOut( OutputFileBatch->url().toLocalFile() );
    fOut.open(QIODevice::WriteOnly);
    QTextStream ostream(&fOut);
    int originalYear = Year->value();

    //Write header to output file
    ostream << i18n("# Timing of Equinoxes and Solstices\n")
    << i18n("# computed by KStars\n#\n")
    << i18n("# Vernal Equinox\t\tSummer Solstice\t\t\tAutumnal Equinox\t\tWinter Solstice\n#\n");

    while ( ! istream.atEnd() ) {
        QString line = istream.readLine();
        bool ok = false;
        int year = line.toInt( &ok );

        //for now I will simply change the value of the Year widget to trigger
        //computation of the Equinoxes and Solstices.
        if ( ok ) {
            //triggers slotCompute(), which sets values of dSpring et al.:
            Year->setValue( year );

            //Write to output file
            ostream << 
                KGlobal::locale()->formatDate( dSpring.date(), KLocale::LongDate ) << "\t"
            << KGlobal::locale()->formatDate( dSummer.date(), KLocale::LongDate ) << "\t"
            << KGlobal::locale()->formatDate( dAutumn.date(), KLocale::LongDate ) << "\t"
            << KGlobal::locale()->formatDate( dWinter.date(), KLocale::LongDate ) << endl;
        }
    }

    if ( Year->value() != originalYear )
        Year->setValue( originalYear );
}
开发者ID:birefringence,项目名称:kstars,代码行数:34,代码来源:modcalcvizequinox.cpp


示例13: csv

int traits::run( const comma::command_line_options& options )
{
    comma::csv::options csv( options );
    csv.full_xpath = true;
    bool discard_collinear = options.exists( "--discard-collinear" );
    line_t first_default = comma::csv::ascii< line_t >().get( options.value< std::string >( "--first", "0,0,0,0,0,0" ) );
    line_t second_default = comma::csv::ascii< line_t >().get( options.value< std::string >( "--second", "0,0,0,0,0,0" ) );
    comma::csv::input_stream< lines_t > istream( std::cin, csv, std::make_pair( first_default, second_default ) );
    comma::csv::output_stream < output_t > ostream( std::cout, csv.binary(), false, csv.flush );
    comma::csv::tied< lines_t, output_t > tied( istream, ostream );
    while( istream.ready() || ( std::cin.good() && !std::cin.eof() ) )
    {
        const lines_t* r = istream.read();
        if( !r ) { break; }
        const Eigen::Vector3d& f = ( r->first.second - r->first.first ).normalized();
        const Eigen::Vector3d& s = ( r->second.second - r->second.first ).normalized();
        if( comma::math::equal( f.dot( s ), f.norm() * s.norm() ) )
        {
            if( discard_collinear ) { continue; }
            std::cerr << "points-calc: lines-nearest: got collinear lines (" << r->first.first.transpose() << " , " << r->first.second.transpose() << ") and (" << r->second.first.transpose() << " , " << r->second.second.transpose() << "), please use --discard collinear to discard" << std::endl;
            return 1;
        }
        const Eigen::Vector3d& m = s.cross( f ).normalized();
        const Eigen::Vector3d& n = s.cross( m ).normalized();
        const Eigen::Vector3d& d = r->second.first - r->first.first;
        const Eigen::Vector3d& a = r->first.first + f * n.dot( d ) / n.dot( f );
        const Eigen::Vector3d& b = a + m * m.dot( d );
        tied.append( output_t( a, b ) );
    }
    return 0;
}
开发者ID:acfr,项目名称:snark,代码行数:31,代码来源:lines_nearest.cpp


示例14: ostream

	/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
	{
		LLBufferStream ostream(channels, buffer.get());
		ostream.write(mData, mSize);
		ostream << std::flush;			// Always flush a LLBufferStream when done writing to it.
		return mSize;
	}
开发者ID:diva,项目名称:SingularityViewer,代码行数:7,代码来源:llhttpclient.cpp


示例15: fOut

void modCalcDayLength::processLines( QTextStream &istream ) {
    QFile fOut( OutputFileBatch->url().toLocalFile() );
    fOut.open(QIODevice::WriteOnly);
    QTextStream ostream(&fOut);

    //Write header
    ostream << "# " << i18nc("%1 is a location on earth", "Almanac for %1", geoBatch->fullName())
    << QString("  [%1, %2]").arg(geoBatch->lng()->toDMSString()).arg(geoBatch->lat()->toDMSString()) << endl
    << "# " << i18n("computed by KStars") << endl
    << "#" << endl
    << "# Date      SRise  STran  SSet     SRiseAz      STranAlt      SSetAz     DayLen    MRise  MTran  MSet      MRiseAz      MTranAlt      MSetAz     LunarPhase" << endl
    << "#" << endl;

    QString line;
    QDate d;

    while ( ! istream.atEnd() ) {
        line = istream.readLine();
        line = line.trimmed();

        //Parse the line as a date, then compute Almanac values
        d = QDate::fromString( line );
        if ( d.isValid() ) {
            updateAlmanac( d, geoBatch );
            ostream << d.toString( Qt::ISODate ) << "  "
            << srTimeString << "  " << stTimeString << "  " << ssTimeString << "  "
            << srAzString << "  " << stAltString << "  " << ssAzString << "  "
            << daylengthString << "    "
            << mrTimeString << "  " << mtTimeString << "  " << msTimeString << "  "
            << mrAzString << "  " << mtAltString << "  " << msAzString << "  "
            << lunarphaseString << endl;
        }
    }
}
开发者ID:Bugsbane,项目名称:kstars,代码行数:34,代码来源:modcalcdaylength.cpp


示例16: main

int main( int ac, char** av )
{
    try
    {
        comma::command_line_options options( ac, av );
        if( options.exists( "--help" ) || options.exists( "-h" ) || ac == 1 ) { usage(); }        
        double d = boost::lexical_cast< double >( options.unnamed( "", "--binary,-b,--delimiter,-d,--fields,-f" )[0] );
        int sign = d < 0 ? -1 : 1;
        int minutes = int( std::floor( std::abs( d )/60 ) );
        int seconds = int( std::floor( std::abs( d ) - double(minutes) * 60 ) );
        int microseconds = int( ( std::abs( d ) - ( double(minutes) * 60 + seconds ) ) * 1000000 );
        minutes *= sign;
        seconds *= sign;
        microseconds *= sign;
        boost::posix_time::time_duration delay = boost::posix_time::minutes( minutes ) + boost::posix_time::seconds( seconds ) + boost::posix_time::microseconds( microseconds );
        comma::csv::options csv( options );
        comma::csv::input_stream< Point > istream( std::cin, csv );
        comma::csv::output_stream< Point > ostream( std::cout, csv );
        comma::signal_flag is_shutdown;
        while( !is_shutdown && std::cin.good() && !std::cin.eof() )
        {
            const Point* p = istream.read();
            if( !p ) { break; }
            Point q = *p;
            q.timestamp = p->timestamp + delay;
            if( csv.binary() ) { ostream.write( q, istream.binary().last() ); }
            else { ostream.write( q, istream.ascii().last() ); }
        }
        if( is_shutdown ) { std::cerr << "csv-time-delay: interrupted by signal" << std::endl; }
        return 0;     
    }
    catch( std::exception& ex ) { std::cerr << "csv-time-delay: " << ex.what() << std::endl; }
    catch( ... ) { std::cerr << "csv-time-delay: unknown exception" << std::endl; }
    usage();
}
开发者ID:dmitry-mikhin,项目名称:comma,代码行数:35,代码来源:csv-time-delay.cpp


示例17: saveToFile

bool saveToFile(const ROSMessage& msg, const std::string& filename, bool asBinary)
{

    std::ios_base::openmode mode;
    if (asBinary) mode = std::ios::out | std::ios::binary;
    else mode = std::ios::out;

    std::ofstream ofs(filename.c_str(), mode);

    if (!ofs.is_open())
    {
        ROS_ERROR("File %s cannot be opened.", filename.c_str());
        return false;
    }

    if (asBinary)
    {
        uint32_t serial_size = ros::serialization::serializationLength(msg);
        boost::shared_array<uint8_t> obuffer(new uint8_t[serial_size]);
        ros::serialization::OStream ostream(obuffer.get(), serial_size);
        ros::serialization::serialize(ostream, msg);
        ofs.write((char*) obuffer.get(), serial_size);
    }
    else
    {
        ofs<<msg; 
    }
    ofs.close();
    return true;
}
开发者ID:belledon,项目名称:graspit-pkgs,代码行数:30,代码来源:grasp_planning_eg_planner_client.cpp


示例18: ostream

void Configuration::error(std::string const& err, Location const* loc) const {
	std::ostream& out = ostream(Verb::ERROR);

	out << "ERROR: ";
	if (loc) out << *loc << ": ";
	out << err << std::endl;
}
开发者ID:babb517,项目名称:bcplusparser,代码行数:7,代码来源:Configuration.cpp


示例19: ostream

data_chunk alert_payload::to_data() const
{
    data_chunk data;
    boost::iostreams::stream<byte_sink<data_chunk>> ostream(data);
    to_data(ostream);
    ostream.flush();
    BITCOIN_ASSERT(data.size() == serialized_size());
    return data;
}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:9,代码来源:alert_payload.cpp


示例20: process_impl

		EStatus process_impl(const LLChannelDescriptors &channels,
							 buffer_ptr_t &buffer, bool &eos,
							 LLSD &context, LLPumpIO *pump)
		{
			LLBufferStream ostream(channels, buffer.get());
			ostream.write(mData.data(), mData.size());
			eos = true;
			return STATUS_DONE;
		}
开发者ID:9skunks,项目名称:imprudence,代码行数:9,代码来源:hipporestrequest.cpp



注:本文中的ostream函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ osync_assert函数代码示例发布时间:2022-05-30
下一篇:
C++ ossl_raise函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap