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


C++ sink函数代码示例

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


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

示例1: bz2_test

void bz2_test()
{
    std::string data("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

    ar::zip::header head;
    head.path = "zip_test.dat";
    head.encrypted = false;
    head.method = ar::zip::method::bzip2;
    head.update_time = std::time(0);
    head.file_size = static_cast<boost::uint32_t>(data.size());
    head.attributes = ar::msdos::attributes::read_only;
    head.permissions = 0123;
    head.comment = "test comment";

    io_ex::tmp_file archive;
    ar::basic_zip_file_sink<
        io_ex::dont_close_device<io_ex::tmp_file>
    > sink(io_ex::dont_close(archive));

    sink.create_entry(head);
    io_ex::blocking_write(sink, &data[0], data.size());
    sink.close();
    sink.close_archive();

    io::seek(archive, 0, BOOST_IOS::beg);

    ar::basic_zip_file_source<io_ex::tmp_file> src(archive);

    BOOST_CHECK(src.next_entry());

    check_header(head, src.header());

    std::string data2;
    io::copy(src, io::back_inserter(data2));

    BOOST_CHECK_EQUAL_COLLECTIONS(
        data.begin(), data.end(), data2.begin(), data2.end()
    );

    BOOST_CHECK(!src.next_entry());
}
开发者ID:fpelliccioni,项目名称:hamigaki,代码行数:41,代码来源:zip_bz2_test.cpp

示例2: ures_open

void RelativeDateFormat::loadDates(UErrorCode &status) {
    UResourceBundle *rb = ures_open(NULL, fLocale.getBaseName(), &status);
    LocalUResourceBundlePointer dateTimePatterns(
        ures_getByKeyWithFallback(rb,
                                  "calendar/gregorian/DateTimePatterns",
                                  (UResourceBundle*)NULL, &status));
    if(U_SUCCESS(status)) {
        int32_t patternsSize = ures_getSize(dateTimePatterns.getAlias());
        if (patternsSize > kDateTime) {
            int32_t resStrLen = 0;
            int32_t glueIndex = kDateTime;
            if (patternsSize >= (kDateTimeOffset + kShort + 1)) {
                int32_t offsetIncrement = (fDateStyle & ~kRelative); // Remove relative bit.
                if (offsetIncrement >= (int32_t)kFull &&
                    offsetIncrement <= (int32_t)kShortRelative) {
                    glueIndex = kDateTimeOffset + offsetIncrement;
                }
            }

            const UChar *resStr = ures_getStringByIndex(dateTimePatterns.getAlias(), glueIndex, &resStrLen, &status);
            if (U_SUCCESS(status) && resStrLen >= patItem1Len && u_strncmp(resStr,patItem1,patItem1Len)==0) {
                fCombinedHasDateAtStart = TRUE;
            }
            fCombinedFormat = new SimpleFormatter(UnicodeString(TRUE, resStr, resStrLen), 2, 2, status);
        }
    }

    // Data loading for relative names, e.g., "yesterday", "today", "tomorrow".
    fDatesLen = UDAT_DIRECTION_COUNT; // Maximum defined by data.
    fDates = (URelativeString*) uprv_malloc(sizeof(fDates[0])*fDatesLen);

    RelDateFmtDataSink sink(fDates, fDatesLen);
    ures_getAllItemsWithFallback(rb, "fields/day/relative", sink, status);

    ures_close(rb);

    if(U_FAILURE(status)) {
        fDatesLen=0;
        return;
    }
}
开发者ID:DavidCai1993,项目名称:node,代码行数:41,代码来源:reldtfmt.cpp

示例3: generate

    inline bool
    generate(OutputIterator target_sink, Expr const& xpr, Parameter const& param)
    {
        typedef spirit::traits::is_component<karma::domain, Expr> is_component;

        // report invalid expression error as early as possible
        BOOST_MPL_ASSERT_MSG(is_component::value,
            xpr_is_not_convertible_to_a_generator, 
            (OutputIterator, Expr, Parameter));

        // wrap user supplied iterator into our own output iterator
        detail::output_iterator<OutputIterator> sink(target_sink);
        
        typedef
            typename result_of::as_component<karma::domain, Expr>::type
        component;
        typedef typename component::director director;

        component c = spirit::as_component(karma::domain(), xpr);
        return director::generate(c, sink, unused, unused, param);
    }
开发者ID:BioinformaticsArchive,项目名称:MulRFRepo,代码行数:21,代码来源:generate.hpp

示例4: main

int main(int argc, char* argv[])
{ 
    eva::stopwatch watch;
    eva::queue* queue_in = new eva::queue();
    eva::queue* queue_out = new eva::queue();

    test_source source( *queue_in );
    test_processor processor( *queue_in, *queue_out );
    test_sink sink( *queue_out );

    watch.start();
    sink.start();
    processor.start();
    source.start();

    sink.join();
    processor.join();
    source.join();

    std::cout << N << " events in " << watch.elapsed_ms() << " ms. " << (int)( N / watch.elapsed_s() ) << " per sec" << std::endl;
}
开发者ID:mmcilroy,项目名称:eva_cpp,代码行数:21,代码来源:test_application3.cpp

示例5: SignalReady

void UpdateDownloader::Run()
{
    // no initialization to do, so signal readiness immediately
    SignalReady();

    try
    {
      const std::wstring tmpdir = CreateUniqueTempDirectory();
      Settings::WriteConfigValue("UpdateTempDir", tmpdir);

      UpdateDownloadSink sink(*this, tmpdir);
      DownloadFile(m_appcast.DownloadURL, &sink);
      sink.Close();
      UI::NotifyUpdateDownloaded(sink.GetFilePath(), m_appcast);
    }
    catch ( ... )
    {
        UI::NotifyUpdateError();
        throw;
    }
}
开发者ID:Houd1ny,项目名称:winsparkle,代码行数:21,代码来源:updatedownloader.cpp

示例6: init_logging

//[ example_sinks_ostream
void init_logging()
{
    boost::shared_ptr< logging::core > core = logging::core::get();

    // Create a backend and attach a couple of streams to it
    boost::shared_ptr< sinks::text_ostream_backend > backend =
        boost::make_shared< sinks::text_ostream_backend >();
    backend->add_stream(
        boost::shared_ptr< std::ostream >(&std::clog, boost::empty_deleter()));
    backend->add_stream(
        boost::shared_ptr< std::ostream >(new std::ofstream("sample.log")));

    // Enable auto-flushing after each log record written
    backend->auto_flush(true);

    // Wrap it into the frontend and register in the core.
    // The backend requires synchronization in the frontend.
    typedef sinks::synchronous_sink< sinks::text_ostream_backend > sink_t;
    boost::shared_ptr< sink_t > sink(new sink_t(backend));
    core->add_sink(sink);
}
开发者ID:AlexMioMio,项目名称:boost,代码行数:22,代码来源:sinks_ostream.cpp

示例7: source

QVariantMap QgsOrderByExpressionAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
  std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
  if ( !source )
    throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) );

  QString expressionString = parameterAsExpression( parameters, QStringLiteral( "EXPRESSION" ), context );

  bool ascending = parameterAsBoolean( parameters, QStringLiteral( "ASCENDING" ), context );
  bool nullsFirst = parameterAsBoolean( parameters, QStringLiteral( "NULLS_FIRST" ), context );

  QString sinkId;
  std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, sinkId, source->fields(), source->wkbType(), source->sourceCrs() ) );
  if ( !sink )
    throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) );

  long count = source->featureCount();
  double step = count > 0 ? 100.0 / count : 1;
  int current = 0;

  QgsFeatureRequest request;
  request.addOrderBy( expressionString, ascending, nullsFirst );

  QgsFeature inFeature;
  QgsFeatureIterator features = source->getFeatures( request, QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks );
  while ( features.nextFeature( inFeature ) )
  {
    if ( feedback->isCanceled() )
    {
      break;
    }
    sink->addFeature( inFeature );
    feedback->setProgress( current * step );
    current++;
  }

  QVariantMap outputs;
  outputs.insert( QStringLiteral( "OUTPUT" ), sinkId );
  return outputs;
}
开发者ID:alexbruy,项目名称:QGIS,代码行数:40,代码来源:qgsalgorithmorderbyexpression.cpp

