// Include bCini7
#define bCini7_Open fopen
#define bCini7_Exists fexist
#define bCini7_Write fwrite
#define bCini7_Read fread
#define bCini7_Close fclose
#define bCini7_Create(%0) if(!bCini7_Exists(%0)) bCini7_Close(bCini7_Open(%0,io_write)) && bCini7_OpenArchive(%0)
#define bCini7_Delete(%0) if(bCini7_Exists(%0)) fremove(%0)
// Variables
stock bCini7_Archive_Name[64] = "null",bCini7_Archive_Line[100][32],bCini7_Archive_Value[100][32],bCini7_Lines_Archive,bCini7_Line_ID,bCini7_Archive_Is_Used,File:bCini7_File_Open,bCini7_File_Var[64],bCini7_System_Lines[2],bCini7_Var_x,bCini7_Archive_Format[64],bCini7_Archive_Format_2[64];
// Definitions
#define bCini7_SetInt(%0,%1,%2) format(bCini7_Archive_Format_2,64,"%d",%2) && bCini7_SetText(%0,%1,bCini7_Archive_Format_2)
#define bCini7_SetFloat(%0,%1,%2) format(bCini7_Archive_Format_2,64,"%f",%2) && bCini7_SetText(%0,%1,bCini7_Archive_Format_2)
#define bCini7_ReadInt(%0,%1) strval(bCini7_ReadText(%0,%1))
#define bCini7_ReadFloat(%0,%1) floatstr(bCini7_ReadText(%0,%1))
#define bCini7_Log(%0,%1) bCini7_File_Open = bCini7_Open(%0,io_append); bCini7_Write(bCini7_File_Open,%1) && bCini7_Close(bCini7_File_Open)
// Used functions
stock bCini7_SetText(archive[],line[],value[])
{
bCini7_OpenArchive(archive);
bCini7_Line_ID = bCini7_GetLineID(line);
if(bCini7_Line_ID == bCini7_Lines_Archive+1)
{
++bCini7_Lines_Archive;
SetSVarInt(line,bCini7_Lines_Archive);
}
strunpack(bCini7_Archive_Line[bCini7_Line_ID],line);
strunpack(bCini7_Archive_Value[bCini7_Line_ID],value);
bCini7_Archive_Is_Used = 1;
bCini7_Archive_Format = "";
return 1;
}
stock bCini7_ReadText(archive[],line[])
{
bCini7_Archive_Format = "";
bCini7_OpenArchive(archive);
strunpack(bCini7_Archive_Format,bCini7_Archive_Value[bCini7_GetLineID(line)]);
return bCini7_Archive_Format;
}
stock bCini7_IsSet(archive[],line[])
{
bCini7_OpenArchive(archive);
if(bCini7_GetLineID(line) ^ bCini7_Lines_Archive+1)
{
return 1;
}
return 0;
}
stock bCini7_DeleteSet(archive[],line[])
{
bCini7_OpenArchive(archive);
bCini7_Line_ID = bCini7_GetLineID(line);
if(bCini7_Line_ID ^ bCini7_Lines_Archive+1)
{
return 1;
}
strunpack(bCini7_Archive_Value[bCini7_Line_ID],"");
bCini7_Archive_Is_Used = 1;
return 1;
}
stock bCini7_Copy(archive_1[],archive_2[],bool:delete_archive)
{
if(!archive_1[0] || !archive_2[0] || !bCini7_Exists(archive_1) || bCini7_Exists(archive_2)) // Is needed
{
return 1;
}
bCini7_OpenArchive(archive_1);
bCini7_File_Open = bCini7_Open(archive_2,io_write);
bCini7_Var_x = 0;
bCini7_Archive_Format = "";
while(bCini7_Var_x <= bCini7_Lines_Archive)
{
format(bCini7_Archive_Format,64,"%s=%s\r\n",bCini7_Archive_Line[bCini7_Var_x],bCini7_Archive_Value[bCini7_Var_x]);
if(bCini7_Archive_Format[0] ^ '=')
{
bCini7_Write(bCini7_File_Open,bCini7_Archive_Format);
}
++bCini7_Var_x;
}
bCini7_Close(bCini7_File_Open);
bCini7_Var_x = 0;
if(delete_archive)
{
bCini7_Delete(archive_1);
}
return 1;
}
// Unused functions
stock bCini7_OpenArchive(archive[])
{
if(!archive[0] || strcmp(bCini7_Archive_Name,archive,true) == 0)
{
return 1;
}
if(strcmp(bCini7_Archive_Name,archive,false))
{
bCini7_CloseArchive();
}
strunpack(bCini7_Archive_Name,archive);
if(!bCini7_Exists(archive))
{
bCini7_Create(archive);
}
else
{
bCini7_File_Open = bCini7_Open(archive,io_read);
while(bCini7_Read(bCini7_File_Open,bCini7_File_Var))
{
if(bCini7_File_Var[0])
{
if(bCini7_File_Var[0] >= 255)
{
strdel(bCini7_File_Var,0,1);
}
bCini7_System_Lines[0] = strlen(bCini7_File_Var);
if(bCini7_File_Var[bCini7_System_Lines[0]-1] == '\r' || bCini7_File_Var[bCini7_System_Lines[0]-1] == '\n')
{
bCini7_File_Var[bCini7_System_Lines[0]-1] = 0;
}
if(bCini7_File_Var[bCini7_System_Lines[0]-2] == '\r' || bCini7_File_Var[bCini7_System_Lines[0]-2] == '\n')
{
bCini7_File_Var[bCini7_System_Lines[0]-2] = 0;
}
bCini7_System_Lines[1] = strfind(bCini7_File_Var,"=");
strmid(bCini7_Archive_Line[bCini7_Lines_Archive],bCini7_File_Var,0,bCini7_System_Lines[1],bCini7_System_Lines[1]+1);
strmid(bCini7_Archive_Value[bCini7_Lines_Archive],bCini7_File_Var,bCini7_System_Lines[1]+1,bCini7_System_Lines[0]);
SetSVarInt(bCini7_Archive_Line[bCini7_Lines_Archive],bCini7_Lines_Archive);
++bCini7_Lines_Archive;
}
else
{
break;
}
}
bCini7_Close(bCini7_File_Open);
}
bCini7_Archive_Format = "";
return 1;
}
stock bCini7_GetLineID(line[])
{
if(GetSVarType(line))
{
return GetSVarInt(line);
}
else
{
return bCini7_Lines_Archive+1;
}
}
stock bCini7_CloseArchive()
{
bCini7_Var_x = 0;
bCini7_Archive_Format = "";
if(!bCini7_Exists(bCini7_Archive_Name) || !bCini7_Archive_Is_Used)
{
while(bCini7_Var_x <= bCini7_Lines_Archive)
{
DeleteSVar(bCini7_Archive_Line[bCini7_Var_x]);
bCini7_Archive_Line[bCini7_Var_x][0] = 0;
bCini7_Archive_Value[bCini7_Var_x][0] = 0;
++bCini7_Var_x;
}
}
else
{
bCini7_File_Open = bCini7_Open(bCini7_Archive_Name,io_write);
while(bCini7_Var_x <= bCini7_Lines_Archive)
{
format(bCini7_Archive_Format,64,"%s=%s\r\n",bCini7_Archive_Line[bCini7_Var_x],bCini7_Archive_Value[bCini7_Var_x]);
if(bCini7_Archive_Format[0] ^ '=')
{
bCini7_Write(bCini7_File_Open,bCini7_Archive_Format);
}
DeleteSVar(bCini7_Archive_Line[bCini7_Var_x]);
bCini7_Archive_Line[bCini7_Var_x][0] = 0;
bCini7_Archive_Value[bCini7_Var_x][0] = 0;
++bCini7_Var_x;
}
bCini7_Close(bCini7_File_Open);
}
bCini7_Var_x = 0;
bCini7_Archive_Name = "null";
bCini7_Lines_Archive = 0;
bCini7_Archive_Is_Used = 0;
bCini7_Archive_Format = "";
}
// End of include
main()
{
// Escrita
new Timer = GetTickCount(),Fala[64];
for(new i; i < 5000; ++i)
{
format(Fala,sizeof(Fala),"Arquivos/Teste bCini7 x DOF2.%d",i);
bCini7_SetText(Fala,"Este","Teste");
bCini7_SetInt(Fala,"Й",1);
bCini7_SetText(Fala,"Teste","Comparativo");
bCini7_SetText(Fala,"Das","Includes");
bCini7_SetText(Fala,"bCini7","e");
bCini7_SetInt(Fala,"DOF",2);
}
bCini7_CloseArchive();
printf("Escrita - bCini7 - %d ms",GetTickCount()-Timer);
Timer = GetTickCount();
for(new i; i < 5000; ++i)
{
format(Fala,sizeof(Fala),"Arquivos/Teste DOF2 x bCini7.%d",i);
DOF2_CreateFile(Fala);
DOF2_SetString(Fala,"Este","Teste");
DOF2_SetInt(Fala,"Й",1);
DOF2_SetString(Fala,"Teste","Comparativo");
DOF2_SetString(Fala,"Das","Includes");
DOF2_SetString(Fala,"bCini7","e");
DOF2_SetInt(Fala,"DOF",2);
}
DOF2_Exit();
printf("Escrita - DOF2 - %d ms",GetTickCount()-Timer);
Timer = GetTickCount();
// Leitura
for(new i; i < 5000; ++i)
{
format(Fala,sizeof(Fala),"Arquivos/Teste bCini7 x DOF2.%d",i);
bCini7_ReadText(Fala,"Este");
bCini7_ReadInt(Fala,"Й");
bCini7_ReadText(Fala,"Teste");
bCini7_ReadText(Fala,"Das");
bCini7_ReadText(Fala,"bCini7");
bCini7_ReadInt(Fala,"DOF");
}
bCini7_CloseArchive();
printf("Leitura - bCini7 - %d ms",GetTickCount()-Timer);
Timer = GetTickCount();
for(new i; i < 5000; ++i)
{
format(Fala,sizeof(Fala),"Arquivos/Teste DOF2 x bCini7.%d",i);
DOF2_GetString(Fala,"Este");
DOF2_GetInt(Fala,"Й");
DOF2_GetString(Fala,"Teste");
DOF2_GetString(Fala,"Das");
DOF2_GetString(Fala,"bCini7");
DOF2_GetInt(Fala,"DOF");
}
DOF2_Exit();
printf("Leitura - DOF2 - %d ms",GetTickCount()-Timer);
}
Seu teste de velocidade й tгo enganoso quanto seu include.
Iludido aquele que nгo lк, e da gratificaзхes .-. |
Seu teste de velocidade й tгo enganoso quanto seu include.
Iludido aquele que nгo lк, e da gratificaзхes .-. |
Dei olhada no cуdigo rapida e se tivesse visto eu nгo posso testar no momento, essa indireta noob foi inъtil.
Nгo tens porque ficar sempre a criticar essas crнticas estupidas parace um noob que nгo sabe porra nenhuma do que fala. Esta include realmente melhorou bastante dado que que era no passado, acho que a mгo do will ajudou muito tbm |