home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2002 December
/
PCWorld_2002-12_cd.bin
/
Software
/
Komercni
/
Baltik
/
katB.exe
/
katB
/
DESIGN
/
DESIGN_C.IO
< prev
next >
Wrap
Text File
|
2002-09-16
|
4KB
|
115 lines
////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------//
//-----project DESINGER, copyright 2002 Libor Bareτ-------------------------//
//----------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////////
void SerializeStringRead(long File, string& strText){
unsigned n;
Soubor¼tiBlok(File,&n,sizeof(n));
StrVytvo²(strText);
StrNastavVelikost(strText,n);
Soubor¼tiBlok(File,(char*)strText,n);
}
void SerializeStringStore(long File, string strText){
unsigned n=StrVelikost(strText);
SouborPiτBlok(File,&n,sizeof(n));
SouborPiτBlok(File,(char*)strText,n);
}
void SerializeClassItemsRead(long File,CLASSITEM ** pClassItems,int nSize){
int nPos = 0;
*pClassItems= (CLASSITEM*) malloc(sizeof(CLASSITEM)*nSize);
CLASSITEM * item;
for(;nPos < nSize; nPos++){
item = &(*pClassItems)[nPos];
Soubor¼tiBlok(File,item,sizeof(CLASSITEM));
SerializeStringRead(File,item->strText);
}
}
void SerializeClassItemsStore(long File,CLASSITEM * pClassItems,int nSize){
int nPos = 0;
CLASSITEM * item;
for(;nPos < nSize; nPos++){
item = &(pClassItems)[nPos];
SouborPiτBlok(File,item,sizeof(CLASSITEM));
SerializeStringStore(File,item->strText);
}
}
DIAGRAMCELL* IO_READ(long File,DIAGRAMCELL * cells,int ** zorder, int &nSize){
int Size = 0,xSize=0;
SouborNastavPozici(File,0,0);
DIAGRAMCELL* pCell;
Soubor¼tiBlok(File,&Size,sizeof(int));
cells = (DIAGRAMCELL*) malloc(sizeof(DIAGRAMCELL)*Size);
*zorder= (int*) malloc(sizeof(int)*Size);
int h=0;
for(;h<6;h++)SerializeStringRead(File,m_strExInfo[h]);
while(!SouborKonec(File)&& Size > xSize){
pCell = &cells[xSize];
Soubor¼tiBlok(File,&(*zorder)[xSize],sizeof(int));
Soubor¼tiBlok(File,&cells[xSize],sizeof(DIAGRAMCELL));
SerializeStringRead(File,pCell->ClassName);
SerializeStringRead(File,pCell->strExStereotypes);
SerializeStringRead(File,pCell->strExProperties);
int i;
int nSizeDependents=pCell->nSizeDependents;
if(nSizeDependents > 0){
pCell->pDependents = (int*)malloc(sizeof(int)*nSizeDependents);
for(i=0;i < nSizeDependents; i++){
Soubor¼tiBlok(File,&pCell->pDependents[i],sizeof(int));
}
}
if(pCell->nSizeVariable > 0){
SerializeClassItemsRead(File,((CLASSITEM**)(&(pCell->pVariable))),pCell->nSizeVariable);
}
if(pCell->nSizeOperation > 0){
SerializeClassItemsRead(File,((CLASSITEM**)(&(pCell->pOperation))),pCell->nSizeOperation);
}
xSize++;
}
nSize = Size;
//nSize = Size-1;
return cells;
}
void IO_WRITE(long File,DIAGRAMCELL* pCells,int * zorder,int nSize){
// export to file ...
SouborNastavPozici(File,0,0);
SouborU²ízni(File);
SouborPiτBlok(File,&nSize,sizeof(int));
int h=0;
for(;h<6;h++)SerializeStringStore(File,m_strExInfo[h]);
int nActual=0;
DIAGRAMCELL * pAc = 0;
for(;nActual < nSize;nActual++){
pAc = & pCells[nActual];
SouborPiτBlok(File,&zorder[nActual],sizeof(int));
SouborPiτBlok(File,pAc,sizeof(DIAGRAMCELL));
SerializeStringStore(File,pAc->ClassName);
SerializeStringStore(File,pAc->strExStereotypes);
SerializeStringStore(File,pAc->strExProperties);
if(pAc->nSizeDependents > 0){
int i;
for(i=0;i < pAc->nSizeDependents;i++){
SouborPiτBlok(File,&pAc->pDependents[i],sizeof(int));
}
}
if(pAc->nSizeVariable > 0){
SerializeClassItemsStore(File,(CLASSITEM*)(pAc->pVariable),pAc->nSizeVariable);
}
if(pAc->nSizeOperation > 0){
SerializeClassItemsStore(File,(CLASSITEM*)(pAc->pOperation),pAc->nSizeOperation);
}
}
}