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


C++ istream::rdbuf方法代码示例

本文整理汇总了C++中istream::rdbuf方法的典型用法代码示例。如果您正苦于以下问题:C++ istream::rdbuf方法的具体用法?C++ istream::rdbuf怎么用?C++ istream::rdbuf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在istream的用法示例。


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

示例1: _Bitsxstr

ChrString _Bitsxstr(istream& Is_, Subscript Num_)
{
  Boolean Changed_ = FALSE;
  ChrString Str_('\0', Num_);

  if (Num_ == PTRDIFFT_MAX)
    --Num_;

  if (_Ipfx(Is_))
  {
    int ch;
    while (0 < Num_ && (ch = Is_.rdbuf()->sbumpc()) != EOF)
      if (ch != '0' && ch != '1')
      {
	Is_.rdbuf()->sputbackc(ch);
	break;
      }
      else
      {
	Str_ += ch;
	Changed_ = TRUE;
	--Num_;
      }
  }

  if (!Changed_)
    Is_.clear(ios::failbit);

  if (!_Ipfx(Is_))
    THROW (FallibleBase::IOFailureErr());

  return Str_;
}
开发者ID:heavilessrose,项目名称:my-sync,代码行数:33,代码来源:bitsx.cpp

示例2:

void zipios::ZipFileTest::compareStreams(const std::string& entryName,
        istream &is1, istream &is2) {
    OutputStringStream buf1, buf2;
    buf1 << is1.rdbuf();
    buf2 << is2.rdbuf();
    CPPUNIT_ASSERT_MESSAGE("Streams differ for entry '"+entryName+"'",
                           buf1.str() == buf2.str());
}
开发者ID:ming81,项目名称:zipios,代码行数:8,代码来源:zipfiletest.cpp

示例3: copy

void copy( T &s, const istream &is ) {
    std::stringstream ss;
    std::streamsize at = is.rdbuf()->pubseekoff(0,is.cur);
    ss << is.rdbuf();
    is.rdbuf()->pubseekpos(at);
    auto x = ss.str();
    s.assign( x.begin(), x.end() );
}
开发者ID:r-lyeh,项目名称:tinybits,代码行数:8,代码来源:tinypipe.hpp

示例4: addAdESSignature

/**
 * Adds signature to the container.
 *
 * @param signature signature, which is added to the container.
 * @throws ContainerException throws exception if there are no documents in container.
 */
void DDoc::addAdESSignature(istream &sigdata)
{
#if USE_SIGFROMMEMORY
    stringstream ofs;
    ofs << sigdata.rdbuf();
    ofs.flush();
    int err = d->lib->f_ddocAddSignatureFromMemory(d->doc, d->filename.c_str(), ofs.str().c_str(), ofs.str().size());
    d->throwCodeError(err, "Failed to sign document", __LINE__);
    d->loadSignatures();
#else
    string fileName = File::tempFileName();
    ofstream ofs(File::encodeName(fileName).c_str());
    ofs << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n";
    ofs << "<SignedDoc format=\"DIGIDOC-XML\" version=\"1.3\" xmlns=\"http://www.sk.ee/DigiDoc/v1.3.0#\">\n";
    ofs << sigdata.rdbuf();
    ofs << "</SignedDoc>";
    ofs.flush();
    ofs.close();

    SignedDoc *sigDoc = nullptr;
    int err = d->lib->f_ddocSaxReadSignedDocFromFile( &sigDoc, fileName.c_str(), 0, 0 );
    d->throwCodeError(err, "Failed to sign document", __LINE__);

    SignatureInfo **signatures = (SignatureInfo**)realloc( d->doc->pSignatures,
        (d->doc->nSignatures + sigDoc->nSignatures) * sizeof(SignatureInfo*));
    if( !signatures )
    {
        d->lib->f_SignedDoc_free( sigDoc );
        d->throwError("Failed to sign document", __LINE__);
        return;
    }

    d->doc->pSignatures = signatures;
    for( int i = 0; i < sigDoc->nSignatures; ++i )
    {
        d->doc->pSignatures[d->doc->nSignatures + i] = sigDoc->pSignatures[i]; // take ownership
        sigDoc->pSignatures[i] = nullptr;
        // from ddocReadNewSignaturesFromDdoc
        ((char*)d->doc->pSignatures[d->doc->nSignatures + i]->pDocs[0]->szDigest)[0] = 0x0A;
    }
    d->doc->nSignatures += sigDoc->nSignatures;
    sigDoc->nSignatures = 0;

    d->lib->f_SignedDoc_free( sigDoc );
#endif
    //Force reload
    save(fileName);
    load(fileName);
}
开发者ID:open-eid,项目名称:libdigidocpp,代码行数:55,代码来源:DDoc.cpp

