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


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

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


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

示例1: readProtocolInput

static bool readProtocolInput( char* buf, unsigned int bufsize, std::istream& is, cmdbind::ProtocolHandler* cmdh)
{
	if (is.eof())
	{
		cmdh->putEOF();
		return false;
	}
	std::size_t pp = 0;
	while (pp < bufsize && !is.eof())
	{
		is.read( buf+pp, sizeof(char));
		if (!is.eof()) ++pp;
	}
	if (pp == 0 && is.eof())
	{
		cmdh->putEOF();
		return false;
	}
	else
	{
		cmdh->putInput( buf, pp);
		return true;
	}
}
开发者ID:Wolframe,项目名称:Wolframe,代码行数:24,代码来源:wolfilterIostreamFilter.cpp

示例2:

bool
Model::load(std::istream & ifs) {
  char chunk[16];
  ifs.read(chunk, 16);

  if (strcmp(chunk, "otcws")) {
    return false;
  }

  unsigned labels_offset  = read_uint(ifs);
  unsigned lexicon_offset   = read_uint(ifs);
  unsigned feature_offset   = read_uint(ifs);
  unsigned parameter_offset = read_uint(ifs);

  ifs.seekg(labels_offset);
  if (!labels.load(ifs)) {
    return false;
  }

  ifs.seekg(lexicon_offset);
  if (!internal_lexicon.load(ifs)) {
    return false;
  }

  ifs.seekg(feature_offset);
  if (!space.load(labels.size(), ifs)) {
    return false;
  }

  ifs.seekg(parameter_offset);
  if (!param.load(ifs)) {
    return false;
  }

  return true;
}
开发者ID:PassStory,项目名称:ltp,代码行数:36,代码来源:model.cpp

示例3: parseStream

rspfErrorCode rspfRpfCoverageSection::parseStream(std::istream &in,
                                                    rspfByteOrder byteOrder)
{
   if(in)
   {
      in.read((char*)&theUpperLeftLat,  8);
      in.read((char*)&theUpperLeftLon,  8);
      in.read((char*)&theLowerLeftLat,  8);
      in.read((char*)&theLowerLeftLon,  8);
      in.read((char*)&theUpperRightLat, 8);
      in.read((char*)&theUpperRightLon, 8);
      in.read((char*)&theLowerRightLat, 8);
      in.read((char*)&theLowerRightLon, 8);
      in.read((char*)&theVerticalResolution,   8);
      in.read((char*)&theHorizontalResolution, 8);
      in.read((char*)&theVerticalInterval,     8);
      in.read((char*)&theHorizontalInterval,   8);

      if( rspf::byteOrder()  != byteOrder )
      {
         rspfEndian anEndian;
         anEndian.swap(theUpperLeftLat);
         anEndian.swap(theUpperLeftLon);
         anEndian.swap(theLowerLeftLat);
         anEndian.swap(theLowerLeftLon);
         anEndian.swap(theUpperRightLat);
         anEndian.swap(theUpperRightLon);
         anEndian.swap(theLowerRightLat);
         anEndian.swap(theLowerRightLon);
         anEndian.swap(theVerticalResolution);
         anEndian.swap(theHorizontalResolution);
         anEndian.swap(theVerticalInterval);
         anEndian.swap(theHorizontalInterval);
      }
   }
   else
   {
      return rspfErrorCodes::RSPF_ERROR;
   }

   return rspfErrorCodes::RSPF_OK;
}
开发者ID:vapd-radi,项目名称:rspf_v2.0,代码行数:42,代码来源:rspfRpfCoverageSection.cpp

示例4: read

	void convolution_layer::read(
		std::istream& binary_stream_to_read_from,
		const boost::uuids::uuid& layer_read_guid)
	{
		binary_stream_to_read_from.read(reinterpret_cast<char*>(&input_feature_map_count), sizeof(input_feature_map_count));
		binary_stream_to_read_from.read(reinterpret_cast<char*>(&output_feature_map_count), sizeof(output_feature_map_count));

		unsigned int dimension_count;
		binary_stream_to_read_from.read(reinterpret_cast<char*>(&dimension_count), sizeof(dimension_count));
		window_sizes.resize(dimension_count);
		binary_stream_to_read_from.read(reinterpret_cast<char*>(&(*window_sizes.begin())), sizeof(unsigned int) * dimension_count);

		left_zero_padding.resize(dimension_count, 0);
		right_zero_padding.resize(dimension_count, 0);
		if (layer_read_guid != layer_guid_v1)
		{
			binary_stream_to_read_from.read(reinterpret_cast<char*>(&(*left_zero_padding.begin())), sizeof(unsigned int) * dimension_count);
			binary_stream_to_read_from.read(reinterpret_cast<char*>(&(*right_zero_padding.begin())), sizeof(unsigned int) * dimension_count);
		}
	}
