Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Lísias de Castro

Universe banco de dados

Recommended Posts

Esse é um banco de dados criado com a biblioteca padrão na linguagem c.

Para baixa-lo basta clicar no link do video abaixo. Lá você encontrara informações

de como linkar a biblioteca e um link para baixa-la.

E aqui esta a api para que tiver alguma duvida.

 

char * UNIVERSE_FUNCTION LocalPath();
LocalPath return the current path of your application.
STATUS UNIVERSE_FUNCTION Exists(char * Name,char * Dir);
Exists return On if there is a file or folder with the Name field inside the Dir.
STRING UNIVERSE_FUNCTION Write(const char * ToWrite);
Write put the ToWrite value into a STRING type.
void UNIVERSE_FUNCTION CreateUniverse(PUNIVERSE ToCreate,const char * Clan,const char * Class);
CreateUniverse will get the Clan and Class. It will Create a folder named Universe in
your local Path and inside it will create a folder with the Clan name. Inside the Clan
folder will be created two files. One will be the name of the Class.CFG and the other Class.DATA.
The first file has the class field and the secound has the data itself.
If there is no data it returns ToCreate->Class.Max = 0 and ToCreate->Data.Max to be checked
by the MaxClass and MaxData.
STATUS UNIVERSE_FUNCTION MaxClass(UNIVERSE ToCheck);
MaxClass will return Off if ToCheck.Class.Max is Equal 0
void UNIVERSE_FUNCTION InsertClass(PUNIVERSE ToInsert,const char * Type,const char * Value);
InsertClass will insert the Type and Value into ToInsert->Class.Type and ToInsert->Class.Value
and Increase ToInsert->Class.Max each time you call it.
void UNIVERSE_FUNCTION SaveClass(UNIVERSE ToSave);
SaveClass will save the informations from ToSave into Class.CFG file
STATUS UNIVERSE_FUNCTION MaxData(UNIVERSE ToCheck);
MaxData returns Off if ToCheck.Data.Max is equal 0, otherwise returns On
void UNIVERSE_FUNCTION StartData(UNIVERSE ToStart);
StartData will start the temp data to be avaliated with your actual data.
You have to call it each time you want to insert new field into your database.
void UNIVERSE_FUNCTION AppendData(char * Type,char * Value);
AppendData will insert the Type and Value into the temp data to be avaliated with
your actual data.
STATUS UNIVERSE_FUNCTION Equal(UNIVERSE ToCompare,char * ClassValue);
Equal will compare temp data and ToCompare. It will return On if ClassValue
exists inside ToCompare. Otherwise it will return Off. The ClassValue use to
be a key value, like an Id which does not repeat in the database.
void UNIVERSE_FUNCTION InsertData(PUNIVERSE ToInsert);
InsertData will put the temp data fields into ToInsert.
In order to save it into the file you must call SaveLastData.
void UNIVERSE_FUNCTION SaveLastData(UNIVERSE ToSave);
SaveLastData will save the last ToSave informations into the Class.DATA.
void UNIVERSE_FUNCTION SaveAllData(UNIVERSE ToSave);
SaveAllData will replace all the informations from ToSave into Class.Data
STATUS UNIVERSE_FUNCTION ModifyData(PUNIVERSE ToModify,char * Key);
ModifyData will look for the Key inside ToModify. If it finds the key it will return On.
if it returns On you must call SaveAllData in order to modify Class.CFG file.
void UNIVERSE_FUNCTION RemoveClassFile(PUNIVERSE ToRemove);
RemoveClassFile removes the Class.CFG and restart ToRemove->Class.Type,ToRemove->Class.Value and ToRemove->Data.Buffer.
void UNIVERSE_FUNCTION RemoveDataFile(PUNIVERSE ToRemove);
RemoveDataFile Removes the Class.DATA and restart ToRemove->Data.Buffer.
char * UNIVERSE_FUNCTION DoubleToString(double ToConvert);
DoubleToString converts ToConvert into char type.
char * UNIVERSE_FUNCTION IntToString(int ToConvert);
IntToString converts ToConvert into int type.
void UNIVERSE_FUNCTION LoadImg(PIMAGE ToCreate,char * Clan);
LoadImage loads the images from the clan. You don't need to call it, because the
LoadObject already does.
void UNIVERSE_FUNCTION LoadSound(PIMAGE ToCreate,char * Clan);
LoadSound loads the sound from the clan. You don't need to call it, because the
LoadObject already does.
void UNIVERSE_FUNCTION LoadObject(POBJECT ToCreate,char * Clan,char * Id);
LoadObject loads the object, image and sound informations from the file.
They are logical information. I have made it in order to adaptate with the
graphic libraries.
double UNIVERSE_FUNCTION Width(POBJECT Object,double ToChange);
Width changes the Object.Width and Object.WidthOffset values passed by ToChange and returns its changes.
double UNIVERSE_FUNCTION Height(POBJECT Object,double ToChange);
Height works like Width but in the Height field.
double UNIVERSE_FUNCTION WidthSize(POBJECT Object,double ToChange)
WidthSize is used to scale the Object->Width. It is multiplied by Object->Width.
double UNIVERSE_FUNCTION HeightSize(POBJECT Object,double ToChange)
HeightSize works like WidthSize but in the HeightSize field.
double UNIVERSE_FUNCTION XSpeed(POBJECT Object,double ToChange);
XSpeed is used to modify the Object->XSpeed value passed by ToChange.
It afects the XSpeed of every X fields.
double UNIVERSE_FUNCTION YSpeed(POBJECT Object,double ToChange);
YSpeed works just like XSpeed but in the YSpeed.
STATUS UNIVERSE_FUNCTION XAround(OBJECT Object,double Min,double Max);
XAround verifies if Object.X is inside the Min and Max field and returns On if it is.
STATUS UNIVERSE_FUNCTION XIncrease(POBJECT Object,double Max);
XIncrease increases the Object->X in the Object->XSpeed until Max field.
STATUS UNIVERSE_FUNCTION XDecrease(POBJECT Object,double Min);
XDecrease decreases the Object->X in the Object->XSpeed until Min field.
STATUS UNIVERSE_FUNCTION YAround(OBJECT Object,double Min,double Max);
YAround works just like XAround but verifying Object.Y.
STATUS UNIVERSE_FUNCTION YIncrease(POBJECT Object,double Max);
YIncrease works just like XIncrease buf affection Object->Y.
STATUS UNIVERSE_FUNCTION YDecrease(POBJECT Object,double Min);
YDecrease works like XDecrese but verifies Object->Y.
STATUS UNIVERSE_FUNCTION XViewAround(OBJECT Object,double Begin,double End);
XViewAround verifies if Object.XView is inside Begin and End field.
STATUS UNIVERSE_FUNCTION XViewIncrease(POBJECT Object,double Max);
Works like XIncrease but affects Object->XView.
STATUS UNIVERSE_FUNCTION XViewDecrease(POBJECT Object,double Min);
XViewIncrease Works like XDecrease but affects Object->YView.
STATUS UNIVERSE_FUNCTION YViewAround(OBJECT Object,double Begin,double End);
YViewAround verifies if Object.YView is inside Begin and End field.
STATUS UNIVERSE_FUNCTION YViewIncrease(POBJECT Object,double Max);
YViewIncrease Works like XViewIncrease but affects Object->YView.
STATUS UNIVERSE_FUNCTION YViewDecrease(POBJECT Object,double Min);
Works like XDecrease but affects Object->YView.
STATUS UNIVERSE_FUNCTION XScrollAround(OBJECT Object,double Begin,double End);
XScrollAround verifies if Object.XScroll is inside Begin and End field.
STATUS UNIVERSE_FUNCTION XScrollIncrease(POBJECT Object,double Max);
XScrollIncrease works like XIncrese but affects Object->XScroll.
STATUS UNIVERSE_FUNCTION XScrollDecrease(POBJECT Object,double Min);
XScrollDecrease works like YDecrease but affects Object->XScroll.
STATUS UNIVERSE_FUNCTION YScrollAround(OBJECT Object,double Begin,double End);
YScrollAround works like XAround and the other around functions.
STATUS UNIVERSE_FUNCTION YScrollIncrease(POBJECT Object,double Max);
YScrollIncrease works like YIncrease but affects Object->YScroll field
STATUS UNIVERSE_FUNCTION YScrollDecrease(POBJECT Object,double Min);
YScrollDecrease works like YDecrease but affects Object->YScroll field
void UNIVERSE_FUNCTION InsertImage(POBJECT ToInsert,char * Name,char * Path,char * Action);
InsertImage inserts the fields Name,Path and Actions into the ToInsert->ImageInfo.Name,ToInsert->ImageInfo.Path
ToInsert->ImageInfo.Action. It inserts the Object->ID field into the ToInsert->ImageInfo.Pattern in order to
link them.
void UNIVERSE_FUNCTION SaveImage(OBJECT ToInsert);
SaveImage saves ToInsert.ImageInfo into the file.
void UNIVERSE_FUNCTION InsertSound(POBJECT ToInsert,char * Name,char * Path);
InsertSound inserts the Name and Path into ToInsert.SoundInformation. It inserts ToInsert.ID into
ToInsert.SoundInformation.Pattern in order to link them.
double UNIVERSE_FUNCTION SoundVolume(POBJECT ToChange,double Volume);
SoundVolume changes the ToChange->SoundInfo.Volume to Volume field.
double UNIVERSE_FUNCTION SoundBalance(POBJECT ToChange,double Balance);
SoundBalance changes the ToChange->SoundInfo.Balance to Balance field.
double UNIVERSE_FUNCTION SoundSpeed(POBJECT ToChange,double Speed);
SoundSpeed changes the ToChange->SoundInfo.Speed to Speed field.
void UNIVERSE_FUNCTION SaveSound(OBJECT ToSave);
SaveSound saves ToSave.SoundInfo into file.
You won't need to can it, because the SaveObject already does.
void UNIVERSE_FUNCTION SaveObject(OBJECT ToSave);
SaveObject saves Object information and Object.ImageInfo and Object.SoundInfo into file.


