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


C++ readHeader函数代码示例

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


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

示例1: readFile

/// This function reads data from file
void readFile( std::string t_filepath )
{
    std::ifstream a_csvread( t_filepath.c_str() );
    if(!a_csvread.is_open())
        std::cout << "Error at opening file: " << t_filepath << std::endl;
    else {
        // file is available

        // read file header
        HeaderData a_header;
        readHeader( a_csvread, a_header );
        std::cout <<  a_header.m_versionString << ": " << a_header.m_major << "." << a_header.m_minor << std::endl;
        std::cout <<  a_header.m_numberOfDataString << ": " << a_header.m_numberOfDataItems << std::endl;

        // read file data
        for( CenterPoint a_data; readData( a_csvread, a_data ); ) { // Nice for-loop
            std::cout <<  a_data.m_name << ", x=" << a_data.m_x << ", y=" << a_data.m_y << std::endl;
        }

        a_csvread.close();
    }
}
开发者ID:meilu2two,项目名称:apps,代码行数:23,代码来源:main.cpp

示例2: objectStream

bool Foam::IOobject::headerOk()
{
    bool ok = true;

    Istream* isPtr = objectStream();

    // If the stream has failed return
    if (!isPtr)
    {
        if (objectRegistry::debug)
        {
            Info
                << "IOobject::headerOk() : "
                << "file " << objectPath() << " could not be opened"
                << endl;
        }

        ok = false;
    }
    else
    {
        // Try reading header
        if (!readHeader(*isPtr))
        {
            if (objectRegistry::debug)
            {
                IOWarningIn("IOobject::headerOk()", (*isPtr))
                    << "failed to read header of file " << objectPath()
                    << endl;
            }

            ok = false;
        }
    }

    delete isPtr;

    return ok;
}
开发者ID:GJOMAA,项目名称:OpenFOAM-dev,代码行数:39,代码来源:IOobject.C

示例3: initLoad

bool BasePersistenceManager::initLoad(const Common::String &filename) {
	if (DID_FAIL(readHeader(filename))) {
		cleanup();
		return STATUS_FAILED;
	}
	_saving = false;

	if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) {
		debugC(kWintermuteDebugSaveGame, "ERROR: Saved game name doesn't match current game");
		cleanup();
		return STATUS_FAILED;
	}

	// if save is newer version than we are, fail
	if (_savedVerMajor >  DCGF_VER_MAJOR ||
	        (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor >  DCGF_VER_MINOR) ||
	        (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD)
	   ) {

		debugC(kWintermuteDebugSaveGame, "ERROR: Saved game version is newer than current game");
		debugC(kWintermuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild);
		cleanup();
		return STATUS_FAILED;
	}

	// if save is older than the minimal version we support
	if (_savedVerMajor <  SAVEGAME_VER_MAJOR ||
	        (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor <  SAVEGAME_VER_MINOR) ||
	        (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD)
	   ) {
		debugC(kWintermuteDebugSaveGame, "ERROR: Saved game is too old and cannot be used by this version of game engine");
		debugC(kWintermuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild);
		cleanup();
		return STATUS_FAILED;

	}

	return STATUS_OK;
}
开发者ID:mokerjoke,项目名称:scummvm,代码行数:39,代码来源:base_persistence_manager.cpp

示例4: HistogramReader

FfhReader::FfhReader(const std::string& filename) : 
   HistogramReader(filename)
{
   readHeader();

   auto it = images.find("IntensityNormalisation");
   if (it != images.end())
   {
      intensity_normalisation = it->second;
      auto size = intensity_normalisation.size();
      std::vector<int> dims = { 1, size.height, size.width };
      intensity_normalisation = intensity_normalisation.reshape(0, 3, &dims[0]);

      // For old-style uncorrected (for #frames) normalisation maps, correct based on maximum
      if (intensity_normalisation.type() == CV_16U)
      {
         double mn, mx;
         cv::minMaxIdx(intensity_normalisation, &mn, &mx);
         intensity_normalisation.convertTo(intensity_normalisation, CV_32F, 1.0 / mx, 0);
      }
   }
}
开发者ID:seanwarren,项目名称:FLIMreader,代码行数:22,代码来源:FfhReader.cpp

示例5: readHeader

SaveStateList SaveFileManager::list(const Common::String &target) {
	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
	Common::StringArray files = saveFileMan->listSavefiles(target + ".###");

	SaveStateList saveList;
	for (Common::StringArray::const_iterator fileName = files.begin(); fileName != files.end(); ++fileName) {
		Common::InSaveFile *saveFile = saveFileMan->openForLoading(*fileName);
		if (saveFile == nullptr || saveFile->err()) {
			continue;
		}

		BladeRunner::SaveFileHeader header;
		readHeader(*saveFile, header);

		int slotNum = atoi(fileName->c_str() + fileName->size() - 3);
		saveList.push_back(SaveStateDescriptor(slotNum, header._name));
	}

	Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());

	return saveList;
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:22,代码来源:savefile.cpp