开发者ID:Alienfeel,项目名称:nnForge,代码行数:20,代码来源:convolution_layer.cpp

示例5: parse

//**************************************************************************
// ossimDtedUhl::parse()
//**************************************************************************
void ossimDtedUhl::parse(std::istream& in)
{
   clearErrorStatus();
   theStartOffset = in.tellg();
   theStopOffset  = theStartOffset;
   // Parse theRecSen
   in.read(theRecSen, FIELD1_SIZE);
   theRecSen[FIELD1_SIZE] = '\0';

   if(!(strncmp(theRecSen, "UHL", 3) == 0))
   {
      // Not a user header label.
      theErrorStatus = ossimErrorCodes::OSSIM_ERROR;  
      in.seekg(theStartOffset);
      return;
   }  
   
   // Parse Field 2
   in.read(theField2, FIELD2_SIZE);
   theField2[FIELD2_SIZE] = '\0';
   
   // Parse theLonOrigin
   in.read(theLonOrigin, FIELD3_SIZE);
   theLonOrigin[FIELD3_SIZE] = '\0';
   
   // Parse theLatOrigin
   in.read(theLatOrigin, FIELD4_SIZE);
   theLatOrigin[FIELD4_SIZE] = '\0';
   
   // Parse theLonInterval
   in.read(theLonInterval, FIELD5_SIZE);
   theLonInterval[FIELD5_SIZE] = '\0';
   
   // Parse theLatInterval
   in.read(theLatInterval, FIELD6_SIZE);
   theLatInterval[FIELD6_SIZE] = '\0';
   
   // Parse theAbsoluteLE
   in.read(theAbsoluteLE, FIELD7_SIZE);
   theAbsoluteLE[FIELD7_SIZE] = '\0';
   
   // Parse theSecurityCode
   in.read(theSecurityCode, FIELD8_SIZE);
   theSecurityCode[FIELD8_SIZE] = '\0';
   
   // Parse Field 9
   in.read(theField9, FIELD9_SIZE);
   theField9[FIELD9_SIZE] = '\0';
   
   // Parse theNumLonLines
   in.read(theNumLonLines, FIELD10_SIZE);
   theNumLonLines[FIELD10_SIZE] = '\0';
   
   // Parse theNumLatPoints
   in.read(theNumLatPoints, FIELD11_SIZE);
   theNumLatPoints[FIELD11_SIZE] = '\0';
   
   // Parse theMultipleAccuracy
   in.read(theMultipleAccuracy, FIELD12_SIZE);
   theMultipleAccuracy[FIELD12_SIZE] = '\0';

   // Field 13 not parsed as it's unused.
   in.ignore(FIELD13_SIZE);
   // Set the stop offset.
   theStopOffset = theStartOffset + UHL_LENGTH;
}
开发者ID:loongfee,项目名称:ossim-svn,代码行数:69,代码来源:ossimDtedUhl.cpp

示例6: load

void SegmentPool::load(std::istream& istr)
{
    istr.read((char*)&maxPoolSize_, sizeof(maxPoolSize_));
    istr.read((char*)&numberOfPools_, sizeof(numberOfPools_));
    istr.read((char*)&segment_, sizeof(segment_));
    istr.read((char*)&offset_, sizeof(offset_));

    pool_.resize(segment_ + 1);
    for (size_t i = 0; i < segment_; ++i)
    {
        if (!pool_[i])
        {
            pool_[i].reset(cachealign_alloc<uint32_t>(maxPoolSize_, HUGEPAGE_SIZE), cachealign_deleter());
        }
        istr.read((char *)&pool_[i][0], sizeof(pool_[0][0]) * maxPoolSize_);
    }
    if (!pool_[segment_])
    {
        pool_[segment_].reset(cachealign_alloc<uint32_t>(maxPoolSize_, HUGEPAGE_SIZE), cachealign_deleter());
    }
    istr.read((char*)&pool_[segment_][0], sizeof(pool_[0][0]) * offset_);
}
开发者ID:RedSunCMX,项目名称:izenelib,代码行数:22,代码来源:SegmentPool.cpp

示例7: loadBinary