示例8: squash_gipfeli_decompress_buffer

static SquashStatus
squash_gipfeli_decompress_buffer (SquashCodec* codec,
                                  size_t* decompressed_length,
                                  uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)],
                                  size_t compressed_length,
                                  const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_length)],
                                  SquashOptions* options) {
  util::compression::Compressor* compressor =
    util::compression::NewGipfeliCompressor();
  util::compression::UncheckedByteArraySink sink((char*) decompressed);
  util::compression::ByteArraySource source((const char*) compressed, compressed_length);
  SquashStatus res = SQUASH_OK;

  if (compressor == NULL)
    return squash_error (SQUASH_MEMORY);

  std::string compressed_str((const char*) compressed, compressed_length);
  size_t uncompressed_length;
  if (!compressor->GetUncompressedLength (compressed_str, &uncompressed_length)) {
    res = squash_error (SQUASH_FAILED);
    goto cleanup;
  }

  if (uncompressed_length > *decompressed_length) {
    res = squash_error (SQUASH_BUFFER_FULL);
    goto cleanup;
  } else {
    *decompressed_length = uncompressed_length;
  }

  if (!compressor->UncompressStream (&source, &sink)) {
    res = squash_error (SQUASH_FAILED);
  }

 cleanup:

  delete compressor;

  return res;
}
开发者ID:wolut,项目名称:squash,代码行数:40,代码来源:squash-gipfeli.cpp

