bool Checksum::ReadFromFile(const char* inFilename) { bool theSuccess = false; this->mChecksumList.clear(); ifstream theStream(inFilename); if(theStream.is_open()) { string theStartString; theStream >> theStartString; // Read in num checksums int theNumChecksums = 0; theStream >> theNumChecksums; // Read in pairs of checksums for(int i = 0; i < theNumChecksums; i++) { string theFormattedString; theStream >> theFormattedString; ChecksumEntry theNewEntry; theNewEntry.SetFromFormattedString(theFormattedString); this->mChecksumList.push_back(theNewEntry); } string theEndString; theStream >> theEndString; theStream.close(); }
void ZASParser::ParseHandler_Prettify::ParsedBinary(const ZStreamR& iStream) { if (fDumpBinaries) { if (fInBlock) spWriteIndent(fStrimW, fIndent); // Let's see if we've got more than 16 bytes. We only have a read // stream, so we can't _ask_ how many bytes would be physically // readable (CountReadable only provides a lower limit, and // can return zero even when there's data available). So we // have to actually suck it and see. We use a ZStreamR_DynamicBuffered, // which lets us read the stream, then return the read bytes to // be re-read if it turns out we've got enough to warrant doing // indentation. ZStreamRWPos_RAM theStreamRAM; ZStreamR_DynamicBuffered theStream(iStream, theStreamRAM); uint64 countSkipped; theStream.Skip(17, &countSkipped); theStream.Rewind(); theStream.Commit(); if (countSkipped <= 16) { // We've got 16 or fewer bytes, emit them on the same line. fStrimW.Write("binary { "); ZStreamW_HexStrim(" ", "", 16, fStrimW).CopyAllFrom(theStream, nullptr, nullptr); fStrimW.Write(" }\n"); } else { // We've got more than 16 bytes, break them up into nice lines. fStrimW.Write("binary\n"); spWriteIndent(fStrimW, fIndent + 1); fStrimW.Write("{"); uint64 size; string chunkSeparator = "\n" + string(fIndent + 1, '\t'); ZStreamW_HexStrim(" ", chunkSeparator, 16, fStrimW) .CopyAllFrom(theStream, &size, nullptr); fStrimW.Write("\n"); spWriteIndent(fStrimW, fIndent + 1); fStrimW.Writef("} // %lld bytes\n", size); } } else { uint64 size; iStream.SkipAll(&size); if (fInBlock) spWriteIndent(fStrimW, fIndent); fStrimW.Writef("binary { /* content not shown */ } // %d bytes\n", size); } }
void CAHALAudioDevice::GetCurrentPhysicalFormats(bool inIsInput, UInt32& ioNumberStreams, AudioStreamBasicDescription* outFormats) const { ioNumberStreams = std::min(ioNumberStreams, GetNumberStreams(inIsInput)); for(UInt32 theIndex = 0; theIndex < ioNumberStreams; ++theIndex) { CAHALAudioStream theStream(GetStreamByIndex(inIsInput, theIndex)); theStream.GetCurrentPhysicalFormat(outFormats[theIndex]); } }
UninflatedMessage* SmallMessageHelper::deflate() const { std::vector<byte> theBuffer(kSmallMessageBufferSize); AOStreamBE theStream(&(theBuffer[0]), theBuffer.size()); reallyDeflateTo(theStream); UninflatedMessage* theDeflatedMessage = new UninflatedMessage(type(), theStream.tellp()); memcpy(theDeflatedMessage->buffer(), &(theBuffer[0]), theDeflatedMessage->length()); return theDeflatedMessage; }
bool GameApp::init() { bool retVal = Game::init(); if( retVal == false ) { return false; } mpMessageManager = new GameMessageManager(); //create and load the Grid, GridBuffer, and GridRenderer mpGrid = new Grid(mpGraphicsSystem->getWidth(), mpGraphicsSystem->getHeight(), GRID_SQUARE_SIZE); mpGridVisualizer = new GridVisualizer( mpGrid ); std::ifstream theStream( gFileName ); mpGrid->load( theStream ); //create the GridGraph for pathfinding mpGridGraph = new GridGraph(mpGrid); //init the nodes and connections mpGridGraph->init(); //mpPathfinder = new DijkstraPathfinder(mpGridGraph); mpPathfinder = new AStarPathfinder(mpGridGraph); //mpPathfinder = new DepthFirstPathfinder(mpGridGraph); //load buffers mpGraphicsBufferManager->loadBuffer( BACKGROUND_ID, "wallpaper.bmp"); //setup sprites GraphicsBuffer* pBackGroundBuffer = mpGraphicsBufferManager->getBuffer( BACKGROUND_ID ); if( pBackGroundBuffer != NULL ) { mpSpriteManager->createAndManageSprite( BACKGROUND_SPRITE_ID, pBackGroundBuffer, 0, 0, pBackGroundBuffer->getWidth(), pBackGroundBuffer->getHeight() ); } mpInputHandler = new InputManager(); mpInputHandler->init(); //debug display PathfindingDebugContent* pContent = new PathfindingDebugContent( mpPathfinder ); mpDebugDisplay = new DebugDisplay( Vector2D(0,12), pContent ); mpMasterTimer->start(); return true; }
bool SmallMessageHelper::inflateFrom(const UninflatedMessage& inUninflated) { AIStreamBE theStream(inUninflated.buffer(), inUninflated.length()); return reallyInflateFrom(theStream); }