XML ファイル内のすべてのタグを取得するためのカスタム関数を作成しています。私はこのコードを使用しています:
wchar_t *GetLine(wchar_t *fileName=L"indexing.xml", wchar_t endSymbol = '\n')
{
SetFilePointer(hReadFile,sizeof(wchar_t) * position, NULL, FILE_BEGIN);
int size;
wchar_t wchr[1];
DWORD dw;
size = 0;
do
{
ReadFile(hReadFile, wchr, sizeof(wchar_t), &dw, NULL);
if(!dw)
{
break;
}
tempGetLine[size] = wchr[0];
size++;
}while(wchr[0] != endSymbol);
tempGetLine[size] = '\0';
position += (size);
return tempGetLine;
}
wchar_t *GetTag(wchar_t *fileName = L"indexing.xml")
{
wchar_t *temp = GetLine(fileName,'>');
int i = 0;
while(*temp != '\0')
{
tempTag[i] = *temp;
i++;
temp++;
}
tempTag[i] = '\0';
return tempTag;
}
動作しますが、大きなファイルでは多くの反復が必要です。コードを最適化するにはどうすればよいですか?