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


C++ OutputStream类代码示例

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


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

示例1: writeToStream

 void writeToStream (const ValueUnion& data, OutputStream& output) const override
 {
     output.writeCompressedInt (1 + (int) data.binaryValue->getSize());
     output.writeByte (varMarker_Binary);
     output << *data.binaryValue;
 }
开发者ID:alessandrostone,项目名称:pMix2,代码行数:6,代码来源:juce_Variant.cpp

示例2: Write

void POVMS_Object::Write(OutputStream& stream, bool append, bool compress)
{
	POVMSType encoding = kPOVMSRawStreamEncoding;
	POVMSStream headerstream[16];
	POVMSStream *objectstream = NULL;
	POVMSStream *compressedstream = NULL;
	int maxheadersize = 0;
	int maxobjectsize = 0;
	int objectsize = 0;
	int datasize = 0;

	try
	{
		objectsize = POVMSStream_Size(&data);
		if(objectsize == 0)
			throw POV_EXCEPTION_CODE(pov_base::kNullPointerErr);

		if(append == false)
		{
			datasize = 0;
			maxheadersize = 12; // header

			datasize += POVMSStream_WriteString("POVRAYMS", headerstream + datasize, &maxheadersize);              // header       8 byte
			datasize += POVMSStream_WriteInt(0x0370, headerstream + datasize, &maxheadersize);                     // version      4 byte

			if(!stream.write((void *)headerstream, datasize))
				throw POV_EXCEPTION_CODE(pov_base::kFileDataErr);
		}

		objectstream = new POVMSStream[objectsize];
		maxobjectsize = objectsize;
		(void)POVMSStream_Write(&data, objectstream, &maxobjectsize);

#ifdef POVMS_COMPRESSION_ENABLED
		if(compress == true)
		{
			compressedstream = new POVMSStream[objectsize * 2];

			// compress stream data
			uLongf destlen = (uLongf)(objectsize * 2);
			if(compress2((Bytef *)(compressedstream), &destlen, (Bytef *)(objectstream), (uLongf)(objectsize), Z_BEST_COMPRESSION) != Z_OK)
				throw POV_EXCEPTION_CODE(pov_base::kCannotHandleDataErr);

			datasize = 0;
			maxheadersize = 12; // header

			datasize += POVMSStream_WriteInt((POVMSInt)(destlen), headerstream + datasize, &maxheadersize);        // data size    4 byte
			datasize += POVMSStream_WriteType(kPOVMSGZipStreamEncoding, headerstream + datasize, &maxheadersize);  // encoding     4 byte
			datasize += POVMSStream_WriteInt(objectsize, headerstream + datasize, &maxheadersize);                 // object size  4 byte

			if(!stream.write((void *)headerstream, datasize))
				throw POV_EXCEPTION_CODE(pov_base::kFileDataErr);

			if(!stream.write((void *)compressedstream, (int)(destlen)))                                            // data         x byte
				throw POV_EXCEPTION_CODE(pov_base::kFileDataErr);
		}
		else
#endif
		{
			datasize = 0;
			maxheadersize = 8; // header

			datasize += POVMSStream_WriteInt(objectsize, headerstream + datasize, &maxheadersize);                 // object size  4 byte
			datasize += POVMSStream_WriteType(kPOVMSRawStreamEncoding, headerstream + datasize, &maxheadersize);   // encoding     4 byte

			if(!stream.write((void *)headerstream, datasize))
				throw POV_EXCEPTION_CODE(pov_base::kFileDataErr);

			if(!stream.write((void *)objectstream, objectsize))                                                    // object       x byte
				throw POV_EXCEPTION_CODE(pov_base::kFileDataErr);
		}

		if(objectstream != NULL)
			delete[] objectstream;
		objectstream = NULL;

		if(compressedstream != NULL)
			delete[] compressedstream;
		compressedstream = NULL;
	}
	catch(...)
	{
		if(objectstream != NULL)
			delete[] objectstream;

		if(compressedstream != NULL)
			delete[] compressedstream;

		throw;
	}
}
开发者ID:acekiller,项目名称:povray,代码行数:91,代码来源:povmscpp.cpp

示例3: myPredecessor

 StandardError::Redirection::Redirection ( OutputStream& output )
     : myPredecessor(set(output.handle()))
 {
 }
开发者ID:AndreLouisCaron,项目名称:w32,代码行数:4,代码来源:StandardError.cpp

