void ToBuffer(StreamList& TheVec, char* pBuffer, int& nBuffUsed) { int nNumEntries = TheVec.size(); int nOffset = 0; int nTemp = 0; memcpy(pBuffer, &nNumEntries, sizeof(int)); StreamList::iterator i; nOffset = sizeof(int); for (i = TheVec.begin(); i != TheVec.end(); i++) { nTemp = (*i).first.size(); memcpy(&pBuffer[nOffset], (*i).first.c_str(), nTemp); nOffset += nTemp; pBuffer[nOffset] = '\0'; nOffset += sizeof(char); nTemp = (*i).second.size(); memcpy(&pBuffer[nOffset], (*i).second.c_str(), nTemp); nOffset += nTemp; pBuffer[nOffset] = '\0'; nOffset += sizeof(char); } nBuffUsed = nOffset; }
int BufSize(StreamList& TheVec) { int nBufSize = TheVec.size() * (sizeof(char)*2); nBufSize += sizeof(int); StreamList::iterator i; for (i = TheVec.begin(); i != TheVec.end(); i++) { nBufSize += (*i).first.size() + (*i).second.size(); } return nBufSize; }
BufferedStream::BufferedStream(CompilerScratch* csb, RecordSource* next) : m_next(next), m_map(csb->csb_pool) { fb_assert(m_next); m_impure = CMP_impure(csb, sizeof(Impure)); StreamList streams; m_next->findUsedStreams(streams); Array<dsc> fields; for (StreamList::iterator i = streams.begin(); i != streams.end(); ++i) { const StreamType stream = *i; CompilerScratch::csb_repeat* const tail = &csb->csb_rpt[stream]; UInt32Bitmap::Accessor accessor(tail->csb_fields); if (accessor.getFirst()) { do { const USHORT id = (USHORT) accessor.current(); const Format* const format = tail->csb_format; // CMP_format(tdbb, csb, stream); const dsc* const desc = &format->fmt_desc[id]; m_map.add(FieldMap(FieldMap::REGULAR_FIELD, stream, id)); fields.add(*desc); } while (accessor.getNext()); } dsc desc; desc.makeLong(0); m_map.add(FieldMap(FieldMap::TRANSACTION_ID, stream, 0)); fields.add(desc); desc.makeInt64(0); m_map.add(FieldMap(FieldMap::DBKEY_NUMBER, stream, 0)); fields.add(desc); desc.makeText(1, CS_BINARY); m_map.add(FieldMap(FieldMap::DBKEY_VALID, stream, 0)); fields.add(desc); } const size_t count = fields.getCount(); Format* const format = Format::newFormat(csb->csb_pool, count); format->fmt_length = FLAG_BYTES(count); for (size_t i = 0; i < count; i++) { dsc& desc = format->fmt_desc[i] = fields[i]; if (desc.dsc_dtype >= dtype_aligned) format->fmt_length = FB_ALIGN(format->fmt_length, type_alignments[desc.dsc_dtype]); desc.dsc_address = (UCHAR*)(IPTR) format->fmt_length; format->fmt_length += desc.dsc_length; } m_format = format; }