void Narf::loadBinary(std::istream& file)
{
  reset();
  int version = loadHeader(file);
  if (version<0)
  {
    std::cerr << __PRETTY_FUNCTION__ << "Incorrect header!\n";
    return;
  }
  pcl::loadBinary(position_.matrix(), file);
  pcl::loadBinary(transformation_.matrix(), file);
  file.read(reinterpret_cast<char*>(&surface_patch_pixel_size_), sizeof(surface_patch_pixel_size_));
  surface_patch_ = new float[surface_patch_pixel_size_*surface_patch_pixel_size_];
  file.read(reinterpret_cast<char*>(surface_patch_),
            surface_patch_pixel_size_*surface_patch_pixel_size_*sizeof(*surface_patch_));
  file.read(reinterpret_cast<char*>(&surface_patch_world_size_), sizeof(surface_patch_world_size_));
  file.read(reinterpret_cast<char*>(&surface_patch_rotation_), sizeof(surface_patch_rotation_));
  file.read(reinterpret_cast<char*>(&descriptor_size_), sizeof(descriptor_size_));
  descriptor_ = new float[descriptor_size_];
  if (file.eof())
    cout << ":-(\n";
  file.read(reinterpret_cast<char*>(descriptor_), descriptor_size_*sizeof(*descriptor_));
}
开发者ID:jonaswitt,项目名称:nestk,代码行数:23,代码来源:narf.cpp

示例8: load