示例5: createJobFile

static bool createJobFile(istream &src, const string &destFile, const Args &args)
{
    Log::debug("Create job file %s", destFile.c_str());

    ofstream dest(destFile, ios::binary | ios::trunc);
    dest << "\033CUPS_BOOMAGA\n";
    dest << "JOB="     << escapeString(args.jobID)   << "\n";
    dest << "USER="    << escapeString(args.user)    << "\n";
    dest << "TITLE="   << escapeString(args.title)   << "\n";
    dest << "COUNT="   << args.count                 << "\n";
    dest << "OPTIONS=" << escapeString(args.options) << "\n";
    dest << "CUPS_BOOMAGA_DATA\n";
    dest << src.rdbuf();
    dest.close();

    if (src.bad() || !dest.good())
    {
        Log::debug("Delete file %s", destFile.c_str());
        unlink(destFile.c_str());
        Log::error("Can't create job file: %s", strerror(errno));
        return false;
    }

    if (chown(destFile.c_str(), args.pwd->pw_uid, -1) != 0)
    {
        Log::error("Can't change owner on directory %s: %s", destFile.c_str(), std::strerror(errno));
        return false;
    }

    return true;
}
开发者ID:Boomaga,项目名称:boomaga,代码行数:31,代码来源:main.cpp

示例6: safeGetline

void safeGetline(istream& is, string& t)
{
    t.clear();
    std::istream::sentry se(is, true);
    std::streambuf* sb = is.rdbuf();
    
    while (true)
    {
        int c = sb->sbumpc();
        switch (c)
        {
            case '\n':
                return;
            case '\r':
                if (sb->sgetc() == '\n')
                    sb->sbumpc();
                return;
            case EOF:
                if (t.empty())
                    is.setstate(std::ios::eofbit);
                return;
            default:
                t += (char)c;
        }
    }
}
开发者ID:Changtx,项目名称:3dRendering,代码行数:26,代码来源:calPrinDir.cpp

示例7:

	template <> _UCXXEXPORT string _readToken<char, char_traits<char> >(istream & stream)
	{
		string temp;
		char_traits<char>::int_type c;
		while(true){
			c = stream.rdbuf()->sgetc();
			if(c != char_traits<char>::eof() && isspace(c) == false){
				stream.rdbuf()->sbumpc();
				temp.append(1, char_traits<char>::to_char_type(c));
			}else{
				break;
			}
		}
		if (temp.size() == 0)
			stream.setstate(ios_base::eofbit|ios_base::failbit);

		return temp;
        }
开发者ID:wgoossens,项目名称:mb-linux-labx,代码行数:18,代码来源:istream.cpp

示例8: _Ipfx

short _Ipfx(istream& Is_, int noskip)
{
  if (Is_.good())
  {
    if (Is_.tie() != 0)
      Is_.tie()->flush();

    if (!noskip && Is_.flags() & ios::skipws)
    {
      int ch;
      while (isspace(ch = Is_.rdbuf()->sbumpc()))
	;
      if (ch != EOF)
	Is_.rdbuf()->sputbackc(ch);
    }

    if (Is_.good())
      return  1;
  }

  Is_.clear(ios::failbit);
  return 0;
}
开发者ID:heavilessrose,项目名称:my-sync,代码行数:23,代码来源:bitsx.cpp