示例4: writeToStream

 void writeToStream (const ValueUnion&, OutputStream& output) const   { output.writeCompressedInt (0); }
开发者ID:Krewn,项目名称:LIOS,代码行数:1,代码来源:juce_Variant.cpp

示例5: write

 inline void write (OutputStream& output)   {
     output.write (values, 2);
 }
开发者ID:randi2kewl,项目名称:ShoutOut,代码行数:3,代码来源:juce_AudioThumbnail.cpp

示例6: Dump

	void Definition::Dump(OutputStream& s, int level, bool fLast)
	{
		if(m_predefined) return;

		CStringW tabs(' ', level*4);

		CStringW str = tabs;
		if(m_predefined) str += '?';
		if(m_priority == PLow) str += '*';
		else if(m_priority == PHigh) str += '!';
		if(!IsTypeUnknown() && !m_autotype) str += m_type;
		if(!IsNameUnknown()) str += '#' + m_name;
		str += ':';
		s.PutString(L"%s", str);

		if(!m_nodes.IsEmpty())
		{
			POSITION pos = m_nodes.GetHeadPosition();
			while(pos)
			{
				Node* pNode = m_nodes.GetNext(pos);

				if(Reference* pRef = dynamic_cast<Reference*>(pNode))
				{
					pRef->Dump(s, level, fLast);
				}
				else 
				{
					ASSERT(!pNode->IsNameUnknown());
					s.PutString(L" %s", pNode->m_name);
				}
			}

			s.PutString(L";\n");

			if(!fLast && (!m_nodes.IsEmpty() || level == 0)) s.PutString(L"\n");
		}
		else if(m_status == string)
		{
			CStringW str = m_value;
			str.Replace(L"\"", L"\\\"");
			s.PutString(L" \"%s\";\n", str);
		}
		else if(m_status == number)
		{
			CStringW str = m_value;
			if(!m_unit.IsEmpty()) str += m_unit;
			s.PutString(L" %s;\n", str);
		}
		else if(m_status == boolean)
		{
			s.PutString(L" %s;\n", m_value);
		}
		else if(m_status == block)
		{
			s.PutString(L" {%s};\n", m_value);
		}
		else
		{
			s.PutString(L" null;\n");
		}
	}
开发者ID:anguoyang,项目名称:MediaPoint,代码行数:62,代码来源:Node.cpp

示例7: save

void Palace::save(OutputStream& stream) const {
	StructureBase::save(stream);
	stream.writeSint32(specialWeaponTimer);
}
开发者ID:binarycrusader,项目名称:dunelegacy,代码行数:4,代码来源:Palace.cpp

示例8: writePathToStream

void Path::writePathToStream (OutputStream& dest) const
{
    dest.writeByte (useNonZeroWinding ? 'n' : 'z');

    size_t i = 0;
    while (i < numElements)
    {
        const float type = data.elements [i++];

        if (type == moveMarker)
        {
            dest.writeByte ('m');
            dest.writeFloat (data.elements [i++]);
            dest.writeFloat (data.elements [i++]);
        }
        else if (type == lineMarker)
        {
            dest.writeByte ('l');
            dest.writeFloat (data.elements [i++]);
            dest.writeFloat (data.elements [i++]);
        }
        else if (type == quadMarker)
        {
            dest.writeByte ('q');
            dest.writeFloat (data.elements [i++]);
            dest.writeFloat (data.elements [i++]);
            dest.writeFloat (data.elements [i++]);
            dest.writeFloat (data.elements [i++]);
        }
        else if (type == cubicMarker)
        {
            dest.writeByte ('b');
            dest.writeFloat (data.elements [i++]);
            dest.writeFloat (data.elements [i++]);
            dest.writeFloat (data.elements [i++]);
            dest.writeFloat (data.elements [i++]);
            dest.writeFloat (data.elements [i++]);
            dest.writeFloat (data.elements [i++]);
        }
        else if (type == closeSubPathMarker)
        {
            dest.writeByte ('c');
        }
    }

    dest.writeByte ('e'); // marks the end-of-path
}
开发者ID:AndyBrown91,项目名称:JuceGames,代码行数:47,代码来源:juce_Path.cpp

示例9: main

