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


C++ ostream::write方法代码示例

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


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

示例1: write_magic

 void write_magic(ostream& os, const string& magic) {
     os.write(magic.c_str(), 4);
 }
开发者ID:tianran,项目名称:vecdcs,代码行数:3,代码来源:DAO.cpp

示例2: WriteByteOrder

 bool WriteByteOrder( ostream& o ) const { Uint8 order = 0x01234567; o.write( (const char*)&order, sizeof( order ) ); return o.good(); }
开发者ID:DmitrySigaev,项目名称:ncbi,代码行数:1,代码来源:cbitmaskbuilder.hpp

示例3: WriteData

 bool WriteData( ostream& o ) const { o.write( (const char*)m_data, sizeof( *m_data ) * m_size ); return o.good(); }
开发者ID:DmitrySigaev,项目名称:ncbi,代码行数:1,代码来源:cbitmaskbuilder.hpp

示例4:

    // string
    void operator& (string x, ostream& stream) {
	x.length() & stream;
	stream.write (x.c_str(), x.length());
    }
开发者ID:dhardy,项目名称:openmalaria,代码行数:5,代码来源:checkpoint.cpp

示例5: writeHoudiniStr

void writeHoudiniStr(ostream& ostream,const string& s)
{
    write<BIGEND>(ostream,(short)s.size());
    ostream.write(s.c_str(),s.size());
}
开发者ID:JimBae,项目名称:partio,代码行数:5,代码来源:BGEO.cpp

示例6: writeLength

void writeLength(ostream &os, short len)
{
	len = htons(len);
	os.write((char *)&len, sizeof(short));
}
开发者ID:mmanley,项目名称:Antares,代码行数:5,代码来源:IppContent.cpp

示例7: writeToFile

void Tempo::writeToFile(ostream & output) {
	MetaEvent::writeToFile(output);

	output.put((char)3); // size
	output.write(MidiUtil::intToBytes(mMPQN, 3), 3);
}
开发者ID:Geromatic,项目名称:Midi-Unreal,代码行数:6,代码来源:Tempo.cpp

示例8: write

void StreamUtils::write(ostream& os, int i) {
    os.write((char*) &i, sizeof(int));
}
开发者ID:bendem,项目名称:SchoolBoats,代码行数:3,代码来源:StreamUtils.cpp

示例9: TypeException