示例9: ofs

void zipios::ZipOutputStreamTest::entryToFile(const string &ent_name, istream &is, 
					      const string &outfile,
                                              bool cerr_report) {
  ofstream ofs( outfile.c_str(), ios::out | ios::binary ) ;
  
  
  ofs << is.rdbuf() ;
  if ( cerr_report ) {
    cerr << "writing " << ent_name << " to " << outfile << endl ;
    cerr << "Stream state: "  ;
    cerr << "good() = " << is.good() << ",\t" ;
    cerr << "fail() = " << is.fail() << ",\t" ;
    cerr << "bad()  = " << is.bad()  << ",\t" ;
    cerr << "eof()  = " << is.eof()  << endl << endl;
  }
  ofs.close() ;
}
开发者ID:ming81,项目名称:zipios,代码行数:17,代码来源:zipoutputstreamtest.cpp

示例10:

bool
ios_base::sync_with_stdio(bool sync)
{
    static ios_base::Init  __make_sure_streams_are_constructed;
    static bool previous_sync = true;
    bool result = previous_sync;
    previous_sync = sync;
    cin.rdbuf()->pubsetbuf(0, !sync);
    cout.rdbuf()->pubsetbuf(0, !sync);
    clog.rdbuf()->pubsetbuf(0, !sync);
    cerr.rdbuf()->pubsetbuf(0, !sync);
#ifndef _EWL_NO_WCHART_CPP_SUPPORT
    wcin.rdbuf()->pubsetbuf(0, !sync);
    wcout.rdbuf()->pubsetbuf(0, !sync);
    wclog.rdbuf()->pubsetbuf(0, !sync);
    wcerr.rdbuf()->pubsetbuf(0, !sync);
#endif  // _EWL_NO_WCHART_CPP_SUPPORT
    return result;
}
开发者ID:reynoldsbd3,项目名称:robot-d5,代码行数:19,代码来源:ios.cpp

示例11:

//ring buffer
ring_buffer::ring_buffer(const istream& fin_) :fin(fin_.rdbuf())
{
    has_loaded_EOF=false;
    has_read_EOF=false;
    length_read=0;
    length_loaded=0;
    n_nodes=1;

    ring_buffer_node* new_node=new ring_buffer_node();
    new_node->next=new_node;
    new_node->previous=new_node;

    start_node=new_node;
    end_node=new_node;
    empty_node=new_node;

    add_nodes(2000);
    load_data();
}
开发者ID:Bhare8972,项目名称:Cyth,代码行数:20,代码来源:lexer.cpp

示例12: loadFoeData

void CommandFoeWrite::loadFoeData(
        ec_ioctl_slave_foe_t *data,
        const istream &in
        )
{
    stringstream err;
    ostringstream tmp;

    tmp << in.rdbuf();
    string const &contents = tmp.str();

    if (getVerbosity() == Verbose) {
        cerr << "Read " << contents.size() << " bytes of FoE data." << endl;
    }

    data->buffer_size = contents.size();

    if (data->buffer_size) {
        // allocate buffer and read file into buffer
        data->buffer = new uint8_t[data->buffer_size];
        contents.copy((char *) data->buffer, contents.size());
    }
}
开发者ID:BlastTNG,项目名称:flight,代码行数:23,代码来源:CommandFoeWrite.cpp

示例13: clear_error

/*
 * Clears an istream object if unusuable characters are entered. Copied from MSDN.
 */