Esse é um banco de dados criado com a biblioteca padrão na linguagem c.

Para baixa-lo basta clicar no link do video abaixo. Lá você encontrara informações

de como linkar a biblioteca e um link para baixa-la.

E aqui esta a api para que tiver alguma duvida.

http://youtu.be/eoBnIU0QsVE

 

char * UNIVERSE_FUNCTION LocalPath();
LocalPath return the current path of your application.
STATUS UNIVERSE_FUNCTION Exists(char * Name,char * Dir);
Exists return On if there is a file or folder with the Name field inside the Dir.
STRING UNIVERSE_FUNCTION Write(const char * ToWrite);
Write put the ToWrite value into a STRING type.
void UNIVERSE_FUNCTION CreateUniverse(PUNIVERSE ToCreate,const char * Clan,const char * Class);
CreateUniverse will get the Clan and Class. It will Create a folder named Universe in
your local Path and inside it will create a folder with the Clan name. Inside the Clan
folder will be created two files. One will be the name of the Class.CFG and the other Class.DATA.
The first file has the class field and the secound has the data itself.
If there is no data it returns ToCreate->Class.Max = 0 and ToCreate->Data.Max to be checked
by the MaxClass and MaxData.
STATUS UNIVERSE_FUNCTION MaxClass(UNIVERSE ToCheck);
MaxClass will return Off if ToCheck.Class.Max is Equal 0
void UNIVERSE_FUNCTION InsertClass(PUNIVERSE ToInsert,const char * Type,const char * Value);
InsertClass will insert the Type and Value into ToInsert->Class.Type and ToInsert->Class.Value
and Increase ToInsert->Class.Max each time you call it.
void UNIVERSE_FUNCTION SaveClass(UNIVERSE ToSave);
SaveClass will save the informations from ToSave into Class.CFG file
STATUS UNIVERSE_FUNCTION MaxData(UNIVERSE ToCheck);
MaxData returns Off if ToCheck.Data.Max is equal 0, otherwise returns On
void UNIVERSE_FUNCTION StartData(UNIVERSE ToStart);
StartData will start the temp data to be avaliated with your actual data.
You have to call it each time you want to insert new field into your database.
void UNIVERSE_FUNCTION AppendData(char * Type,char * Value);
AppendData will insert the Type and Value into the temp data to be avaliated with
your actual data.
STATUS UNIVERSE_FUNCTION Equal(UNIVERSE ToCompare,char * ClassValue);
Equal will compare temp data and ToCompare. It will return On if ClassValue
exists inside ToCompare. Otherwise it will return Off. The ClassValue use to
be a key value, like an Id which does not repeat in the database.
void UNIVERSE_FUNCTION InsertData(PUNIVERSE ToInsert);
InsertData will put the temp data fields into ToInsert.
In order to save it into the file you must call SaveLastData.
void UNIVERSE_FUNCTION SaveLastData(UNIVERSE ToSave);
SaveLastData will save the last ToSave informations into the Class.DATA.
void UNIVERSE_FUNCTION SaveAllData(UNIVERSE ToSave);
SaveAllData will replace all the informations from ToSave into Class.Data
STATUS UNIVERSE_FUNCTION ModifyData(PUNIVERSE ToModify,char * Key);
ModifyData will look for the Key inside ToModify. If it finds the key it will return On.
if it returns On you must call SaveAllData in order to modify Class.CFG file.
void UNIVERSE_FUNCTION RemoveClassFile(PUNIVERSE ToRemove);
RemoveClassFile removes the Class.CFG and restart ToRemove->Class.Type,ToRemove->Class.Value and ToRemove->Data.Buffer.
void UNIVERSE_FUNCTION RemoveDataFile(PUNIVERSE ToRemove);
RemoveDataFile Removes the Class.DATA and restart ToRemove->Data.Buffer.
char * UNIVERSE_FUNCTION DoubleToString(double ToConvert);
DoubleToString converts ToConvert into char type.
char * UNIVERSE_FUNCTION IntToString(int ToConvert);
IntToString converts ToConvert into int type.
void UNIVERSE_FUNCTION LoadImg(PIMAGE ToCreate,char * Clan);
LoadImage loads the images from the clan. You don't need to call it, because the
LoadObject already does.
void UNIVERSE_FUNCTION LoadSound(PIMAGE ToCreate,char * Clan);
LoadSound loads the sound from the clan. You don't need to call it, because the
LoadObject already does.
void UNIVERSE_FUNCTION LoadObject(POBJECT ToCreate,char * Clan,char * Id);
LoadObject loads the object, image and sound informations from the file.
They are logical information. I have made it in order to adaptate with the
graphic libraries.
double UNIVERSE_FUNCTION Width(POBJECT Object,double ToChange);
Width changes the Object.Width and Object.WidthOffset values passed by ToChange and returns its changes.
double UNIVERSE_FUNCTION Height(POBJECT Object,double ToChange);
Height works like Width but in the Height field.
double UNIVERSE_FUNCTION WidthSize(POBJECT Object,double ToChange)
WidthSize is used to scale the Object->Width. It is multiplied by Object->Width.
double UNIVERSE_FUNCTION HeightSize(POBJECT Object,double ToChange)
HeightSize works like WidthSize but in the HeightSize field.
double UNIVERSE_FUNCTION XSpeed(POBJECT Object,double ToChange);
XSpeed is used to modify the Object->XSpeed value passed by ToChange.
It afects the XSpeed of every X fields.
double UNIVERSE_FUNCTION YSpeed(POBJECT Object,double ToChange);
YSpeed works just like XSpeed but in the YSpeed.
STATUS UNIVERSE_FUNCTION XAround(OBJECT Object,double Min,double Max);
XAround verifies if Object.X is inside the Min and Max field and returns On if it is.
STATUS UNIVERSE_FUNCTION XIncrease(POBJECT Object,double Max);
XIncrease increases the Object->X in the Object->XSpeed until Max field.
STATUS UNIVERSE_FUNCTION XDecrease(POBJECT Object,double Min);
XDecrease decreases the Object->X in the Object->XSpeed until Min field.
STATUS UNIVERSE_FUNCTION YAround(OBJECT Object,double Min,double Max);
YAround works just like XAround but verifying Object.Y.
STATUS UNIVERSE_FUNCTION YIncrease(POBJECT Object,double Max);
YIncrease works just like XIncrease buf affection Object->Y.
STATUS UNIVERSE_FUNCTION YDecrease(POBJECT Object,double Min);
YDecrease works like XDecrese but verifies Object->Y.
STATUS UNIVERSE_FUNCTION XViewAround(OBJECT Object,double Begin,double End);
XViewAround verifies if Object.XView is inside Begin and End field.
STATUS UNIVERSE_FUNCTION XViewIncrease(POBJECT Object,double Max);
Works like XIncrease but affects Object->XView.
STATUS UNIVERSE_FUNCTION XViewDecrease(POBJECT Object,double Min);
XViewIncrease Works like XDecrease but affects Object->YView.
STATUS UNIVERSE_FUNCTION YViewAround(OBJECT Object,double Begin,double End);
YViewAround verifies if Object.YView is inside Begin and End field.
STATUS UNIVERSE_FUNCTION YViewIncrease(POBJECT Object,double Max);
YViewIncrease Works like XViewIncrease but affects Object->YView.
STATUS UNIVERSE_FUNCTION YViewDecrease(POBJECT Object,double Min);
Works like XDecrease but affects Object->YView.
STATUS UNIVERSE_FUNCTION XScrollAround(OBJECT Object,double Begin,double End);
XScrollAround verifies if Object.XScroll is inside Begin and End field.
STATUS UNIVERSE_FUNCTION XScrollIncrease(POBJECT Object,double Max);
XScrollIncrease works like XIncrese but affects Object->XScroll.
STATUS UNIVERSE_FUNCTION XScrollDecrease(POBJECT Object,double Min);
XScrollDecrease works like YDecrease but affects Object->XScroll.
STATUS UNIVERSE_FUNCTION YScrollAround(OBJECT Object,double Begin,double End);
YScrollAround works like XAround and the other around functions.
STATUS UNIVERSE_FUNCTION YScrollIncrease(POBJECT Object,double Max);
YScrollIncrease works like YIncrease but affects Object->YScroll field
STATUS UNIVERSE_FUNCTION YScrollDecrease(POBJECT Object,double Min);
YScrollDecrease works like YDecrease but affects Object->YScroll field
void UNIVERSE_FUNCTION InsertImage(POBJECT ToInsert,char * Name,char * Path,char * Action);
InsertImage inserts the fields Name,Path and Actions into the ToInsert->ImageInfo.Name,ToInsert->ImageInfo.Path
ToInsert->ImageInfo.Action. It inserts the Object->ID field into the ToInsert->ImageInfo.Pattern in order to
link them.
void UNIVERSE_FUNCTION SaveImage(OBJECT ToInsert);
SaveImage saves ToInsert.ImageInfo into the file.
void UNIVERSE_FUNCTION InsertSound(POBJECT ToInsert,char * Name,char * Path);
InsertSound inserts the Name and Path into ToInsert.SoundInformation. It inserts ToInsert.ID into
ToInsert.SoundInformation.Pattern in order to link them.
double UNIVERSE_FUNCTION SoundVolume(POBJECT ToChange,double Volume);
SoundVolume changes the ToChange->SoundInfo.Volume to Volume field.
double UNIVERSE_FUNCTION SoundBalance(POBJECT ToChange,double Balance);
SoundBalance changes the ToChange->SoundInfo.Balance to Balance field.
double UNIVERSE_FUNCTION SoundSpeed(POBJECT ToChange,double Speed);
SoundSpeed changes the ToChange->SoundInfo.Speed to Speed field.
void UNIVERSE_FUNCTION SaveSound(OBJECT ToSave);
SaveSound saves ToSave.SoundInfo into file.
You won't need to can it, because the SaveObject already does.
void UNIVERSE_FUNCTION SaveObject(OBJECT ToSave);
SaveObject saves Object information and Object.ImageInfo and Object.SoundInfo into file.