void aol::Vector<_DataType>::saveRaw ( ostream &out, const qc::SaveType type, const DataType Minimum, const DataType Maximum ) const {
  int i = 0;

  DataType maximum = Maximum;

  if ( ( type == qc::PGM_UNSIGNED_CHAR_BINARY || type == qc::PGM_UNSIGNED_SHORT_BINARY ) && Maximum == 0 ) {
    cerr << "Cannot scale image to a maximum of 0, scaling to 1 instead.\n";
    // This is necessary to write complete black images
    maximum = 1;
  }

  switch ( type ) {
    case qc::PGM_UNSIGNED_CHAR_ASCII: {
      aol::Vector<unsigned char> buffer ( this->_size );
      bool flag = this->createOverflowHandledData ( buffer, Minimum, maximum );
      for ( i = 0; i < this->_size; ++i ) {
        out <<  static_cast<int> ( buffer[i] ) << " ";
        if ( ( i % 10 ) == 9 ) out << std::endl;
      }
      if ( flag && !quietMode ) cerr << "warning: Data contains values < 0 that are converted to unsigned char\n";
    }
    break;

    case qc::PGM_UNSIGNED_CHAR_BINARY: {
      aol::Vector<unsigned char> buffer ( this->_size );
      bool flag = this->createOverflowHandledData ( buffer, Minimum, maximum );
      out.write ( reinterpret_cast<char*> ( buffer.getData() ), this->_size );
      if ( flag && !quietMode ) cerr << "warning: Data contains values < 0 that are converted to unsigned char\n";
    }
    break;

    case qc::PGM_FLOAT_ASCII: {
      for ( i = 0; i < this->_size; ++i ) {
        out << this->_pData[i] << " ";
        if ( ( i % 10 ) == 9 ) out << std::endl;
      }
    }
    break;

    case qc::PGM_FLOAT_BINARY: {
      if ( ( sizeof ( float ) == sizeof ( DataType ) ) && !(std::numeric_limits<DataType>::is_integer) ) {
        out.write ( reinterpret_cast<char *> ( this->_pData ), this->_size * sizeof ( float ) );
      } else {
        float * buffer = new float[this->_size];
        for ( i = 0; i < this->_size; ++i ) buffer[i] =  static_cast<float> ( this->_pData[i] );
        out.write ( reinterpret_cast<char *> ( buffer ), this->_size * sizeof ( float ) );
        delete[] buffer;
      }
    }
    break;

    case qc::PGM_DOUBLE_BINARY: {
      if ( ( sizeof ( double ) == sizeof ( DataType ) ) && !(std::numeric_limits<DataType>::is_integer) ) {
        out.write ( reinterpret_cast<char *> ( this->_pData ), this->_size * sizeof ( double ) );
      } else {
        double * buffer = new double[this->_size];
        for ( i = 0; i < this->_size; ++i ) buffer[i] =  static_cast<double> ( this->_pData[i] );
        out.write ( reinterpret_cast<char *> ( buffer ), this->_size * sizeof ( double ) );
        delete[] buffer;
      }
    }
    break;

    case qc::PGM_UNSIGNED_SHORT_BINARY: {
      bool flag = false;
      unsigned short *buffer = new unsigned short[this->_size];
      for ( i = 0; i < this->_size; ++i ) {
        DataType temp = this->_pData[i];
        if ( static_cast<double> ( temp ) < 0 ) {
          flag = true;
          // Workaround for icc (replaced - with abs)
          temp = aol::Abs ( this->_pData[i] );
        }
        buffer[i] =  static_cast<unsigned short> ( static_cast<double> ( temp ) / static_cast<double> ( maximum ) * 65535.0 );
      }
      out.write ( reinterpret_cast<char*> ( buffer ), this->_size * sizeof ( unsigned short ) );
      delete[] buffer;
      if ( flag && !this->quietMode ) cerr << "warning: Data contains values < 0 that are converted to unsigned short\n";
    }
    break;

    default:
      throw aol::TypeException ( "aol::Vector<DataType>::saveRaw: invalid type specified", __FILE__, __LINE__ );
  }


  if ( out.good() ) {
    if ( !quietMode )
      cerr << "Successfully wrote to PGM " << type << " stream\n";
  } else {
    const aol::Bzipofstream* pOut = dynamic_cast<const aol::Bzipofstream*>(&out);
    if( pOut != NULL )
      throw aol::Exception ( "aol::Vector<DataType>::saveRaw: Writing to aol::Bzipofstream failed. Is there enough free memory to hold the whole file?", __FILE__, __LINE__ );
    else
      throw aol::Exception ( "aol::Vector<DataType>::saveRaw: Error writing file", __FILE__, __LINE__ );
  }

}
开发者ID:nmevenkamp,项目名称:pcams,代码行数:98,代码来源:vec.cpp

示例10: WriteSize

void CSRFormat::WriteSize(int size,ostream &ofs)
{
    ofs.write((char*)&size,sizeof(int));
}
开发者ID:CooperLiu,项目名称:openbabel,代码行数:4,代码来源:CSRformat.cpp

示例11: out

		void Header::out(ostream & streamOut)
		{
			assert( _name[0] && _mode[0] && _uid[0] && _gid[0] && _size[0] && _mtime[0] && _magic[0] && _version[0] && _uname[0] && _gname[0] );
			if (! _chksum[0]) { checksum(); }
			streamOut.write((char *) this, sizeof(Header));
		}
开发者ID:entrity,项目名称:moviesoap,代码行数:6,代码来源:ustar.cpp

示例12: readAndWriteHeaders