int main(int args, char ** argv)
{
  cout << "******************************************************************" << endl;
  cout << "*              Bio++ Distance Methods, version 2.2.0             *" << endl;
  cout << "* Author: J. Dutheil                        Created     05/05/07 *" << endl;
  cout << "*                                           Last Modif. 04/02/15 *" << endl;
  cout << "******************************************************************" << endl;
  cout << endl;

  if(args == 1)
  {
    help();
    return 0;
  }
  
  try {

  BppApplication bppdist(args, argv, "BppDist");
  bppdist.startTimer();

  Alphabet* alphabet = SequenceApplicationTools::getAlphabet(bppdist.getParams(), "", false);
  auto_ptr<GeneticCode> gCode;
  CodonAlphabet* codonAlphabet = dynamic_cast<CodonAlphabet*>(alphabet);
  if (codonAlphabet) {
    string codeDesc = ApplicationTools::getStringParameter("genetic_code", bppdist.getParams(), "Standard", "", true, true);
    ApplicationTools::displayResult("Genetic Code", codeDesc);

    gCode.reset(SequenceApplicationTools::getGeneticCode(codonAlphabet->getNucleicAlphabet(), codeDesc));
  }

  VectorSiteContainer* allSites = SequenceApplicationTools::getSiteContainer(alphabet, bppdist.getParams());
  
  VectorSiteContainer* sites = SequenceApplicationTools::getSitesToAnalyse(* allSites, bppdist.getParams());
  delete allSites;

  ApplicationTools::displayResult("Number of sequences", TextTools::toString(sites->getNumberOfSequences()));
  ApplicationTools::displayResult("Number of sites", TextTools::toString(sites->getNumberOfSites()));
  
  SubstitutionModel* model = PhylogeneticsApplicationTools::getSubstitutionModel(alphabet, gCode.get(), sites, bppdist.getParams());
  
	DiscreteDistribution* rDist = 0;
  if (model->getNumberOfStates() > model->getAlphabet()->getSize())
  {
    //Markov-modulated Markov model!
    rDist = new ConstantRateDistribution();
  }
  else
  {
	  rDist = PhylogeneticsApplicationTools::getRateDistribution(bppdist.getParams());
  }
   
  DistanceEstimation distEstimation(model, rDist, sites, 1, false);
 
  string method = ApplicationTools::getStringParameter("method", bppdist.getParams(), "nj");
  ApplicationTools::displayResult("Tree reconstruction method", method);
  TreeTemplate<Node>* tree;
  AgglomerativeDistanceMethod* distMethod = 0;
  if(method == "wpgma")
  {
    PGMA* wpgma = new PGMA(true);
    distMethod = wpgma;
  }
  else if(method == "upgma")
  {
    PGMA* upgma = new PGMA(false);
    distMethod = upgma;
  }
  else if(method == "nj")
  {
    NeighborJoining* nj = new NeighborJoining();
    nj->outputPositiveLengths(true);
    distMethod = nj;
  }
  else if(method == "bionj")
  {
    BioNJ* bionj = new BioNJ();
    bionj->outputPositiveLengths(true);
    distMethod = bionj;
  }
  else throw Exception("Unknown tree reconstruction method.");
  
  string type = ApplicationTools::getStringParameter("optimization.method", bppdist.getParams(), "init");
  ApplicationTools::displayResult("Model parameters estimation method", type);
  if (type == "init") type = OptimizationTools::DISTANCEMETHOD_INIT;
  else if (type == "pairwise") type = OptimizationTools::DISTANCEMETHOD_PAIRWISE;
  else if (type == "iterations") type = OptimizationTools::DISTANCEMETHOD_ITERATIONS;
  else throw Exception("Unknown parameter estimation procedure '" + type + "'.");
  
	unsigned int optVerbose = ApplicationTools::getParameter<unsigned int>("optimization.verbose", bppdist.getParams(), 2);
	
	string mhPath = ApplicationTools::getAFilePath("optimization.message_handler", bppdist.getParams(), false, false);
	OutputStream* messenger = 
		(mhPath == "none") ? 0 :
			(mhPath == "std") ? ApplicationTools::message :
				new StlOutputStream(new ofstream(mhPath.c_str(), ios::out));
	ApplicationTools::displayResult("Message handler", mhPath);

	string prPath = ApplicationTools::getAFilePath("optimization.profiler", bppdist.getParams(), false, false);
	OutputStream* profiler = 
		(prPath == "none") ? 0 :
//.........这里部分代码省略.........
开发者ID:matsen,项目名称:bppsuite,代码行数:101,代码来源:bppDist.cpp


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