IChunkFileMemory* CVST2KSPIPlugIn::CreateChunkFile() { CAutoDelete<IChunk> pChunk(IChunk::Create(NULL, 0, 'vstc')); { void* pData; tint32 iSize = mpVSTEffect->dispatcher(mpVSTEffect, effGetChunk, 0, 0, &pData, 0); if (iSize != 0) { // Write parms to chunk pChunk->Write((const tchar*)pData, iSize); } } CAutoDelete<IChunk> pChunk2(IChunk::Create(NULL, 0, 'vstp')); { tint32 iNrOfParams = mpVSTEffect->numParams; if (iNrOfParams > 0) { tfloat32* pData = new tfloat32[iNrOfParams]; tint32 iParam; for (iParam = 0; iParam < iNrOfParams; iParam++) { tfloat32 fValue = mpVSTEffect->getParameter(mpVSTEffect, iParam); pData[iParam] = fValue; } // Write parms to chunk pChunk2->Write((const tchar*)pData, iNrOfParams * sizeof(tfloat32)); } } // Create a chunk file IChunkFileMemory* pFile = IChunkFileMemory::Create(); // Open it tint32 iFileVersion = 1; if (pFile->Open(IFile::FileCreate, iFileVersion) == false) { // Couldn't "open" file, must be wrong format return NULL; } // Add chunks to chunk file pFile->SetChunk(pChunk, true); pFile->SetChunk(pChunk2, true); return pFile; }
bool FGFSIo::parseDataset(QByteArray* data) { int i, index_start, index_end; QList<int> index_list; //DEBUGH( "parsing:", data->data() ); index_list.clear(); i=0; while (i<data->size()) { index_list.append(m_xmlprot->getVarSep().indexIn(*data, i)); if ( index_list.last()==-1 ) { if ( i==0 ) { DEBUGP(LOGWARNING, "deal with silly 1-byte data!! (so no sep)"); return false; } else { index_list.removeLast(); index_list.append(m_xmlprot->getLineSep().indexIn(*data, i)); //last one doesn't have var_sep if (index_list.last()==-1) { DEBUGP(LOGWARNING, "confused by invalid data (no line sep at end)"); return false; } break; } } else { i=index_list.last()+1; // DEBUGP(LOGDEBUG, "cont last chunk search at: " << i); } } if ( index_list.size() != m_xmlprot->getSize()) { DEBUGP(LOGWARNING, "bs happended: split:" << index_list.size() << " expected:" << m_xmlprot->getSize() ); return false; } DEBUGP(LOGBULK, "successful split to chunks:" << index_list.size() << " expected:" << m_xmlprot->getSize() ); index_list.prepend(-m_xmlprot->getVarSep().pattern().size()); i=-1; while (i++ < m_xmlprot->getSize()-1) { index_start=index_list[i]+m_xmlprot->getVarSep().pattern().size(); index_end=index_list[i+1]-index_list[i]-m_xmlprot->getVarSep().pattern().size(); // bit misnamed due to reuse, denotes length not end index here DEBUGP(LOGBULK, "chunk_nr:" << m_xmlprot->getChunkInfo()[i].index.row() << "from:" << index_start << "len:" << index_end ); newFGmsgchunk pChunk(m_xmlprot->getChunkInfo()[i].FgType, m_xmlprot->getChunkInfo()[i].count ); pChunk.m_description.index=m_xmlprot->getChunkInfo()[i].index; int row=pChunk.m_description.index.parent().row(); if (row<0) row=pChunk.m_description.index.row(); #if 0 DEBUGP(LOGWARNING, row << pChunk.m_description.index.internalId() << pChunk.m_description.index.parent().row() << "->" << pChunk.m_description.index.row() ); #endif if (!m_flightstatusmodel->setData(pChunk.m_description.index, data->mid(index_start, index_end))) DEBUGP(LOGWARNING, "Error converting" << m_flightstatusmodel->data(pChunk.m_description.index, Qt::ToolTipRole).toString()) << data->mid(index_start, index_end); } return true; }