void clear_error(istream& in)
{
	streambuf* sbpThis;
    char szTempBuf[20];
    std::streamsize nCount;

	in.clear();                 // Clear error flags
    sbpThis = in.rdbuf();       // Get streambuf pointer
    nCount = sbpThis->in_avail(); // Number of characters in buffer

    while (nCount)                // Extract them to szTempBuf
    {
        if  (nCount > 20)
        {
            sbpThis->sgetn(szTempBuf, 20);
            nCount -= 20;
        }
        else
        {
            sbpThis->sgetn(szTempBuf, nCount);
            nCount = 0;
        }
    }
}
开发者ID:nalindquist,项目名称:Programming,代码行数:27,代码来源:IOFunctions.cpp

示例14: signature

/**
 *
 * @param path
 * @throws SignatureException
 */
SignatureBES::SignatureBES(istream &sigdata, BDoc *bdoc)
 : signature(nullptr)
 , asicsignature(nullptr)
 , bdoc(bdoc)
{
    try
    {
        stringstream is;
        is << sigdata.rdbuf();
        sigdata_ = is.str();

        Properties properties;
        properties.schema_location(XADES_NAMESPACE, File::fullPathUrl(Conf::instance()->xsdPath() + "/XAdES.xsd"));
        properties.schema_location(XADESv141_NAMESPACE, File::fullPathUrl(Conf::instance()->xsdPath() + "/XAdESv141.xsd"));
        properties.schema_location(URI_ID_DSIG, File::fullPathUrl(Conf::instance()->xsdPath() + "/xmldsig-core-schema.xsd"));
        properties.schema_location(ASIC_NAMESPACE, File::fullPathUrl(Conf::instance()->xsdPath() + "/ts_102918v010201.xsd"));
        asicsignature = xAdESSignatures(is, Flags::dont_initialize, properties).release();
        if(asicsignature->signature().size() > 1)
            THROW("More than one signature in signatures.xml file is unsupported");
        if(asicsignature->signature().empty())
            THROW("Failed to parse signature XML");
        signature = &asicsignature->signature()[0];
    }
    catch(const Parsing& e)
    {
        stringstream s;
        s << e;
        THROW("Failed to parse signature XML: %s", s.str().c_str());
    }
    catch(const xsd::cxx::exception& e)
    {
        THROW("Failed to parse signature XML: %s", e.what());
    }

#if 0
    for(const ReferenceType &ref: signature->signedInfo().reference())
        if(ref.transforms().present())
            THROW("Transforms are not supported");
#endif
    const QualifyingPropertiesType::SignedPropertiesOptional &sp = qualifyingProperties().signedProperties();
    if(sp.present())
    {
        const SignedPropertiesType::SignedDataObjectPropertiesOptional &sdop = sp->signedDataObjectProperties();
        if(sdop.present())
        {
            if(!sdop->commitmentTypeIndication().empty())
                THROW("CommitmentTypeIndicationType is not supported");
            if(!sdop->allDataObjectsTimeStamp().empty())
                THROW("AllDataObjectsTimeStamp is not supported");
            if(!sdop->individualDataObjectsTimeStamp().empty())
                THROW("IndividualDataObjectsTimeStampType is not supported");
        }
    }
    const QualifyingPropertiesType::UnsignedPropertiesOptional &up = qualifyingProperties().unsignedProperties();
    if(up.present())
    {
        if(up->unsignedDataObjectProperties().present())
            THROW("UnsignedDataObjectProperties are not supported");
        const UnsignedPropertiesType::UnsignedSignaturePropertiesOptional &usp = up->unsignedSignatureProperties();
        if(usp.present())
        {
            if(!usp->counterSignature().empty())
                THROW("CounterSignature is not supported");
            if(!usp->completeCertificateRefs().empty())
                THROW("CompleteCertificateRefs are not supported");
            if(!usp->completeRevocationRefs().empty())
                THROW("CompleteRevocationRefs are not supported");
            if(!usp->attributeCertificateRefs().empty())
                THROW("AttributeCertificateRefs are not supported");
            if(!usp->attributeRevocationRefs().empty())
                THROW("AttributeRevocationRefs are not supported");
            if(!usp->sigAndRefsTimeStamp().empty())
                THROW("SigAndRefsTimeStamp is not supported");
            if(!usp->refsOnlyTimeStamp().empty())
                THROW("RefsOnlyTimeStamp is not supported");
            if(!usp->attrAuthoritiesCertValues().empty())
                THROW("AttrAuthoritiesCertValues are not supported");
            if(!usp->attributeRevocationValues().empty())
                THROW("AttributeRevocationValues are not supported");
            if(!usp->archiveTimeStamp().empty())
                THROW("ArchiveTimeStamp is not supported");
            if(!usp->timeStampValidationData().empty())
                THROW("TimeStampValidationData is not supported");
        }
    }

    // Base class has verified the signature to be valid according to XML-DSig.
    // Now perform additional checks here and throw if this signature is
    // ill-formed according to BDoc.

    getSignedSignatureProperties(); // assumed to throw in case this block doesn't exist
    signingCertificate(); // assumed to throw in case this block doesn't exist

    if(id().empty())
        THROW("Signature element mandatory attribute 'Id' is missing");
//.........这里部分代码省略.........
开发者ID:vallov,项目名称:libdigidocpp,代码行数:101,代码来源:SignatureBES.cpp

示例15: __getaline

ios::iostate __getaline( istream &istrm, char *buf, int len,
/***************************************************************/
    char delim, int is_get, int &chars_read ) {
// Read characters into buffer "buf".
// At most "len - 1" characters are read, and a 0 is added at the end.
// If "delim" is encountered, it is left in the stream and the read is
// terminated (and the NULLCHAR is added).
// Used by:
//    get( char *buf, int len, char delim )
//    getline( char *buf, int len, char delim )
//
// NOTE: Borland sets eofbit only. A full buffer just stops reading.
//       If something has been read, set eofbit anyway.
//
//       The proposed standard says to set failbit if the buffer is filled
//       without finding the delimiter (if doing a "getline"), or if a read
//       fails and no characters are extracted. It says nothing about eofbit.
//
//       Currently we set eofbit only if eof occurs on first character read.
//       failbit is set if no characters were read.
//
//       Failbit was being set (prior to Nov15,95) when len-1 characters were
//       read in the buffer.  At that time we discerned that no one else
//       was setting failbit in that case, so we stopped doing it.

    int           c;
    int           offset;
    ios::iostate  state = 0;
    streambuf    *sb;

    offset = 0;
    __lock_it( istrm.__i_lock );
    if( len > 1 && istrm.ipfx( 1 ) ) {
        sb = istrm.rdbuf();
        __lock_it( sb->__b_lock );
        len--;  // leave a space for the NULLCHAR
        while( offset < len ) {
            c = sb->speekc();
            if( c == EOF ) {
                if( offset == 0 ) {
                    state |= ios::eofbit;
                }
                break;
            }
            if( c == delim ) {
                if( !is_get ) {
                    sb->sbumpc();
                }
                break;
            }
            buf[offset++] = (char)c;
            sb->sbumpc();
        }
        istrm.isfx();
    }
    buf[offset]  = '\0';
    chars_read = offset;

    // the draft standard says that no characters is an
    // error if using get() or getline().
    // the IOStreams Handbook suggests that no characters is not
    // an error if the delim was seen, this seems to be what our
    // competitors do.
    if( (offset == 0) && (c != delim) ) {
        state |= ios::failbit;
    }
    // the draft standard says that len-1 characters is an
    // error if using getline()
    // our competitors don't agree with the draft, we won't follow the
    // draft either
    #if 0
    if( offset == len && !is_get ) {
        state |= ios::failbit;
    }
    #endif
    return( state );
}
开发者ID:kendallb,项目名称:scitech-mgl,代码行数:77,代码来源:istgalin.cpp


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