void COFFFileEmit( owl_file_handle file ) { //***************************************** prepareExportSection( file ); prepareStringTable( file ); calcNumSymbols( file ); calcSectionOffsets( file ); calcLineNumSymbolIndices( file ); emitFileHeader( file ); emitSectionHeaders( file ); emitSectionData( file ); emitSymbolTable( file ); emitStringTable( file ); }
bool PrimitiveBlockOutputAdaptor::flush(std::string & buffer) { if (!m_PrimitiveBlock->IsInitialized()) return false; // prepare string table output cache uint32_t * stringIdTable = prepareStringTable(); // prepare plain nodes if (m_PlainNodesGroup) prepareNodes(m_PlainNodesGroup, stringIdTable); // prepare dense nodes if (m_DenseNodesGroup) { prepareNodes(m_DenseNodesGroup, stringIdTable); int64_t prevLat = 0, prevLon = 0, prevId = 0; google::protobuf::RepeatedPtrField<crosby::binary::Node>::const_iterator nodeIt = m_DenseNodesGroup->nodes().begin(); while (nodeIt != m_DenseNodesGroup->nodes().end()) { m_DenseNodesGroup->mutable_dense()->add_id(nodeIt->id() - prevId); m_DenseNodesGroup->mutable_dense()->add_lat(nodeIt->lat() - prevLat); m_DenseNodesGroup->mutable_dense()->add_lon(nodeIt->lon() - prevLon); prevId = nodeIt->id(); prevLat = nodeIt->lat(); prevLon = nodeIt->lon(); for (int i = 0; i < nodeIt->keys_size(); ++i) { m_DenseNodesGroup->mutable_dense()->add_keys_vals(nodeIt->keys(i)); m_DenseNodesGroup->mutable_dense()->add_keys_vals(nodeIt->vals(i)); } m_DenseNodesGroup->mutable_dense()->add_keys_vals(0); ++nodeIt; } m_DenseNodesGroup->clear_nodes(); } // prepare ways if (m_WaysGroup) { google::protobuf::RepeatedPtrField<crosby::binary::Way>::iterator wayIt = m_WaysGroup->mutable_ways()->begin(); int realSize; while (wayIt != m_WaysGroup->mutable_ways()->end()) { // encode and clean refs realSize = deltaEncodeClean<int64_t>(wayIt->mutable_refs()->mutable_data(), wayIt->mutable_refs()->mutable_data() + wayIt->refs_size(), -1); wayIt->mutable_refs()->Truncate(realSize); cleanUpTags<crosby::binary::Way>(*wayIt, stringIdTable); ++wayIt; } } delete[] stringIdTable; assert(m_PrimitiveBlock->IsInitialized()); m_PrimitiveBlock->SerializeToString(&buffer); delete m_PrimitiveBlock; m_PrimitiveBlock = new crosby::binary::PrimitiveBlock(); m_PlainNodesGroup = NULL; m_DenseNodesGroup = NULL; m_WaysGroup = NULL; m_RelationsGroup = NULL; // add empty string table cache entry m_PrimitiveBlock->mutable_stringtable()->add_s(std::string()); return true; }