M
microming
Unregistered / Unconfirmed
GUEST, unregistred user!
近日在网上得到一C++BUILDER的程序,是一个转换的过程。我只能以学DELPHI的功力把其看懂
但不知如何转换为DELPHI的程序,因为其中用到很多指针,那些汉字是我翻译的。只能说个大概。
哪位大虾可否帮我译为DELPHI的源程,最好详细一点,本人说话算话,愿以200大洋相赠!
void ConvertSaveData(TStream *SaveData, TStream *OutStream)//参数为一内存数据流
{
TMemoryStream *header, *buffer, *bufIndex; //定义指针
char item1[8], item2[8]; //定义数指
long n; //整型变量
unsigned short w; //短整变量
header = new TMemoryStream; //开避内存区域,多大呢???
buffer = new TMemoryStream; //开避内存区域,多大呢???
bufIndex = new TMemoryStream; //开避内存区域,多大呢???
while(SaveData->Position<SaveData->Size) //比较指针是否超界,??:此时的POSITiON在何处,0或1
{
//process header
SaveData->ReadBuffer(item1, 8); //从SAVEDATA读取8个字符至ITEM1
header->Seek(0, soFromBeginning); //??是否为定位于第0个字符
while(header->Position<header->Size) //同上
{
header->ReadBuffer(item2, 8); //读8个字符,此时指针在第0位开始
if(memcmp(item1,item2,8) == 0) //比较8个字符
goto HEADER_EXIST; //相等转
}
//add to header
header->Seek(0,soFromEnd);//??定位于最后的什么地方
header->WriteBuffer(item1, 8); //写缓存
HEADER_EXIST:
//process buffer index & buffer
n = buffer->Position;// ???此时的N 在什么地方呢?
bufIndex->WriteBuffer(&n, sizeof);//??有写入吗?
buffer->WriteBuffer(item1,8); //put the header
while(true)
{
if(SaveData->Position>=SaveData->Size)
break;
SaveData->ReadBuffer(&w,2); //读
buffer->WriteBuffer(&w,2); //写
if(w == 0xafaf) //标志
break;
}
}
//prepare outStream//未译
n = header->Size;
header->Seek(0,soFromBeginning);
OutStream->WriteBuffer(&n,4);
OutStream->CopyFrom(header,n);
n = bufIndex->Size;
bufIndex->Seek(0,soFromBeginning);
OutStream->WriteBuffer(&n,4);
OutStream->CopyFrom(bufIndex,n);
n = buffer->Size;
buffer->Seek(0,soFromBeginning);
OutStream->WriteBuffer(&n,4);
OutStream->CopyFrom(buffer,n);
delete header;
delete buffer;
delete bufIndex;
}
但不知如何转换为DELPHI的程序,因为其中用到很多指针,那些汉字是我翻译的。只能说个大概。
哪位大虾可否帮我译为DELPHI的源程,最好详细一点,本人说话算话,愿以200大洋相赠!
void ConvertSaveData(TStream *SaveData, TStream *OutStream)//参数为一内存数据流
{
TMemoryStream *header, *buffer, *bufIndex; //定义指针
char item1[8], item2[8]; //定义数指
long n; //整型变量
unsigned short w; //短整变量
header = new TMemoryStream; //开避内存区域,多大呢???
buffer = new TMemoryStream; //开避内存区域,多大呢???
bufIndex = new TMemoryStream; //开避内存区域,多大呢???
while(SaveData->Position<SaveData->Size) //比较指针是否超界,??:此时的POSITiON在何处,0或1
{
//process header
SaveData->ReadBuffer(item1, 8); //从SAVEDATA读取8个字符至ITEM1
header->Seek(0, soFromBeginning); //??是否为定位于第0个字符
while(header->Position<header->Size) //同上
{
header->ReadBuffer(item2, 8); //读8个字符,此时指针在第0位开始
if(memcmp(item1,item2,8) == 0) //比较8个字符
goto HEADER_EXIST; //相等转
}
//add to header
header->Seek(0,soFromEnd);//??定位于最后的什么地方
header->WriteBuffer(item1, 8); //写缓存
HEADER_EXIST:
//process buffer index & buffer
n = buffer->Position;// ???此时的N 在什么地方呢?
bufIndex->WriteBuffer(&n, sizeof);//??有写入吗?
buffer->WriteBuffer(item1,8); //put the header
while(true)
{
if(SaveData->Position>=SaveData->Size)
break;
SaveData->ReadBuffer(&w,2); //读
buffer->WriteBuffer(&w,2); //写
if(w == 0xafaf) //标志
break;
}
}
//prepare outStream//未译
n = header->Size;
header->Seek(0,soFromBeginning);
OutStream->WriteBuffer(&n,4);
OutStream->CopyFrom(header,n);
n = bufIndex->Size;
bufIndex->Seek(0,soFromBeginning);
OutStream->WriteBuffer(&n,4);
OutStream->CopyFrom(bufIndex,n);
n = buffer->Size;
buffer->Seek(0,soFromBeginning);
OutStream->WriteBuffer(&n,4);
OutStream->CopyFrom(buffer,n);
delete header;
delete buffer;
delete bufIndex;
}