Пример #1
0
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;
	}
}
Пример #2
0
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;
}
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;
}
Пример #4
0
	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);
		}
	}
Пример #5
0
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_);
}
Пример #6
0
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_));
}
Пример #7
0
//**************************************************************************
// 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;
}
Пример #8
0
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;
			}
			unsigned b = util::to_unsigned(version_str.data() + b_start, b_end - b_start);
			
			size_t c_start = b_end + 1;
			size_t c_end = version_str.find_first_not_of(digits, c_start);
			if(c_end == std::string::npos) {
				continue;
			}
			unsigned c = util::to_unsigned(version_str.data() + c_start, c_end - c_start);
			
			size_t d_start = c_end;
			if(version_str[d_start] == 'a') {
				if(d_start + 1 >= version_str.length()) {
					continue;
				}
				d_start++;
			}
			
			unsigned d = 0;
			if(version_str[d_start] == '.') {
				d_start++;
				size_t d_end = version_str.find_first_not_of(digits, d_start);
				if(d_end != std::string::npos && d_end != d_start) {
					d = util::to_unsigned(version_str.data() + d_start, d_end - d_start);
				}
			}
			
			value = INNO_VERSION_EXT(a, b, c, d);
			break;
			
		} catch(boost::bad_lexical_cast) {
			continue;
		}
	}
	if(bracket == std::string::npos) {
		throw version_error();
	}
	
	bits = 32;
	unicode = (version_str.find("(u)") != std::string::npos);
	known = false;
}
Пример #9
0
 void deserialize(std::istream& in, T& data)
 {
   in.read(reinterpret_cast<char*>(&data), sizeof(T));
 }
