当前位置: 首页>>代码示例>>C++>>正文


C++ ostream函数代码示例

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


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


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