void WavReader::readAndWriteHeaders(
      const std::string& name,
      istream& file,
      ostream& out,
      FormatSubchunk& formatSubchunk,
      FormatSubchunkHeader& formatSubchunkHeader) {
   RiffHeader header;
   file.read(reinterpret_cast<char*>(&header), sizeof(RiffHeader));
   // ...

   if (toString(header.id, 4) != "RIFF") {
      rLog(channel, "ERROR: %s is not a RIFF file",
         name.c_str());
      return;
   }
   if (toString(header.format, 4) != "WAVE") {
      rLog(channel, "ERROR: %s is not a wav file: %s",
         name.c_str(),
         toString(header.format, 4).c_str());
      return;
   }
   out.write(reinterpret_cast<char*>(&header), sizeof(RiffHeader));

   file.read(reinterpret_cast<char*>(&formatSubchunkHeader), 
         sizeof(FormatSubchunkHeader));

   if (toString(formatSubchunkHeader.id, 4) != "fmt ") {
      rLog(channel, "ERROR: %s expecting 'fmt' for subchunk header; got '%s'",
         name.c_str(),
         toString(formatSubchunkHeader.id, 4).c_str());
      return;
   }

   out.write(reinterpret_cast<char*>(&formatSubchunkHeader), 
         sizeof(FormatSubchunkHeader));

   file.read(reinterpret_cast<char*>(&formatSubchunk), sizeof(FormatSubchunk));

   out.write(reinterpret_cast<char*>(&formatSubchunk), sizeof(FormatSubchunk));

   rLog(channel, "format tag: %u", formatSubchunk.formatTag); // show as hex?
   rLog(channel, "samples per second: %u", formatSubchunk.samplesPerSecond);
   rLog(channel, "channels: %u", formatSubchunk.channels);
   rLog(channel, "bits per sample: %u", formatSubchunk.bitsPerSample);

   auto bytes = formatSubchunkHeader.subchunkSize - sizeof(FormatSubchunk);

   auto additionalBytes = new char[bytes];
   file.read(additionalBytes, bytes);
   out.write(additionalBytes, bytes);
   
   FactOrData factOrData;
   file.read(reinterpret_cast<char*>(&factOrData), sizeof(FactOrData));
   out.write(reinterpret_cast<char*>(&factOrData), sizeof(FactOrData));

   if (toString(factOrData.tag, 4) == "fact") {
      FactChunk factChunk;
      file.read(reinterpret_cast<char*>(&factChunk), sizeof(FactChunk));
      out.write(reinterpret_cast<char*>(&factChunk), sizeof(FactChunk));

      file.read(reinterpret_cast<char*>(&factOrData), sizeof(FactOrData));
      out.write(reinterpret_cast<char*>(&factOrData), sizeof(FactOrData));

      rLog(channel, "samples per channel: %u", factChunk.samplesPerChannel);
   }

   if (toString(factOrData.tag, 4) != "data") {
      string tag{toString(factOrData.tag, 4)};
      rLog(channel, "%s ERROR: unknown tag>%s<", name.c_str(), tag.c_str());
      return;
   }
}
开发者ID:ChiahungTai,项目名称:TDD,代码行数:72,代码来源:WavReader.cpp

示例13: Write

int FixedTextBuffer::Write(ostream & stream) {
    stream.write(Buffer, BufferSize);
    return stream.good();
}
开发者ID:atawre,项目名称:fstructure,代码行数:4,代码来源:fixtext.cpp

示例14: writeTo

//--------------------------------------------------
bool ofBuffer::writeTo(ostream & stream) const{
	if( stream.bad() ) return false;
	stream.write(&(buffer[0]),buffer.size()-1);
	return true;
}
开发者ID:prettyextreme,项目名称:openFrameworks-0.7,代码行数:6,代码来源:ofFileUtils.cpp

示例15: Write

int DelimTextBuffer::Write(ostream & stream) const{
	stream.write((char*) &bufferSize, sizeof(bufferSize));
	stream.write(buffer, bufferSize);
	return stream.good();
}
开发者ID:grachegrache,项目名称:multitab_server,代码行数:5,代码来源:deltext.cpp


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