Пример #10
0
unsigned int base::read( std::istream &file, unsigned short &data )
{
    file.read( (char*)&data, sizeof( unsigned short ) );
    return sizeof( unsigned short );
}
Пример #11
0
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];
      }
   }
}
Пример #12
0
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");
}
Пример #13
0
Result::Result(std::istream & in) {
    in.read((char *) &mExitCode, sizeof(int));
    mpOutputBuffer = new Buffer(in);
}
Пример #14
0
//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;
}
Пример #15
0
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();
}
Пример #16
0
void read_to(std::vector<T> &buffer, std::istream &is) {
	is.read(reinterpret_cast<char*>(&buffer[0]), buffer.size() * sizeof T);
}
void readBinary(T& t, std::istream& in)
{
   in.read((char*)&t, sizeof(T));
}  
Пример #18
0
std::vector<LsbObject *> LsxReader::loadFile(std::istream& input) {
	cleanup();
	std::vector<LsbObject *> objects;
	std::vector<LsbObject *> empty;
	int startPos = input.tellg();
	input.seekg(0, std::ios::end);
	int bytesTotal = input.tellg() - startPos;
	input.seekg(0, std::ios::beg);
	int bytesLeft = bytesTotal;
	
	char *xmlBuf = new char[bytesTotal];
	input.read(xmlBuf, bytesTotal);
	TiXmlDocument doc;
	doc.Parse(xmlBuf);
	delete[] xmlBuf;
	
	TiXmlElement *saveElement = doc.FirstChildElement("save");
	if (saveElement == 0) {
		return empty;
	}
	
	TiXmlElement *headerElement = saveElement->FirstChildElement("header");
	if (headerElement != 0) {
		const char *version = headerElement->Attribute("version");
		const char *time = headerElement->Attribute("time");
		if (version == 0 || time == 0) {
			return empty;
		}
		cachedHeader.endianness = 0;
		cachedHeader.fileLength = bytesTotal;
		cachedHeader.fileTimestamp = 0;
		try {
			cachedHeader.fileTimestamp = boost::lexical_cast<long>(time);
		} catch (const boost::bad_lexical_cast& e) {
			
		}
		try {
			cachedHeader.magic = boost::lexical_cast<long>(version);
		} catch (const boost::bad_lexical_cast& e) {
			
		}
	}
	
	TiXmlElement *versionElement = saveElement->FirstChildElement("version");
	if (versionElement != 0) {
		const char *major = versionElement->Attribute("major");
		const char *minor = versionElement->Attribute("minor");
		const char *revision = versionElement->Attribute("revision");
		const char *build = versionElement->Attribute("build");
		if (major == 0 || minor == 0 || revision == 0 || build == 0) {
			return empty;
		}
		try {
			cachedHeader.verMajor = boost::lexical_cast<long>(major);
		} catch (const boost::bad_lexical_cast& e) {
			
		}
		try {
			cachedHeader.verMinor = boost::lexical_cast<long>(minor);
		} catch (const boost::bad_lexical_cast& e) {
			
		}
		try {
			cachedHeader.verRevision = boost::lexical_cast<long>(revision);
		} catch (const boost::bad_lexical_cast& e) {
			
		}
		try {
			cachedHeader.verBuild = boost::lexical_cast<long>(build);
		} catch (const boost::bad_lexical_cast& e) {
			
		}
	}
	
	if (headerElement != 0 || versionElement != 0) {
		headerCached = true;
	}
	
	std::vector<TiXmlElement *> regions = getAllElementsByName(saveElement, "region");
	if (readerProgressCallback != 0) {
		readerProgressCallback->onLoadBegin(regions.size());
	}
	//std::cout<<"Region count = "<<regions.size()<<'\n';
	for (int i=0; i<regions.size(); ++i) {
		TiXmlElement *regionNode = regions[i];
		const char *id = regionNode->Attribute("id");
		if (id == 0) {
			return empty;
		}
		TAG_LSB *tag = LsbObject::createTagIfNeeded(id, &tagList);
		objects.push_back(new LsbObject());
		LsbObject *obj = objects[objects.size() - 1];
		obj->setIndex(tag->index);
		obj->setType(0x0);
		obj->setName(id);
		obj->setDirectoriesLeft(1);
		obj->setEntityId(i + 1);
		obj->setEntitySize(0);
		std::stack<LsbObject *> arrayStack;
		arrayStack.push(obj);
		
		//std::cout<<"Processing region "<<id<<'\n';
		if (!readTagData(regionNode, 0, arrayStack, bytesLeft, tagList, 0)) {
			return empty;
		}
		
		if (readerProgressCallback != 0) {
			readerProgressCallback->onLoadUpdate(regions.size() - (i + 1));
		}
	}
	if (readerProgressCallback != 0) {
		readerProgressCallback->onLoadEnd();
	}
	
//	static const int BLOCK_SIZE = 2048;
//	char alloc[BLOCK_SIZE];
//	char allocHeader[sizeof(HEADER_LSB)];
//	if (input && bytesLeft >= sizeof(HEADER_LSB)) {
//		input.read(allocHeader, sizeof(HEADER_LSB));
//		bytesLeft -= sizeof(HEADER_LSB);
//		*(&cachedHeader) = *((HEADER_LSB*)allocHeader);
//		headerCached = true;
		
//		bool good = readTags(input, cachedHeader.tagCount, bytesLeft, tagList, alloc);
//		if (!good) {
//			return empty;
//		}
//		if (input && bytesLeft >= sizeof(long)) {
//			input.read(alloc, sizeof(long));
//			bytesLeft -= sizeof(long);
//			*(&entityCount) = *((long*)alloc);
//		}
//		else {
//			return empty;
//		}
//		readDataHeader(input, bytesLeft, alloc);
//		//        for (int i=0; i<entityHeaderList.size(); ++i) {
//		//            ////std::cout<<"Offset "<<(i+1)<<": "<<(void*)entityHeaderList[i].dataOffset<<
//		//                       "   id="<<entityHeaderList[i].id<<'\n';
//		//        }
//		if (readerProgressCallback != 0) {
//			readerProgressCallback->onLoadBegin(entityHeaderList.size());
//		}
//		for (int i=0; i<entityHeaderList.size(); ++i) {
//			ENTITY_HEADER_LSB *entityHeaderPtr = 0;
//			if ((i+1) < entityHeaderList.size()) {
//				entityHeaderPtr = entityHeaderList[i+1];
//			}
//			int bytesNext = (entityHeaderPtr == 0 ?
//								 bytesTotal - entityHeaderList[i]->dataOffset :
//								 entityHeaderPtr->dataOffset - entityHeaderList[i]->dataOffset);
//			input.seekg(entityHeaderList[i]->dataOffset);
//			TAG_LSB *tagPtr = getTagByIndex(entityHeaderList[i]->id, tagList);
//			char *tag = "?";
//			if (tagPtr != 0) {
//				tag = tagPtr->tag;
//			}
//			////std::cout<<"Entity "<<(i + 1)<<"------------------ Offset:"
////					<<(void*) entityHeaderList[i].dataOffset<<" Id: "
//	//			   <<(void*) entityHeaderList[i].id<<" ("<<tag<<")"<<'\n';
//			objects.push_back(new LsbObject());
//			LsbObject *obj = objects[objects.size() - 1];
//			obj->setIndex(entityHeaderList[i]->id);
//			obj->setType(0x0);
//			obj->setName(tag);
//			obj->setDirectoriesLeft(1);
//			obj->setEntityId(i + 1);
//			obj->setEntitySize(bytesNext);
//			std::stack<LsbObject *> arrayStack;
//			arrayStack.push(obj);
			
//			//if ((i+1) == 15)
//				//std::system("pause");
//			readTagData(input, bytesNext, arrayStack, cachedHeader.tagCount, bytesLeft, tagList, alloc);
//			if (readerProgressCallback != 0) {
//				readerProgressCallback->onLoadUpdate(entityHeaderList.size() - (i + 1));
//			}
//		}
//		if (bytesLeft > 0) {
//			////std::cout<<"Warning: extra bytes leftover: "<<bytesLeft<<'\n';
//		}
//		////freeTagList(tagList);
//	}
//	else {
//		if (readerProgressCallback != 0) {
//			readerProgressCallback->onLoadEnd();
//		}
//		return std::vector<LsbObject *>();
//	}
//	if (readerProgressCallback != 0) {
//		readerProgressCallback->onLoadEnd();
//	}
	return objects;
}
Пример #19
0
void ossimNitfFileHeaderV2_1::parseStream(std::istream& in)
{
   clearFields();

   // identification and origination group
   in.read(theFileTypeVersion, 9);
   theHeaderSize += 9;
   in.read(theComplexityLevel, 2);
   theHeaderSize += 2;
   in.read(theSystemType, 4);
   theHeaderSize += 4;
   in.read(theOriginatingStationId, 10);
   theHeaderSize += 10;
   in.read(theDateTime, 14);
   theHeaderSize += 14;
   in.read(theFileTitle, 80);
   theHeaderSize += 80;

   // read security group
   in.read(theSecurityClassification, 1);
   theHeaderSize ++;
   in.read(theSecurityClassificationSys, 2);
   theHeaderSize += 2;
   in.read(theCodewords, 11);
   theHeaderSize += 11;
   in.read(theControlAndHandling, 2);
   theHeaderSize += 2;
   in.read(theReleasingInstructions, 20);
   theHeaderSize += 20;
   in.read(theDeclassificationType, 2);
   theHeaderSize += 2;
   in.read(theDeclassificationDate, 8);
   theHeaderSize += 8;
   in.read(theDeclassificationExemption, 4);
   theHeaderSize += 4;
      
   in.read(theDowngrade, 1);
   theHeaderSize ++;
   in.read(theDowngradingDate, 8);
   theHeaderSize += 8;
   in.read(theClassificationText, 43);
   theHeaderSize += 43;
   in.read(theClassificationAuthorityType, 1);
   theHeaderSize ++;
   in.read(theClassificationAuthority, 40);
   theHeaderSize += 40;
   in.read(theClassificationReason, 1);
   theHeaderSize ++;
   in.read(theSecuritySourceDate, 8);
   theHeaderSize += 8;
   in.read(theSecurityControlNumber, 15);
   theHeaderSize += 15;
   in.read(theCopyNumber, 5);
   theHeaderSize += 5;
   in.read(theNumberOfCopies, 5);
   theHeaderSize += 5;
   in.read(theEncryption, 1);
   theHeaderSize ++;
   in.read((char*)theFileBackgroundColor, 3);
   theHeaderSize += 3;
   in.read(theOriginatorsName, 24);
   theHeaderSize += 24;
   in.read(theOriginatorsPhone, 18);
   theHeaderSize += 18;
   in.read(theFileLength, 12);
   theHeaderSize += 12;
   in.read(theHeaderLength, 6);
   theHeaderSize += 6;
   
   // image description group
   in.read(theNumberOfImageInfoRecords, 3); 
   theHeaderSize += 3;
   readImageInfoRecords(in); 

   // symbol description group
   in.read(theNumberOfGraphicInfoRecords, 3); 
   theHeaderSize += 3;
   readGraphicInfoRecords(in);

   in.read(theReservedForFutureUse1, 3);
   theHeaderSize += 3;
      
   // text file information group
   in.read(theNumberOfTextFileInfoRecords, 3); 
   theHeaderSize += 3;
   readTextFileInfoRecords(in);

   // Data extension group
   in.read(theNumberOfDataExtSegInfoRecords, 3); 
   theHeaderSize += 3;
   readDataExtSegInfoRecords(in);

   // Reserve Extension Segment group
   in.read(theNumberOfResExtSegInfoRecords, 3); 
   theHeaderSize += 3;
   readResExtSegInfoRecords(in);

   in.read(theUserDefinedHeaderDataLength, 5);
   theHeaderSize += 5;

   // only get the header overflow if there even exists
   // user defined data.
   std::streampos userDefinedHeaderLength = ossimString(theUserDefinedHeaderDataLength).toInt32();
   ossimNitfTagInformation         headerTag;
   std::streampos start   = in.tellg();
   std::streampos current = in.tellg();
   if(userDefinedHeaderLength > 0)
   {
      in.read(theUserDefinedHeaderOverflow, 3);
         
      while((current - start) < userDefinedHeaderLength)
      {
         headerTag.parseStream(in);
         theTagList.push_back(headerTag);
         // in.ignore(headerTag.getTagLength());
         // headerTag.clearFields();
         current = in.tellg();
      }
      in.seekg(start + userDefinedHeaderLength);
      theHeaderSize += (userDefinedHeaderLength);
   }
   in.read(theExtendedHeaderDataLength, 5);
   theHeaderSize += 5;
   std::streampos extendedHeaderDataLength = ossimString(theExtendedHeaderDataLength).toInt32();

   start   = in.tellg();
   current = in.tellg();
   // for now let's just ignore it
   if(extendedHeaderDataLength > 0)
   {
      in.read(theExtendedHeaderDataOverflow, 3);
      while((current - start) < extendedHeaderDataLength)
      {
         headerTag.parseStream(in);
         theTagList.push_back(headerTag);
         
         // in.ignore(headerTag.getTagLength());
         // headerTag.clearFields();
         current = in.tellg();
      }
      theHeaderSize += extendedHeaderDataLength;
      in.seekg(start + extendedHeaderDataLength);
   }

   // this need to be re-thought
   initializeAllOffsets();
}
Пример #20
0
bool readXml(std::istream &in, StateDefinition &state)
{
	pugi::xml_document doc;

	in.seekg(0, std::ios::end);
	auto fileSize = in.tellg();
	in.seekg(0, std::ios::beg);

	std::unique_ptr<char[]> fileData(new char[fileSize]);
	in.read(fileData.get(), fileSize);
	if (!in)
	{
		std::cerr << "Failed to read " << fileSize << "bytes from input file\n";
		return false;
	}

	boost::uuids::detail::sha1 sha;
	sha.reset();
	sha.process_bytes(fileData.get(), fileSize);
	unsigned int hashValue[5];
	sha.get_digest(hashValue);

	for (int i = 0; i < 5; i++)
	{
		unsigned int v = hashValue[i];
		for (int j = 0; j < 4; j++)
		{
			// FIXME: Probably need to do the reverse for big endian?
			char stringBuf[3];
			unsigned int byteHex = v & 0xff000000;
			byteHex >>= 24;
			snprintf(stringBuf, sizeof(stringBuf), "%02x", byteHex);
			state.hashString += stringBuf;
			v <<= 8;
		}
	}

	auto ret = doc.load_buffer(fileData.get(), fileSize);
	if (!ret)
	{
		std::cerr << "Failed to parse file:" << ret.description() << "\n";
		return false;
	}

	auto rootNode = doc.first_child();
	while (rootNode)
	{
		if (std::string(rootNode.name()) == "openapoc_gamestate")
		{
			auto objectNode = rootNode.first_child();
			while (objectNode)
			{
				if (std::string(objectNode.name()) == "object")
				{
					SerializeObject obj("");
					auto externalAttr = objectNode.attribute("external");
					if (!externalAttr.empty())
					{
						std::string externalValue = externalAttr.as_string();
						if (externalValue == "true")
						{
							obj.external = true;
						}
						else
						{
							std::cerr << "Unknown object external attribute \"" << externalValue
							          << "\"\n";
						}
					}
					auto memberNode = objectNode.first_child();
					while (memberNode)
					{
						if (std::string(memberNode.name()) == "member")
						{
							std::string memberName = memberNode.text().as_string();
							NodeType type = NodeType::Normal;
							auto typeAttr = memberNode.attribute("type");
							if (!typeAttr.empty())
							{
								std::string typeName = typeAttr.as_string();
								if (typeName == "Normal")
									type = NodeType::Normal;
								else if (typeName == "Section")
									type = NodeType::Section;
								else if (typeName == "SectionMap")
									type = NodeType::SectionMap;
								else
									std::cerr << "Unknown member type attribute \"" << typeName
									          << "\"\n";
							}
							SerializeNode member(memberName);
							member.type = type;
							obj.members.push_back(std::make_pair(member.name, member));
						}
						else if (std::string(memberNode.name()) == "name")
						{
							obj.name = memberNode.text().as_string();
						}
						memberNode = memberNode.next_sibling();
					}
					state.objects.push_back(obj);
				}
				else if (std::string(objectNode.name()) == "enum")
				{
					SerializeEnum sEnum;
					auto valueNode = objectNode.first_child();
					while (valueNode)
					{
						if (std::string(valueNode.name()) == "value")
						{
							sEnum.values.push_back(valueNode.text().as_string());
						}
						else if (std::string(valueNode.name()) == "name")
						{
							sEnum.name = valueNode.text().as_string();
						}
						valueNode = valueNode.next_sibling();
					}
					state.enums.push_back(sEnum);
				}
				objectNode = objectNode.next_sibling();
			}
		}
		rootNode = rootNode.next_sibling();
	}

	return true;
}
Пример #21
0
unsigned int base::read( std::istream &file, char &data )
{
    file.read( &data, sizeof( char ) );
    return sizeof( char );
}
Пример #22
0
T get_type(std::istream & is) {
	T result = 0;
	is.read(reinterpret_cast<char *>(&result), sizeof(T));
	return result;
};
Пример #23
0
unsigned int base::read( std::istream &file, float &data )
{
    file.read( (char*)&data, sizeof( float ) );
    return sizeof( float );
}
Пример #24
0
T read(std::istream& stream){
    T value;
    stream.read(reinterpret_cast<char*>(&value), sizeof(T));

    return value;
}
Пример #25
0
int _table_hdr_t::fetch_8(std::istream &stream)
{
	int8_t res;
	stream.read((char*)&res, 1);
	return res;
}
Пример #26
0
bool CModelFile::ReadModel(std::istream& stream)
{
    m_triangles.clear();

    OldModelHeader header;

    header.revision      = IOUtils::ReadBinary<4, int>(stream);
    header.version       = IOUtils::ReadBinary<4, int>(stream);
    header.totalTriangles = IOUtils::ReadBinary<4, int>(stream);
    for (int i = 0; i < 10; ++i)
        header.reserved[i] = IOUtils::ReadBinary<4, int>(stream);


    if (!stream.good())
    {
        GetLogger()->Error("Error reading model file header\n");
        return false;
    }

    // Old model version #1
    if ( (header.revision == 1) && (header.version == 0) )
    {
        for (int i = 0; i < header.totalTriangles; ++i)
        {
            OldModelTriangle1 t;
            t.used     = IOUtils::ReadBinary<1, char>(stream);
            t.selected = IOUtils::ReadBinary<1, char>(stream);

            /* padding */ IOUtils::ReadBinary<2, unsigned int>(stream);

            ReadBinaryVertex(stream, t.p1);
            ReadBinaryVertex(stream, t.p2);
            ReadBinaryVertex(stream, t.p3);

            ReadBinaryMaterial(stream, t.material);
            stream.read(t.texName, 20);
            t.min = IOUtils::ReadBinaryFloat(stream);
            t.max = IOUtils::ReadBinaryFloat(stream);

            if (stream.fail())
            {
                GetLogger()->Error("Error reading model data\n");
                return false;
            }

            ModelTriangle triangle;
            triangle.p1.FromVertex(t.p1);
            triangle.p2.FromVertex(t.p2);
            triangle.p3.FromVertex(t.p3);

            triangle.material = t.material;
            triangle.tex1Name = std::string(t.texName);
            triangle.lodLevel = MinMaxToLodLevel(t.min, t.max);

            m_triangles.push_back(triangle);
        }
    }
    else if ( header.revision == 1 && header.version == 1 )
    {
        for (int i = 0; i < header.totalTriangles; ++i)
        {
            OldModelTriangle2 t;
            t.used     = IOUtils::ReadBinary<1, char>(stream);
            t.selected = IOUtils::ReadBinary<1, char>(stream);

            /* padding */ IOUtils::ReadBinary<2, unsigned int>(stream);

            ReadBinaryVertex(stream, t.p1);
            ReadBinaryVertex(stream, t.p2);
            ReadBinaryVertex(stream, t.p3);

            ReadBinaryMaterial(stream, t.material);
            stream.read(t.texName, 20);
            t.min = IOUtils::ReadBinaryFloat(stream);
            t.max = IOUtils::ReadBinaryFloat(stream);
            t.state = IOUtils::ReadBinary<4, long>(stream);

            t.reserved1 = IOUtils::ReadBinary<2, short>(stream);
            t.reserved2 = IOUtils::ReadBinary<2, short>(stream);
            t.reserved3 = IOUtils::ReadBinary<2, short>(stream);
            t.reserved4 = IOUtils::ReadBinary<2, short>(stream);

            if (stream.fail())
            {
                GetLogger()->Error("Error reading model data\n");
                return false;
            }

            ModelTriangle triangle;
            triangle.p1.FromVertex(t.p1);
            triangle.p2.FromVertex(t.p2);
            triangle.p3.FromVertex(t.p3);

            triangle.material = t.material;
            triangle.tex1Name = std::string(t.texName);
            triangle.lodLevel = MinMaxToLodLevel(t.min, t.max);
            triangle.state = t.state;

            m_triangles.push_back(triangle);
        }
    }
    else
    {
        for (int i = 0; i < header.totalTriangles; ++i)
        {
            OldModelTriangle3 t;
            t.used     = IOUtils::ReadBinary<1, char>(stream);
            t.selected = IOUtils::ReadBinary<1, char>(stream);

            /* padding */ IOUtils::ReadBinary<2, unsigned int>(stream);

            ReadBinaryVertexTex2(stream, t.p1);
            ReadBinaryVertexTex2(stream, t.p2);
            ReadBinaryVertexTex2(stream, t.p3);

            ReadBinaryMaterial(stream, t.material);
            stream.read(t.texName, 20);
            t.min = IOUtils::ReadBinaryFloat(stream);
            t.max = IOUtils::ReadBinaryFloat(stream);
            t.state = IOUtils::ReadBinary<4, long>(stream);
            t.texNum2 = IOUtils::ReadBinary<2, short>(stream);

            t.reserved2 = IOUtils::ReadBinary<2, short>(stream);
            t.reserved3 = IOUtils::ReadBinary<2, short>(stream);
            t.reserved4 = IOUtils::ReadBinary<2, short>(stream);

            if (stream.fail())
            {
                GetLogger()->Error("Error reading model data\n");
                return false;
            }

            ModelTriangle triangle;
            triangle.p1 = t.p1;
            triangle.p2 = t.p2;
            triangle.p3 = t.p3;

            triangle.material = t.material;
            triangle.tex1Name = std::string(t.texName);
            triangle.lodLevel = MinMaxToLodLevel(t.min, t.max);
            triangle.state = t.state;
            triangle.variableTex2 = t.texNum2 == 1;

            if (!triangle.variableTex2 && t.texNum2 != 0)
            {
                if (t.texNum2 >= 1 && t.texNum2 <= 10)
                    triangle.state |= ENG_RSTATE_DUAL_BLACK;

                if (t.texNum2 >= 11 && t.texNum2 <= 20)
                    triangle.state |= ENG_RSTATE_DUAL_WHITE;

                char tex2Name[20] = { 0 };
                sprintf(tex2Name, "dirty%.2d.png", t.texNum2); // hardcoded as in original code
                triangle.tex2Name = tex2Name;
            }

            m_triangles.push_back(triangle);
       }
    }

    for (int i = 0; i < static_cast<int>( m_triangles.size() ); ++i)
    {
        // All extensions are now png
        m_triangles[i].tex1Name = StrUtils::Replace(m_triangles[i].tex1Name, "bmp", "png");
        m_triangles[i].tex1Name = StrUtils::Replace(m_triangles[i].tex1Name, "tga", "png");

        m_triangles[i].tex2Name = StrUtils::Replace(m_triangles[i].tex2Name, "bmp", "png");
        m_triangles[i].tex2Name = StrUtils::Replace(m_triangles[i].tex2Name, "tga", "png");

        // TODO: fix this in model files
        if (m_triangles[i].tex1Name == "plant.png")
            m_triangles[i].state |= ENG_RSTATE_ALPHA;

        GetLogger()->Trace("ModelTriangle %d\n", i+1);
        std::string s1 = m_triangles[i].p1.ToString();
        GetLogger()->Trace(" p1: %s\n", s1.c_str());
        std::string s2 = m_triangles[i].p2.ToString();
        GetLogger()->Trace(" p2: %s\n", s2.c_str());
        std::string s3 = m_triangles[i].p3.ToString();
        GetLogger()->Trace(" p3: %s\n", s3.c_str());

        std::string d = m_triangles[i].material.diffuse.ToString();
        std::string a = m_triangles[i].material.ambient.ToString();
        std::string s = m_triangles[i].material.specular.ToString();
        GetLogger()->Trace(" mat: d: %s  a: %s  s: %s\n", d.c_str(), a.c_str(), s.c_str());

        GetLogger()->Trace(" tex1: %s  tex2: %s\n", m_triangles[i].tex1Name.c_str(),
                          m_triangles[i].variableTex2 ? "(variable)" : m_triangles[i].tex2Name.c_str());
        GetLogger()->Trace(" lod level: %d\n", m_triangles[i].lodLevel);
        GetLogger()->Trace(" state: %ld\n", m_triangles[i].state);
    }

    return true;
}
Пример #27
0
bool UpsPatcher::PatchBuffer(std::istream &upsFile, vector<uint8_t> &input, vector<uint8_t> &output)
{
	upsFile.seekg(0, std::ios::end);
	size_t fileSize = (size_t)upsFile.tellg();
	upsFile.seekg(0, std::ios::beg);

	char header[4];
	upsFile.read((char*)&header, 4);
	if(memcmp((char*)&header, "UPS1", 4) != 0) {
		//Invalid UPS file
		return false;
	}

	uint64_t inputFileSize = ReadBase128Number(upsFile);
	uint64_t outputFileSize = ReadBase128Number(upsFile);
	if(inputFileSize == -1 || outputFileSize == -1) {
		//Invalid file
		return false;
	}

	output.resize((size_t)outputFileSize);
	std::copy(input.begin(), input.end(), output.begin());

	uint32_t pos = 0;
	while((size_t)upsFile.tellg() < fileSize - 12) {
		uint32_t offset = (uint32_t)ReadBase128Number(upsFile);
		if(offset == -1) {
			//Invalid file
			return false;
		}

		pos += offset;

		while(true) {
			uint8_t xorValue = 0;
			upsFile.read((char*)&xorValue, 1);
			if((size_t)upsFile.tellg() > fileSize - 12) {
				//Invalid file
				return false;
			}

			output[pos] ^= xorValue;
			pos++;

			if(!xorValue) {
				break;
			}
		}
	}

	uint8_t inputChecksum[4];
	uint8_t outputChecksum[4];
	upsFile.read((char*)inputChecksum, 4);
	upsFile.read((char*)outputChecksum, 4);
	uint32_t patchInputCrc = inputChecksum[0] | (inputChecksum[1] << 8) | (inputChecksum[2] << 16) | (inputChecksum[3] << 24);
	uint32_t patchOutputCrc = outputChecksum[0] | (outputChecksum[1] << 8) | (outputChecksum[2] << 16) | (outputChecksum[3] << 24);
	uint32_t inputCrc = CRC32::GetCRC(input.data(), input.size());
	uint32_t outputCrc = CRC32::GetCRC(output.data(), output.size());

	if(patchInputCrc != inputCrc || patchOutputCrc != outputCrc) {
		return false;
	}
	return true;
}
Пример #28
0
void ossimNitfRsmpcaTag::parseStream(std::istream& in)
{
   clearFields();
   
   in.read(m_iid, IID_SIZE);
   in.read(m_edition, EDITION_SIZE);
   in.read(m_rsn, RSN_SIZE);
   in.read(m_csn, CSN_SIZE);
   in.read(m_rfep, FLOAT21_SIZE);
   in.read(m_cfep, FLOAT21_SIZE);
   in.read(m_rnrmo, FLOAT21_SIZE);
   in.read(m_cnrmo, FLOAT21_SIZE);
   in.read(m_xnrmo, FLOAT21_SIZE);
   in.read(m_ynrmo, FLOAT21_SIZE);
   in.read(m_znrmo, FLOAT21_SIZE);
   in.read(m_rnrmsf, FLOAT21_SIZE);
   in.read(m_cnrmsf, FLOAT21_SIZE);
   in.read(m_xnrmsf, FLOAT21_SIZE);
   in.read(m_ynrmsf, FLOAT21_SIZE);
   in.read(m_znrmsf, FLOAT21_SIZE);

   in.read(m_rnpwrx, MAXPOWER_SIZE);
   in.read(m_rnpwry, MAXPOWER_SIZE);
   in.read(m_rnpwrz, MAXPOWER_SIZE);
   in.read(m_rntrms, NUMTERMS_SIZE);
   ossim_uint32 idx = 0;
   m_rowNumNumTerms = ossimString(m_rntrms).toUInt32();
   m_rnpcf.resize(m_rowNumNumTerms);
   char temp1[FLOAT21_SIZE+1];
   temp1[FLOAT21_SIZE] = '\0';
   for(idx = 0; idx < m_rowNumNumTerms; ++idx)
   {
      in.read(temp1, FLOAT21_SIZE);
      m_rnpcf[idx] = POLYFILL; 
      m_rnpcf[idx] = temp1;
   }

   in.read(m_rdpwrx, MAXPOWER_SIZE);
   in.read(m_rdpwry, MAXPOWER_SIZE);
   in.read(m_rdpwrz, MAXPOWER_SIZE);
   in.read(m_rdtrms, NUMTERMS_SIZE);
   m_rowDenNumTerms = ossimString(m_rdtrms).toUInt32();
   m_rdpcf.resize(m_rowDenNumTerms);
   char temp2[FLOAT21_SIZE+1];
   temp2[FLOAT21_SIZE] = '\0';
   for(idx = 0; idx < m_rowDenNumTerms; ++idx)
   {
      in.read(temp2, FLOAT21_SIZE);
      m_rdpcf[idx] = POLYFILL; 
      m_rdpcf[idx] = temp2;
   }

   in.read(m_cnpwrx, MAXPOWER_SIZE);
   in.read(m_cnpwry, MAXPOWER_SIZE);
   in.read(m_cnpwrz, MAXPOWER_SIZE);
   in.read(m_cntrms, NUMTERMS_SIZE);
   m_colNumNumTerms = ossimString(m_cntrms).toUInt32();
   m_cnpcf.resize(m_colNumNumTerms); 
   char temp3[FLOAT21_SIZE+1];
   temp3[FLOAT21_SIZE] = '\0';
   for(idx = 0; idx < m_colNumNumTerms; ++idx)
   {
      in.read(temp3, FLOAT21_SIZE);
      m_cnpcf[idx] = POLYFILL; 
      m_cnpcf[idx] = temp3;
   }

   in.read(m_cdpwrx, MAXPOWER_SIZE);
   in.read(m_cdpwry, MAXPOWER_SIZE);
   in.read(m_cdpwrz, MAXPOWER_SIZE);
   in.read(m_cdtrms, NUMTERMS_SIZE);
   m_colDenNumTerms = ossimString(m_cdtrms).toUInt32();
   m_cdpcf.resize(m_colDenNumTerms); 
   char temp4[FLOAT21_SIZE+1];
   temp4[FLOAT21_SIZE] = '\0';
   for(idx = 0; idx < m_colDenNumTerms; ++idx)
   {
      in.read(temp4, FLOAT21_SIZE);
      m_cdpcf[idx] = POLYFILL; 
      m_cdpcf[idx] = temp4;
   }
}
Пример #29
0
static unsigned int read_ulong(std::istream& is)
{
  unsigned char a[4];
  is.read((char*) a, sizeof a);
  return (a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
}
Пример #30
0
void read_to(T &obj, std::istream &is) {
	is.read(reinterpret_cast<char*>(&obj), sizeof T);
}