void version::load(std::istream & is) {
	
	static const char digits[] = "0123456789";
	
	BOOST_STATIC_ASSERT(sizeof(stored_legacy_version) <= sizeof(stored_version));
	
	stored_legacy_version legacy_version;
	is.read(legacy_version, std::streamsize(sizeof(legacy_version)));
	
	if(legacy_version[0] == 'i' && legacy_version[sizeof(legacy_version) - 1] == '\x1a') {
		
		for(size_t i = 0; i < size_t(boost::size(legacy_versions)); i++) {
			if(!memcmp(legacy_version, legacy_versions[i].name, sizeof(legacy_version))) {
				value = legacy_versions[i].version;
				bits = legacy_versions[i].bits;
				unicode = false;
				known = true;
				debug("known legacy version: \"" << versions[i].name << '"');
				return;
			}
		}
		
		debug("unknown legacy version: \""
		      << std::string(legacy_version, sizeof(legacy_version)) << '"');
		
		if(legacy_version[0] != 'i' || legacy_version[2] != '.' || legacy_version[4] != '.'
		   || legacy_version[7] != '-' || legacy_version[8] != '-') {
			throw version_error();
		}
		
		if(legacy_version[9] == '1' && legacy_version[10] == '6') {
			bits = 16;
		} else if(legacy_version[9] == '3' && legacy_version[10] == '2') {
			bits = 32;
		} else {
			throw version_error();
		}
		
		std::string version_str(legacy_version, sizeof(legacy_version));
		
		try {
			unsigned a = util::to_unsigned(version_str.data() + 1, 1);
			unsigned b = util::to_unsigned(version_str.data() + 3, 1);
			unsigned c = util::to_unsigned(version_str.data() + 5, 2);
			value = INNO_VERSION(a, b, c);
		} catch(boost::bad_lexical_cast) {
			throw version_error();
		}
		
		unicode = false;
		known = false;
		
		return;
	}
	
	stored_version version;
	BOOST_STATIC_ASSERT(sizeof(legacy_version) <= sizeof(version));
	memcpy(version, legacy_version, sizeof(legacy_version));
	is.read(version + sizeof(legacy_version),
	        std::streamsize(sizeof(version) - sizeof(legacy_version)));
	
	
	for(size_t i = 0; i < size_t(boost::size(versions)); i++) {
		if(!memcmp(version, versions[i].name, sizeof(version))) {
			value = versions[i].version;
			bits = 32;
			unicode = versions[i].unicode;
			known = true;
			debug("known version: \"" << versions[i].name << '"');
			return;
		}
	}
	
	char * end = std::find(version, version + boost::size(version), '\0');
	std::string version_str(version, end);
	debug("unknown version: \"" << version_str << '"');
	if(version_str.find("Inno Setup") == std::string::npos) {
		throw version_error();
	}
	
	size_t bracket = version_str.find('(');
	for(; bracket != std::string::npos; bracket = version_str.find('(', bracket + 1)) {
		
		if(version_str.length() - bracket < 6) {
			continue;
		}
		
		try {
			
			size_t a_start = bracket + 1;
			size_t a_end = version_str.find_first_not_of(digits, a_start);
			if(a_end == std::string::npos || version_str[a_end] != '.') {
				continue;
			}
			unsigned a = util::to_unsigned(version_str.data() + a_start, a_end - a_start);
			
			size_t b_start = a_end + 1;
			size_t b_end = version_str.find_first_not_of(digits, b_start);
			if(b_end == std::string::npos || version_str[b_end] != '.') {
				continue;
//.........这里部分代码省略.........
开发者ID:a-detiste,项目名称:innoextract,代码行数:101,代码来源:version.cpp

示例9: deserialize

 void deserialize(std::istream& in, T& data)
 {
   in.read(reinterpret_cast<char*>(&data), sizeof(T));
 }
开发者ID:spraetor,项目名称:amdis2,代码行数:4,代码来源:Serializer.hpp

示例10: read

unsigned int base::read( std::istream &file, unsigned short &data )
{
    file.read( (char*)&data, sizeof( unsigned short ) );
    return sizeof( unsigned short );
}
开发者ID:newtempest,项目名称:Tools,代码行数:5,代码来源:base.cpp

示例11: readStream

void ossimLasHdr::readStream(std::istream& in)
{
   in.read(m_fileSignature, 4);
   in.read((char*)&m_fileSourceId, 2);
   in.read((char*)&m_globalEncoding, 2);
   in.read((char*)&m_projectIdGuidData1, 4);
   in.read((char*)&m_projectIdGuidData2, 2);
   in.read((char*)&m_projectIdGuidData3, 2);
   in.read((char*)&m_projectIdGuidData4, 8);
   in.read((char*)&m_versionMajor, 1);
   in.read((char*)&m_versionMinor, 1);
   in.read(m_systemIndentifier, 32);
   in.read(m_generatingSoftware, 32);
   in.read((char*)&m_fileCreationDay, 2);
   in.read((char*)&m_fileCreateionYear, 2);
   in.read((char*)&m_headerSize, 2);
   in.read((char*)&m_offsetToPointData, 4);
   in.read((char*)&m_numberOfVariableLengthRecords, 4);
   in.read((char*)&m_pointDataFormatId, 1);
   in.read((char*)&m_pointDataRecordLength, 2);
   in.read((char*)&m_legacyNumberOfPointRecords, 4);
   in.read((char*)&m_legacyNumberOfPointsByReturn, 20);
   in.read((char*)&m_xScaleFactor, 8);
   in.read((char*)&m_yScaleFactor, 8);
   in.read((char*)&m_zScaleFactor, 8);
   in.read((char*)&m_xOffset, 8);
   in.read((char*)&m_yOffset, 8);
   in.read((char*)&m_zOffset, 8);
   in.read((char*)&m_maxX, 8);
   in.read((char*)&m_minX, 8);
   in.read((char*)&m_maxY, 8);
   in.read((char*)&m_minY, 8);
   in.read((char*)&m_maxZ, 8);
   in.read((char*)&m_minZ, 8);

   // Version specific:
   if ( versionGreaterThan( 1, 2 ) )
   {
      // Added in 1.3:
      in.read((char*)&m_startOfWaveformDataPacket, 8);
   }
   if ( versionGreaterThan( 1, 3 ) )
   {
      // Added in 1.4:
      in.read((char*)&m_startOfExtendedVariableLengthRecords, 8);
      in.read((char*)&m_numberOfExtendedVariableLengthRecords, 4);
      in.read((char*)&m_numberOfPointRecords, 8);
      in.read((char*)&m_numberOfPointsByReturn, 120);
   }

   if ( ossim::byteOrder() == OSSIM_BIG_ENDIAN )
   {
      swap();
   }

   if ( !versionGreaterThan( 1, 3 ) ) // Less than 1.4
   {
      //---
      // Copy legacy point count to 64 bit data members. This will allow LAS code
      // to always go through same methods for point counts.
      //---
      m_numberOfPointRecords = m_legacyNumberOfPointRecords;
      for ( ossim_uint32 i = 0; i < 5; ++i )
      {
         m_numberOfPointsByReturn[i] = m_legacyNumberOfPointsByReturn[i];
      }
   }
}
开发者ID:LucHermitte,项目名称:ossim,代码行数:68,代码来源:ossimLasHdr.cpp

示例12: logic_error

task4_4::a_message::a_message( std::istream& inp )
{
    inp.read( content_, content_size );
    if ( inp.eof() )
        throw std::logic_error("bad input stream, a_message cannot be readed");
}
开发者ID:russov,项目名称:cpp_craft_1013,代码行数:6,代码来源:a_message.cpp

示例13: sizeof

Result::Result(std::istream & in) {
    in.read((char *) &mExitCode, sizeof(int));
    mpOutputBuffer = new Buffer(in);
}
开发者ID:Donkey-Sand,项目名称:gvirtus-zeroMQ,代码行数:4,代码来源:Result.cpp

示例14: unzip_llsd

//decompress a block of LLSD from provided istream
// not very efficient -- creats a copy of decompressed LLSD block in memory
// and deserializes from that copy using LLSDSerialize
bool unzip_llsd(LLSD& data, std::istream& is, S32 size)
{
	U8* result = NULL;
	U32 cur_size = 0;
	z_stream strm;
		
	const U32 CHUNK = 65536;

	U8 *in = new U8[size];
	is.read((char*) in, size); 

	U8 out[CHUNK];
		
	strm.zalloc = Z_NULL;
	strm.zfree = Z_NULL;
	strm.opaque = Z_NULL;
	strm.avail_in = size;
	strm.next_in = in;

	S32 ret = inflateInit(&strm);

	do
	{
		strm.avail_out = CHUNK;
		strm.next_out = out;
		ret = inflate(&strm, Z_NO_FLUSH);
		if (ret == Z_STREAM_ERROR)
		{
			inflateEnd(&strm);
			free(result);
			delete [] in;
			return false;
		}
		
		switch (ret)
		{
		case Z_NEED_DICT:
			ret = Z_DATA_ERROR;
		case Z_DATA_ERROR:
		case Z_MEM_ERROR:
			inflateEnd(&strm);
			free(result);
			delete [] in;
			return false;
			break;
		}

		U32 have = CHUNK-strm.avail_out;

		result = (U8*) realloc(result, cur_size + have);
		memcpy(result+cur_size, out, have);
		cur_size += have;

	} while (ret == Z_OK);

	inflateEnd(&strm);
	delete [] in;

	if (ret != Z_STREAM_END)
	{
		free(result);
		return false;
	}

	//result now points to the decompressed LLSD block
	{
		std::string res_str((char*) result, cur_size);

		std::string deprecated_header("<? LLSD/Binary ?>");

		if (res_str.substr(0, deprecated_header.size()) == deprecated_header)
		{
			res_str = res_str.substr(deprecated_header.size()+1, cur_size);
		}
		cur_size = res_str.size();

		std::istringstream istr(res_str);
		
		if (!LLSDSerialize::fromBinary(data, istr, cur_size))
		{
			llwarns << "Failed to unzip LLSD block" << llendl;
			free(result);
			return false;
		}
	}

	free(result);
	return true;
}
开发者ID:Logear,项目名称:PartyHatViewer,代码行数:92,代码来源:llsdserialize.cpp

示例15: readTextContent

bool ossimXmlNode::readTextContent(std::istream& in)
{
    xmlskipws(in);

    theText = "";
    theCDataFlag = false;
    char c = in.peek();

    do
    {
        if(c == '<')
        {
            in.ignore();

            // we will check for comments or CDATA
            if(in.peek()=='!')
            {
                char buf1[4];
                buf1[3] = '\0';
                in.read(buf1, 3);
                if(ossimString(buf1) == "!--")
                {
                    // special text read
                    theText += buf1;
                    bool done = false;
                    do
                    {
                        if(in.peek() != '-')
                        {
                            in.ignore();
                        }
                        else
                        {
                            in.ignore();
                            if(in.peek() == '-')
                            {
                                in.ignore();
                                if(in.peek() == '>')
                                {
                                    in.ignore();
                                    done = true;
                                    c = in.peek();
                                }
                            }
                        }
                    } while(!done&&!in.fail());
                }
                else
                {

                    char buf2[6];
                    buf2[5] = '\0';
                    in.read(buf2, 5);
                    if(in.fail())
                    {
                        return false;
                    }
                    if(ossimString(buf1)+ossimString(buf2) == "![CDATA[")
                    {
                        if(readCDataContent(in))
                        {
                            theCDataFlag = true;
                            return true;
                        }
                    }
                }
            }
            else
            {
                in.putback(c);
                return true;
            }
        }
        else
        {
            theText += (char)in.get();
            c = in.peek();
        }
    } while(!in.fail());

    return !in.fail();
}
开发者ID:renyu310,项目名称:ossim-svn,代码行数:82,代码来源:ossimXmlNode.cpp


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