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


C++ std::ostream类代码示例

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


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

示例1: sintoxml

void sintoxml(std::ostream& s, const char* filename, sinparms& sp)
{
  std::ifstream f(filename);
  if (!f.is_open()) {
    throw std::runtime_error("Unable to open SIN file for XML conversion");
  }

  pugi::xml_document doc;
  pugi::xml_node root = doc.append_child();
  root.set_name("philips");

  std::string line;
  const size_t buffer_size = 4096;
  char buffer[buffer_size];
  while (!f.eof()) {
    f.getline(buffer,buffer_size);
    std::string line(buffer);
    std::stringstream s;
    uint16_t idx1, idx2, idx3;
    char tmp;
    std::string parameter_name;
    std::string parameter_value;
    if (line.find(':') != std::string::npos && isdigit(line[1])) {
	  boost::algorithm::trim_right(line);
	  s << line;
	  s >> idx1; s >> idx2; s >> idx3; s >> tmp;
      s >> parameter_name;
      
      pugi::xml_node parm = root.append_child(parameter_name.c_str());
      pugi::xml_attribute attr_idx1 = parm.append_attribute("idx1");
      attr_idx1.set_value(idx1);
      pugi::xml_attribute attr_idx2 = parm.append_attribute("idx2");
      attr_idx2.set_value(idx2);
      pugi::xml_attribute attr_idx3 = parm.append_attribute("idx3");
      attr_idx3.set_value(idx3);
      s >> tmp;

      bool get_nchan = false;
      float pda[2];
      bool get_pda = false;
      int pda_comp = 0;
      if (parameter_name == "enable_pda") {
	sp.ismira = false;
      } else if (parameter_name == "max_measured_channels") {
	get_nchan = true;
      } else if (parameter_name == "nr_measured_channels") {
	get_nchan = true;
      } else if (parameter_name == "pda_ampl_factors") {
	get_pda = true;
      }
      
      while (!s.eof()) {
	s >> parameter_value;

	if (get_nchan) {
	  sp.nchan = std::atoi(parameter_value.c_str());
	}

	if (get_pda) {
	  pda[pda_comp++] = std::atof(parameter_value.c_str());
      
	  if (pda_comp > 1) {
	    sp.pda_amp_factors.push_back(std::complex<float>(pda[0],pda[1]));
	    pda_comp = 0;
	  }
	}

	pugi::xml_node v = parm.append_child("value");
	v.append_child(pugi::node_pcdata).set_value(parameter_value.c_str());
      }
    }
  }
开发者ID:ismrmrd,项目名称:philips_to_ismrmrd,代码行数:72,代码来源:main.cpp

示例2: exportScore

int CsoundFile::exportScore(std::ostream &stream) const
{
  stream << score << std::endl;
  return stream.good();
}
开发者ID:hlolli,项目名称:csound,代码行数:5,代码来源:CsoundFile.cpp

示例3: format_impl

S32 LLSDXMLFormatter::format_impl(const LLSD& data, std::ostream& ostr, U32 options, U32 level) const
{
	S32 format_count = 1;
	std::string pre;
	std::string post;

	if (options & LLSDFormatter::OPTIONS_PRETTY)
	{
		for (U32 i = 0; i < level; i++)
		{
			pre += "    ";
		}
		post = "\n";
	}

	switch(data.type())
	{
	case LLSD::TypeMap:
		if (0 == data.size())
		{
			ostr << pre << "<map />" << post;
		}
		else
		{
			ostr << pre << "<map>" << post;
			LLSD::map_const_iterator iter = data.beginMap();
			LLSD::map_const_iterator end = data.endMap();
			for (; iter != end; ++iter)
			{
				ostr << pre << "<key>" << escapeString((*iter).first) << "</key>" << post;
				format_count += format_impl((*iter).second, ostr, options, level + 1);
			}
			ostr << pre <<  "</map>" << post;
		}
		break;

	case LLSD::TypeArray:
		if (0 == data.size())
		{
			ostr << pre << "<array />" << post;
		}
		else
		{
			ostr << pre << "<array>" << post;
			LLSD::array_const_iterator iter = data.beginArray();
			LLSD::array_const_iterator end = data.endArray();
			for(; iter != end; ++iter)
			{
				format_count += format_impl(*iter, ostr, options, level + 1);
			}
			ostr << pre << "</array>" << post;
		}
		break;

	case LLSD::TypeUndefined:
		ostr << pre << "<undef />" << post;
		break;

	case LLSD::TypeBoolean:
		ostr << pre << "<boolean>";
		if (mBoolAlpha || (ostr.flags() & std::ios::boolalpha))
		{
			ostr << (data.asBoolean() ? "true" : "false");
		}
		else
		{
			ostr << (data.asBoolean() ? 1 : 0);
		}
		ostr << "</boolean>" << post;
		break;

	case LLSD::TypeInteger:
		ostr << pre << "<integer>" << data.asInteger() << "</integer>" << post;
		break;

	case LLSD::TypeReal:
		ostr << pre << "<real>";
		if (mRealFormat.empty())
		{
			ostr << data.asReal();
		}
		else
		{
			formatReal(data.asReal(), ostr);
		}
		ostr << "</real>" << post;
		break;

	case LLSD::TypeUUID:
		if (data.asUUID().isNull())
		{
			ostr << pre << "<uuid />" << post;
		}
		else
		{
			ostr << pre << "<uuid>" << data.asUUID() << "</uuid>" << post;
		}
		break;

	case LLSD::TypeString:
//.........这里部分代码省略.........
开发者ID:OS-Development,项目名称:VW.Phoenix,代码行数:101,代码来源:llsdserialize_xml.cpp

示例4: saveToStream

void ChunkPillar::saveToStream(std::ostream& pillarData)
{
	// Save the heightmap
	pillarData.write(reinterpret_cast<char*>(heightMap.data()), heightMap.size() * sizeof(heightMap[0]));
}
开发者ID:1am3r,项目名称:cubicplanets,代码行数:5,代码来源:ChunkPillar.cpp

示例5: exportCommand

int CsoundFile::exportCommand(std::ostream &stream) const
{
  stream << command.c_str() << std::endl;
  return stream.good();
}
开发者ID:hlolli,项目名称:csound,代码行数:5,代码来源:CsoundFile.cpp

示例6: save

 void PeSectionHeader::save(std::ostream& os) const {
   os.write(reinterpret_cast<const char*>(&this->st), sizeof(this->st));
 }
开发者ID:Manouchehri,项目名称:Triton,代码行数:3,代码来源:peSectionHeader.cpp

示例7: write_uint16

void write_uint16(std::ostream& s, uint16_t x) {
  uint8_t buf[2];
  buf[0] = x;
  buf[1] = x >> 8;
  s.write(reinterpret_cast<char*>(buf), 2);
}
开发者ID:mbitsnbites,项目名称:libsac,代码行数:6,代码来源:file_io.cpp

示例8: install_separator

 void install_separator(std::ostream& o1, std::ostream& o2)
 {
     static custom_separator csep(o2);
     o1.rdbuf(&csep);
     o1.tie(&o2);
 }
开发者ID:CCJY,项目名称:coliru,代码行数:6,代码来源:main.cpp

示例9:

void VerifSuite_CppPrintfComp_1_t::print ( std::ostream& s ) {
#if __cplusplus >= 201103L
  if (T1.values[0]) dat_prints<104>(s, "display %h %h", T3, T2);
#endif
s.flush();
}
开发者ID:EqualInformation,项目名称:chisel,代码行数:6,代码来源:VerifSuite_CppPrintfComp_1.cpp

示例10: LogError

	void CLogger::LogError( std::ostream const & msg )
	{
		std::stringstream ss;
		ss << msg.rdbuf();
		LogError( ss.str() );
	}
开发者ID:DragonJoker,项目名称:DatabaseConnector,代码行数:6,代码来源:DatabaseLogger.cpp

示例11: write32

void write32(std::ostream &s, uint32 v) {
	uint32 t = swapEndianLong(v);
	s.write((char *)&t, 4);
}
开发者ID:JennaMalkin,项目名称:openc2e,代码行数:4,代码来源:streamutils.cpp

示例12: swrite

void swrite(std::ostream& s, std::string t) {
    int32_t len = (int32_t)t.size();
    swrite(s, len);
    s.write(t.c_str(), len);
    while (len++ % 4) s.put(0);
}
开发者ID:VTREEM,项目名称:IfcOpenShell,代码行数:6,代码来源:IfcGeomServer.cpp

示例13: writeRGBStream

        WriteResult writeRGBStream(const osg::Image& img, std::ostream &fout, const std::string& name) const
        {
            rawImageRec raw;
            raw.imagic = 0732;

            GLenum dataType = img.getDataType();

            raw.type  = dataType == GL_UNSIGNED_BYTE ? 1 :
                dataType == GL_BYTE ? 1 :
                dataType == GL_BITMAP ? 1 :
                dataType == GL_UNSIGNED_SHORT ? 2 :
                dataType == GL_SHORT ? 2 :
                dataType == GL_UNSIGNED_INT ? 4 :
                dataType == GL_INT ? 4 :
                dataType == GL_FLOAT ? 4 :
                dataType == GL_UNSIGNED_BYTE_3_3_2 ? 1 :
                dataType == GL_UNSIGNED_BYTE_2_3_3_REV ? 1 :
                dataType == GL_UNSIGNED_SHORT_5_6_5 ? 2 :
                dataType == GL_UNSIGNED_SHORT_5_6_5_REV ? 2 :
                dataType == GL_UNSIGNED_SHORT_4_4_4_4 ? 2 :
                dataType == GL_UNSIGNED_SHORT_4_4_4_4_REV ? 2 :
                dataType == GL_UNSIGNED_SHORT_5_5_5_1 ? 2 :
                dataType == GL_UNSIGNED_SHORT_1_5_5_5_REV ? 2 :
                dataType == GL_UNSIGNED_INT_8_8_8_8 ? 4 :
                dataType == GL_UNSIGNED_INT_8_8_8_8_REV ? 4 :
                dataType == GL_UNSIGNED_INT_10_10_10_2 ? 4 :
                dataType == GL_UNSIGNED_INT_2_10_10_10_REV ? 4 : 4;

            GLenum pixelFormat = img.getPixelFormat();

            raw.dim    = 3;
            raw.sizeX = img.s();
            raw.sizeY = img.t();
            raw.sizeZ =
                pixelFormat == GL_COLOR_INDEX? 1 :
                pixelFormat == GL_RED? 1 :
                pixelFormat == GL_GREEN? 1 :
                pixelFormat == GL_BLUE? 1 :
                pixelFormat == GL_ALPHA? 1 :
                pixelFormat == GL_RGB? 3 :
                pixelFormat == GL_BGR ? 3 :
                pixelFormat == GL_RGBA? 4 :
                pixelFormat == GL_BGRA? 4 :
                pixelFormat == GL_LUMINANCE? 1 :
                pixelFormat == GL_LUMINANCE_ALPHA ? 2 : 1;
            raw.min = 0;
            raw.max = 0xFF;
            raw.wasteBytes = 0;
            strncpy( raw.name, name.c_str(), 80);
            raw.colorMap = 0;
            raw.bpc = (img.getPixelSizeInBits()/raw.sizeZ)/8;

            int isize = img.getImageSizeInBytes();
            unsigned char *buffer = new unsigned char[isize];
            if(raw.bpc == 1)
            {
                unsigned char *dptr = buffer;
                int i, j;
                for( i = 0; i < raw.sizeZ; ++i )
                {
                    const unsigned char *ptr = img.data();
                    ptr += i;
                    for( j = 0; j < isize/raw.sizeZ; ++j )
                    {
                        *(dptr++) = *ptr;
                        ptr += raw.sizeZ;
                    }
                }
            }
            else
            { // bpc == 2
                unsigned short *dptr = reinterpret_cast<unsigned short*>(buffer);
                int i, j;
                for( i = 0; i < raw.sizeZ; ++i )
                {
                    const unsigned short *ptr = reinterpret_cast<const unsigned short*>(img.data());
                    ptr += i;
                    for( j = 0; j < isize/(raw.sizeZ*2); ++j )
                    {
                        *dptr = *ptr;
                        ConvertShort(dptr++, 1);
                        ptr += raw.sizeZ;
                    }
                }
            }


            if( raw.needsBytesSwapped() )
                raw.swapBytes();

            /*
            swapBytes( raw.imagic );
            swapBytes( raw.type );
            swapBytes( raw.dim );
            swapBytes( raw.sizeX );
            swapBytes( raw.sizeY );
            swapBytes( raw.sizeZ );
            swapBytes( raw.min );
            swapBytes( raw.max );
            swapBytes( raw.colorMap );
//.........这里部分代码省略.........
开发者ID:yueying,项目名称:osg,代码行数:101,代码来源:ReaderWriterRGB.cpp

示例14: serialize

	ErrorStatus serialize(std::ostream &dst) const {
		uint16_t tmp16;

		dst.write(reinterpret_cast<const char *>(&_clientIP),
				  sizeof(_clientIP));
		if (!dst) {
			return E_FSTREAM;
		}
		dst.write(reinterpret_cast<const char *>(&_serverIP),
				  sizeof(_serverIP));
		if (!dst) {
			return E_FSTREAM;
		}
		dst.write(reinterpret_cast<const char *>(&_queryTime),
				  sizeof(_queryTime));
		if (!dst) {
			return E_FSTREAM;
		}
		dst.write(reinterpret_cast<const char *>(&_responseTime),
				  sizeof(_responseTime));
		if (!dst) {
			return E_FSTREAM;
		}
		dst.write(reinterpret_cast<const char *>(&_queryFlags),
				  sizeof(_queryFlags));
		if (!dst) {
			return E_FSTREAM;
		}
		dst.write(reinterpret_cast<const char *>(&_responseFlags),
				  sizeof(_responseFlags));
		if (!dst) {
			return E_FSTREAM;
		}
		dst.put(boost::numeric_cast<uint8_t>(_queryName.length()));
		if (!dst) {
			return E_FSTREAM;
		}
		dst.write(_queryName.data(), _queryName.length());
		if (!dst) {
			return E_FSTREAM;
		}
		dst.write(reinterpret_cast<const char *>(&_queryType),
				  sizeof(_queryType));
		if (!dst) {
			return E_FSTREAM;
		}
		tmp16 = boost::numeric_cast<uint16_t>(_responses.size());
		dst.write(reinterpret_cast<const char *>(&tmp16),
				  sizeof(tmp16));
		if (!dst) {
			return E_FSTREAM;
		}
		for (std::vector<DNSResponse*>::const_iterator it(_responses.begin());
			 it != _responses.end();
			 ++it)
		{
			dst.put(boost::numeric_cast<uint8_t>((*it)->name().length()));
			if (!dst) {
				return E_FSTREAM;
			}
			dst.write((*it)->name().data(), (*it)->name().length());
			if (!dst) {
				return E_FSTREAM;
			}
			tmp16 = (*it)->rawType();
			dst.write(reinterpret_cast<const char *>(&tmp16),
					  sizeof(tmp16));
			if (!dst) {
				return E_FSTREAM;
			}
			tmp16 = boost::numeric_cast<uint16_t>((*it)->resourceData().length());
			dst.write(reinterpret_cast<const char *>(&tmp16), sizeof(tmp16));
			if (!dst) {
				return E_FSTREAM;
			}
			dst.write((*it)->resourceData().data(), (*it)->resourceData().length());
			if (!dst) {
				return E_FSTREAM;
			}
		}

		return E_SUCCESS;
	}
开发者ID:derrick0714,项目名称:infer,代码行数:83,代码来源:DNS.hpp

示例15: finest_level

void
BoxLib::WriteGenericPlotfileHeader (std::ostream &HeaderFile,
                                    int nlevels,
				    const Array<BoxArray> &bArray,
				    const Array<std::string> &varnames,
				    const Array<Geometry> &geom,
				    Real time,
				    const Array<int> &level_steps,
				    const Array<IntVect> &ref_ratio,
				    const std::string &versionName,
				    const std::string &levelPrefix,
				    const std::string &mfPrefix)
{
        BL_PROFILE("WriteGenericPlotfileHeader()");

        BL_ASSERT(nlevels <= bArray.size());
        BL_ASSERT(nlevels <= geom.size());
        BL_ASSERT(nlevels <= ref_ratio.size()+1);
        BL_ASSERT(nlevels <= level_steps.size());

        int finest_level(nlevels - 1);

	HeaderFile.precision(17);

	VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size);
	HeaderFile.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size());

	// ---- this is the generic plot file type name
        HeaderFile << versionName << '\n';

        HeaderFile << varnames.size() << '\n';

        for (int ivar = 0; ivar < varnames.size(); ++ivar) {
	    HeaderFile << varnames[ivar] << "\n";
        }
        HeaderFile << BL_SPACEDIM << '\n';
        HeaderFile << time << '\n';
        HeaderFile << finest_level << '\n';
        for (int i = 0; i < BL_SPACEDIM; ++i) {
            HeaderFile << Geometry::ProbLo(i) << ' ';
	}
        HeaderFile << '\n';
        for (int i = 0; i < BL_SPACEDIM; ++i) {
            HeaderFile << Geometry::ProbHi(i) << ' ';
	}
        HeaderFile << '\n';
        for (int i = 0; i < finest_level; ++i) {
            HeaderFile << ref_ratio[i][0] << ' ';
	}
        HeaderFile << '\n';
	for (int i = 0; i <= finest_level; ++i) {
	    HeaderFile << geom[i].Domain() << ' ';
	}
        HeaderFile << '\n';
        for (int i = 0; i <= finest_level; ++i) {
            HeaderFile << level_steps[i] << ' ';
	}
        HeaderFile << '\n';
        for (int i = 0; i <= finest_level; ++i) {
            for (int k = 0; k < BL_SPACEDIM; ++k) {
                HeaderFile << geom[i].CellSize()[k] << ' ';
	    }
            HeaderFile << '\n';
        }
        HeaderFile << (int) Geometry::Coord() << '\n';
        HeaderFile << "0\n";

	for (int level = 0; level <= finest_level; ++level) {
	    HeaderFile << level << ' ' << bArray[level].size() << ' ' << time << '\n';
	    HeaderFile << level_steps[level] << '\n';
	    
	    for (int i = 0; i < bArray[level].size(); ++i)
	    {
		const Box &b(bArray[level][i]);
		RealBox loc = RealBox(b, geom[level].CellSize(), geom[level].ProbLo());
		for (int n = 0; n < BL_SPACEDIM; ++n) {
		    HeaderFile << loc.lo(n) << ' ' << loc.hi(n) << '\n';
		}
	    }

	    HeaderFile << MultiFabHeaderPath(level, levelPrefix, mfPrefix) << '\n';
	}
}
开发者ID:BoxLib-Codes,项目名称:BoxLib,代码行数:83,代码来源:PlotFileUtil.cpp


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