示例6: inName

void Decoder::decode(std::string inFileName,std::string outFileName,bool mode)
{
    //open input file
    std::string inName(inFileName);
    if (inName.rfind(".ebast",inName.size()-6) == std::string::npos) {
        std::cerr << "This isn't a ebast File" << std::endl;
        exit(1);
    }
    inFile.open(inFileName, std::ios::in | std::ios::binary);
    if (!inFile.is_open()) {
        std::cerr << "Unable to read File" << std::endl;
        exit(1);
    }
    
    //open output file
    std::string outName(outFileName);
    outName += ".txt";
    if(std::ifstream(outName.c_str()))
    {
        std::cerr<<outName<<" already exists!"<<std::endl;
        exit(1);
    }
    
    outFile.open(outName.c_str(),std::ios::out | std::ios::binary);
    if (!outFile.is_open()) {
        std::cerr << "Unable to create File" << std::endl;
        exit(1);
    }
    
    //reading frequency table from file
    huffmanTree->setRoot(readHeader());
    if (mode) {
        print(huffmanTree->getRoot());
    }
    //make file
    makeFile();
    
}
开发者ID:alfredoliardo,项目名称:pressIt,代码行数:38,代码来源:Decoder.cpp

示例7: readHeader

    int IfdMakerNote::read(const byte* buf,
                           long len,
                           long start,
                           ByteOrder byteOrder,
                           long shift)
    {
        // Remember the offset
        offset_ = start - shift;
        // Set byte order if none is set yet
        if (byteOrder_ == invalidByteOrder) byteOrder_ = byteOrder;
        // Read and check the header (and set offset adjustment)
        int rc = readHeader(buf + start, len - start, byteOrder);
        if (rc == 0) {
            rc = checkHeader();
        }
        // Adjust shift
        long newShift = absShift_ ? shift + shift_ : start + shift_;
        // Read the makernote IFD
        if (rc == 0) {
            rc = ifd_.read(buf, len, start + start_, byteOrder_, newShift);
        }
        if (rc == 0) {
            // IfdMakerNote currently does not support multiple IFDs
            if (ifd_.next() != 0) {
#ifndef SUPPRESS_WARNINGS
                std::cerr << "Warning: Makernote IFD has a next pointer != 0 ("
                          << ifd_.next()
                          << "). Ignored.\n";
#endif
            }
        }
#ifdef DEBUG_MAKERNOTE
        hexdump(std::cerr, buf + start, len - start);
        if (rc == 0) ifd_.print(std::cerr);
#endif

        return rc;
    } // IfdMakerNote::read
开发者ID:obklar,项目名称:exiv2,代码行数:38,代码来源:makernote.cpp

示例8: infile

void GameApp::BuildLevel()
{
	ifstream infile("tilemap.txt");
	string line;
	while (getline(infile, line)) 
	{
			if (line == "[header]") 
			{
				if (!readHeader(infile)) 
				{
					return;
				}
			}
			else if (line == "[layer]") 
			{
				readLayerData(infile);
			}
			else if (line == "[Object Layer 1]") 
			{
				readEntityData(infile);
			}
	}
}
开发者ID:WilsonLiCode,项目名称:GamePro,代码行数:23,代码来源:GameApp.cpp

示例9: clearData

void ModelBinaryLoader::loadBinaryFile(std::string p_FilePath)
{
	clearData();
	std::ifstream input(p_FilePath, std::istream::in | std::istream::binary);
	if(!input)
	{
		throw std::runtime_error("File could not be opened: " + p_FilePath);
	}
	m_FileHeader = readHeader(&input);
	m_Material = readMaterial(m_FileHeader.m_NumMaterial,&input);
	if(m_FileHeader.m_Animated)
	{
		m_AnimationVertexBuffer = readVertexBufferAnimation(m_FileHeader.m_NumVertex, &input);
		calculateBoundingVolume(m_AnimationVertexBuffer);
	}
	else
	{
		m_VertexBuffer = readVertexBuffer(m_FileHeader.m_NumVertex, &input);
		calculateBoundingVolume(m_VertexBuffer);
	}
	m_MaterialBuffer = readMaterialBuffer(m_FileHeader.m_NumMaterialBuffer, &input);
	
}
开发者ID:BuffBuff,项目名称:GE-Architecture,代码行数:23,代码来源:ModelBinaryLoader.cpp

示例10: if