示例9: main

////////////////////////////////////////////////////////////////////////////
//  Main program
////////////////////////////////////////////////////////////////////////////
int
main()
{
    std::cout << "/////////////////////////////////////////////////////////\n\n";
    std::cout << "\tPrinting integers in a matrix using Spirit...\n\n";
    std::cout << "/////////////////////////////////////////////////////////\n\n";

    // here we put the data to generate
    std::vector<std::vector<int> > v;

    // now, generate the size and the contents for the matrix
    std::srand((unsigned int)std::time(NULL));
    std::size_t rows = std::rand() / (RAND_MAX / 10);
    std::size_t columns = std::rand() / (RAND_MAX / 10);

    v.resize(rows);
    for (std::size_t row = 0; row < rows; ++row)
    {
        v[row].resize(columns);
        std::generate(v[row].begin(), v[row].end(), std::rand);
    }

    // ok, we got the matrix, now print it out
    std::string generated;
    std::back_insert_iterator<std::string> sink(generated);
    if (!client::generate_matrix(sink, v))
    {
        std::cout << "-------------------------\n";
        std::cout << "Generating failed\n";
        std::cout << "-------------------------\n";
    }
    else
    {
        std::cout << "-------------------------\n";
        std::cout << "Generated:\n" << generated << "\n";
        std::cout << "-------------------------\n";
    }

    return 0;
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:43,代码来源:num_matrix.cpp

示例10: main5

int main5 (int argc, char *argv[])
{
    zmq::context_t context (1);

    //  Socket to send messages on
    zmq::socket_t  sender(context, ZMQ_PUSH);
    sender.bind("tcp://*:5557");

    std::cout << "Press Enter when the workers are ready: " << std::endl;
    getchar ();
    std::cout << "Sending tasks to workers...\n" << std::endl;

    //  The first message is "0" and signals start of batch
    zmq::socket_t sink(context, ZMQ_PUSH);
    sink.connect("tcp://localhost:5558");
    zmq::message_t message(2);
    memcpy(message.data(), "0", 1);
    sink.send(message);

    //  Initialize random number generator
    srand ((unsigned) time (NULL));

    //  Send 100 tasks
    int task_nbr;
    int total_msec = 0;     //  Total expected cost in msecs
    for (task_nbr = 0; task_nbr < 100; task_nbr++) {
        int workload;
        //  Random workload from 1 to 100msecs
        workload = within (100) + 1;
        total_msec += workload;

		message.rebuild(10);
		sprintf ((char *) message.data(), "%d", workload);
		sender.send(message);
    }
    std::cout << "Total expected cost: " << total_msec << " msec" << std::endl;
    s_sleep (1);              //  Give 0MQ time to deliver

    return 0;
}
开发者ID:huangjunfeng2000,项目名称:ZeroMQ,代码行数:40,代码来源:taskvent.cpp

示例11: main

int main () {
    zmq::context_t context(1);

    //  First allow 0MQ to set the identity
    zmq::socket_t sink(context, ZMQ_XREP);
    sink.bind( "inproc://example");

    zmq::socket_t anonymous(context, ZMQ_REQ);
    anonymous.connect( "inproc://example");
    
	s_send (anonymous, "XREP uses a generated UUID");
    s_dump (sink);

    zmq::socket_t identified (context, ZMQ_REQ);
    identified.setsockopt( ZMQ_IDENTITY, "Hello", 5);
    identified.connect( "inproc://example");
    
    s_send (identified, "XREP socket uses REQ's socket identity");
    s_dump (sink);

    return 0;
}
开发者ID:bosoxbill,项目名称:zguide,代码行数:22,代码来源:identity.cpp

示例12: sink

void CLog::add_text_file_sink_unorder()
{
	boost::shared_ptr< sinks::text_file_backend > file_backend = boost::make_shared< sinks::text_file_backend >(
		keywords::file_name = "log_%Y-%m-%d_%H-%M-%S_%N.txt",
		keywords::rotation_size = setting_.max_file_size_,

		// 시점 (일 변경시)
		keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0),

		// 주기 (1분마다)
		// keywords::time_based_rotation = sinks::file::rotation_at_time_interval(boost::posix_time::minutes(1)),

		keywords::format = "[%TimeStamp%] (%Severity%) : %Message%",
		keywords::min_free_space= setting_.max_storage_size_ + setting_.max_file_size_
		);

	file_backend->auto_flush(true);

	typedef sinks::asynchronous_sink< sinks::text_file_backend > sink_t;
	boost::shared_ptr< sink_t > sink(new sink_t(file_backend));

	sink->set_formatter(
		expr::format("[%1%] [%2%] %3% %4%")
		% expr::attr< unsigned int >("RecordID")
		% expr::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S.%f")
		% logging::trivial::severity
		% expr::message
		);

	sink->locked_backend()->set_file_collector(
		sinks::file::make_collector(
		keywords::target = "logs",
		keywords::max_size = setting_.max_storage_size_
		)
		);

	logging::core::get()->add_sink(sink);

}
开发者ID:FiaDot,项目名称:boost-log-test,代码行数:39,代码来源:Log.cpp