Compartilhar este post


Link para o post
Compartilhar em outros sites

E aqui vai um exemplo de como implementar o banco de dados.

 

 

#include <universe.h>
 
typedef struct{ // First you have to create the field of your project
  STRING Name;
  UINT Age;
  }PERSON,*PPERSON;
 
// CreateUniverse(PUNIVERSE ToCreate,const char * Class,const char * Clan)
// MaxClass(UNIVERSE ToCheck) Returns Off if there is no class
// MaxData(UNIVERSE ToCheck) Return Off if there is no data
// Equal(UNIVERSE ToCheck,)
 
void LoadPerson(PPERSON ToLoad){ // Here you create a function to load the standard values or the database values
  UNIVERSE Person;
  CreateUniverse(&Person,"Class","Person"); // Create a folder named Universe in your local Path
// and inside it create a path named Class
  if(!MaxClass(Person)){// Verify if the class if empty
    // Double Int Word
    InsertClass(&Person,"Word","Name");// Insert the class type and value
    InsertClass(&Person,"Int","Age");// into a temp class
SaveClass(Person);// Save it into the file class
}
  // Load the standard configuration in case of no data yet
  ToLoad->Name = Write("Empty"); // The parameter of the function Write is converts it into STRING type
  ToLoad->Age  = 0;
  if(MaxData(Person)){// verify if there is some data there
    UINT LastData=0,LastClass=0;// Load the data
while(LastData<Person.Data.Max){// verify if the data reached the end
 if(!strncmp("Name",Person.Class.Value[LastClass].Text,Person.Class.Value[LastClass].Length)){
   // recover the name field
ToLoad->Name = Write(Person.Data.Buffer[LastData].Text);
   }
 if(!strncmp("Age",Person.Class.Value[LastClass].Text,Person.Class.Value[LastClass].Length)){
   // Recover the Age field
ToLoad->Age = atoi(Person.Data.Buffer[LastData].Text);
}
 LastClass++;// Increase the class counter
 if(LastClass==Person.Class.Max){// verify if it is the last class value
LastClass = 0;// go to the first value of the next data
}
      LastData++;
 }
}
  }
 
void SavePerson(PERSON ToSave){
  UNIVERSE Person;
  CreateUniverse(&Person,"Class","Person");// Load the information from the Database if it exists
  StartData(Person);// Prepare the temp data to be written
  AppendData("Name",ToSave.Name.Text);// insert the name into the temp data
  AppendData("Age",IntToString(ToSave.Age));// insert the age into the temp data using the function conversor
  if(!Equal(Person,"Name")){ // Verify if ToSave.Name is different of the data
    InsertData(&Person);// Insert the Person informations
SaveLastData(Person);// save into file
}
  else if(ModifyData(&Person,ToSave.Name.Text))SaveAllData(Person);// Replace all the Person information into file
  }
 
int main(){
  PERSON Client;
  LoadPerson(&Client);
  //Client.Name = Write("Cliente Name");
  //Client.Age  = 50;
  printf("%s %i\n",Client.Name.Text,Client.Age);
  SavePerson(Client);
  return 0;
  }
 

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.