bool MP3Stream::seek(const Timestamp &where) {
	if (where == _length) {
		_state = MP3_STATE_EOS;
		return true;
	} else if (where > _length) {
		return false;
	}

	const uint32 time = where.msecs();

	mad_timer_t destination;
	mad_timer_set(&destination, time / 1000, time % 1000, 1000);

	if (_state != MP3_STATE_READY || mad_timer_compare(destination, _totalTime) < 0)
		initStream();

	while (mad_timer_compare(destination, _totalTime) > 0 && _state != MP3_STATE_EOS)
		readHeader();

	decodeMP3Data();

	return (_state != MP3_STATE_EOS);
}
开发者ID:Templier,项目名称:residual,代码行数:23,代码来源:mp3.cpp

示例11: readHeader

int 
recvFrom
(Peer *peer, byte *headerBuf, byte *dataBuf)
{	
	 	int headerSize = readHeader(peer, headerBuf, HEADERSIZE);
		
		if(headerSize == 0 )
		{
			printf("Non Header \n");
			return 0;
		}
 
		int length = byteToInt(headerBuf, 8);
		int dataSize   = readData(peer  , dataBuf,   length );

		printf("[ from %s ] type : %d, redesc : %d length : %d data : %s \n",
		 peer->ip, byteToInt(headerBuf,0),
                 byteToInt(headerBuf, 4),
                 byteToInt(headerBuf, 8),
                 dataBuf);

		return (headerSize + dataSize);
}
开发者ID:pooingx2,项目名称:SecretGarden,代码行数:23,代码来源:protocol.c

示例12: decompress

void decompress(InputStream& inputStream, OutputBuffer& output, header* pHeader) {

	header h;
	if (pHeader) {
		h = *pHeader;
	} else {
		readHeader(inputStream, h);
	}

	uint8* pInputBuffer	 = new uint8[h.fileSize];
	uint8* pOutputBuffer = new uint8[h.fileSize];

	ArithmeticDecoder	decoder(inputStream);
	StructuredModel		model(h.increments);
	model.decode(decoder, pInputBuffer, h.tempSize);

	iMTF(pInputBuffer, h.tempSize);
	iBWT(pInputBuffer, pOutputBuffer, h.tempSize, h.first);
	iRLE(pOutputBuffer, pInputBuffer, h.tempSize);

	output.setBuffer(pInputBuffer, h.fileSize);
	delete[] pOutputBuffer;
}
开发者ID:johansten,项目名称:cruelcruncher,代码行数:23,代码来源:decompress.cpp

示例13: readFile

int readFile (char *filename, int *rows, int *cols, PIXEL** bitmap) 
{
  int fd, ret;
  unsigned int start;
  
  if(filename) {
    if((fd = open(filename, O_RDONLY)) < 0) {
      perror("Can't open bmp file to read");
      return -1;
    }
  } else fd = STDIN_FILENO;

  ret = readHeader (fd, rows, cols, &start);
  if(ret) return ret;

  *bitmap = (PIXEL*)malloc(sizeof(PIXEL)*(*rows)*(*cols));
  ret = readBits (fd, *bitmap, *rows, *cols, start);
  if(ret) return ret;

  if(filename) close(fd);

  return 0;
}
开发者ID:liuxfiu,项目名称:teach-COP4338F14,代码行数:23,代码来源:bmplib.c

示例14: readHeader

void MDNS::getResponses() {
  QueryHeader header = readHeader(buffer);

  if ((header.flags & 0x8000) == 0 && header.qdcount > 0) {
    uint8_t count = 0;

    while (count++ < header.qdcount && buffer->available() > 0) {
      Label * label = matcher->match(labels, buffer);

      if (buffer->available() >= 4) {
        uint16_t type = buffer->readUInt16();
        uint16_t cls = buffer->readUInt16();

        if (label != NULL) {

          label->matched(type, cls);
        }
      } else {
        status = "Buffer underflow at index " + buffer->getOffset();
      }
    }
  }
}
开发者ID:glibersat,项目名称:firmware,代码行数:23,代码来源:MDNS.cpp

示例15: getName

bool Table::rewind()
{
  xmlTextReaderPtr reader = NULL;

  if ( (reader = xmlNewTextReaderFilename(getName().c_str())) == NULL)
  {
    cout<<endl<<"Essai d'ouvrir "<< getName() <<endl;
    cout << "erreur fatale " << endl;
    return (false);
  }

  xmlTextReaderRead(reader);

  // initialisation du xmlReader
  setXmlReader(reader);
  // Utilise readHeader()
  readHeader();

  // le tuple courant est 0
  currentTuple = 0;

  return (true);
}
开发者ID:BackupTheBerlios,项目名称:micromegas-svn,代码行数:23,代码来源:table.cpp


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