示例13: input

QVariantMap QgsExtractByLocationAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
  std::unique_ptr< QgsFeatureSource > input( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
  std::unique_ptr< QgsFeatureSource > intersectSource( parameterAsSource( parameters, QStringLiteral( "INTERSECT" ), context ) );
  const QList< int > selectedPredicates = parameterAsEnums( parameters, QStringLiteral( "PREDICATE" ), context );
  QString dest;
  std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, input->fields(), input->wkbType(), input->sourceCrs() ) );

  if ( !sink )
    return QVariantMap();

  auto addToSink = [&]( const QgsFeature & feature )
  {
    QgsFeature f = feature;
    sink->addFeature( f, QgsFeatureSink::FastInsert );
  };
  process( input.get(), intersectSource.get(), selectedPredicates, addToSink, false, feedback );

  QVariantMap results;
  results.insert( QStringLiteral( "OUTPUT" ), dest );
  return results;
}
开发者ID:giohappy,项目名称:QGIS,代码行数:22,代码来源:qgsalgorithmextractbylocation.cpp

示例14: test_dilution_scheme

void test_dilution_scheme(int const num_slice,
                          int const num_block,
                          DilutionType const type) {
  auto const name = dilution_names.at(type);
  auto const block_size = num_slice / num_block;
  std::cout << "T = " << num_slice << ", T" << name << num_block << " (Morningstar), T"
            << name << block_size << " (Other):\n\n";

  DilutionScheme dilution_scheme(num_slice, block_size, type);
  for (int b = 0; b < dilution_scheme.size(); ++b) {
    auto const blocks = dilution_scheme[b];
    std::cout << std::setw(2) << blocks.source() << " => " << std::setw(2)
              << blocks.sink() << "\n";

    for (auto const slices : blocks) {
      std::cout << "  " << std::setw(2) << slices.source() << " -> " << std::setw(2)
                << slices.sink() << "\n";
    }
  }

  std::cout << "\n\n";
}
开发者ID:maowerner,项目名称:cntr.v0.1,代码行数:22,代码来源:dilution-iterator.cpp

示例15: task1p5

void task1p5(std::ifstream & inputfile, std::ofstream & outputfile)
{
    std::string line;
    getline (inputfile,line);
    int linesize = line.size();
    std::vector<bool*> map;
    getBoolRow(map,line,linesize);
    getBoolMap(inputfile,map,linesize);
    int count ;
    int mapsize = map.size();
    for(int i =0 ; i< mapsize ; i++)
    {
        for (int j =0 ; j < linesize ; j++ ) 
        {
            if (sink(map,i,j,mapsize,linesize)) 
            {
                count++;
            }
        }
    }
    std::cout << count;
}
开发者ID:Aljaksandr,项目名称:cpp_craft_1013,代码行数:22,代码来源:main.cpp


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