示例#1
0
文件: GEOOBJ.CPP 项目: hkaiser/TRiAS
void CGeoObj :: ReDefType( const char *type )
{
	CTriasObjekt TO( this );
	CxString	 text;

	ASSERT( ObjNr() > 0L );
	TO.ONr() = ObjNr();
	TO.ObjTyp() = ObjTyp();
	if ( TO.Read()) {
		if ( ZeigeLeseFehler ) {
			text.printf( "Objekt gelesen: %s, (Punkte: %d, Linien: %d, ID: %ld)", (const char*)UniqueIdent(), TO.AnzahlPunkte(), TO.AnzahlKonturen(), TO.Ident());
			if ( AfxMessageBox( text, MB_OKCANCEL ) != IDOK )
				 ZeigeLeseFehler = FALSE;
		}
		TO.ObjTyp() = *type;
		TO.ONr()  = -1L;
		TO.Neu() = TRUE;
		TO.WriteBack();

		if ( ZeigeLeseFehler ) {
			text.printf( "Objekt gelesen und geschrieben: %s, (alt: %ld) (neu: %ld)", (const char*)UniqueIdent(), ObjNr(), TO.ONr());
			if ( AfxMessageBox( text, MB_OKCANCEL ) != IDOK )
				ZeigeLeseFehler = FALSE;
		}

		ASSERT( TO.ONr() > 0L );
//		DEX_DeleteObject( ObjNr());
		if ( TO.ONr() > 0L )	ObjNr() = TO.ONr();
	}
	else if ( ZeigeLeseFehler ) {
		text = "Objekt nicht gelesen: ";
		text += UniqueIdent();
		if ( AfxMessageBox( text, MB_OKCANCEL ) != IDOK )
			ZeigeLeseFehler = FALSE;
	}
}	// ReDefType
示例#2
0
/*----------------------------------------------------------------------
   WriteStructureSchema						
   ecrit le schema de structure pointe' par pSS dans le fichier	
   de nom fileName.						
   Si code est nul, ecrit le schema avec un nouveau code		
   d'identification, sinon avec code comme code d'identification.	
  ----------------------------------------------------------------------*/
ThotBool             WriteStructureSchema (Name fileName, PtrSSchema pSS,
					   int code)
{
   PtrTtAttribute      pAttr;
   int                 i, j;

   /* ouvre le fichier */
   outfile = TtaWriteOpen (fileName);
   if (outfile == 0)
      return False;

   /* ecrit la partie fixe du schema de structure */
   WriteName (pSS->SsName);
   if (code == 0)
      /* alloue un nouveau code d'identification au schema compile' */
      WriteShort (UniqueIdent ());
   else
      /* le schema compile' a le code d'identification code */
      WriteShort (code);
   WriteName (pSS->SsDefaultPSchema);
   WriteBoolean (pSS->SsExtension);
   WriteShort (pSS->SsDocument);
   WriteShort (pSS->SsRootElem);
   WriteShort (pSS->SsNAttributes);
   WriteShort (pSS->SsNRules);
   WriteBoolean (pSS->SsExport);

   WriteShort (pSS->SsNExceptions);
   for (i = 0; i < pSS->SsNExceptions; i++)
      WriteShort (pSS->SsException[i]);

   /* ecrit le texte des constantes */
   i = 0;
   do
      TtaWriteByte (outfile, pSS->SsConstBuffer[i++]);
   while (pSS->SsConstBuffer[i - 1] != '\0' || pSS->SsConstBuffer[i] != '\0');

   /* SsFirstDynNature */
   TtaWriteByte (outfile, '\0');

   /* ecrit les attributs */
   for (i = 0; i < pSS->SsNAttributes; i++)
     {
	pAttr = pSS->SsAttribute->TtAttr[i];
	WriteName (pAttr->AttrName);
	WriteBoolean (pAttr->AttrGlobal);
	WriteShort (pAttr->AttrFirstExcept);
	WriteShort (pAttr->AttrLastExcept);
	WriteAttributeType (pAttr->AttrType);
	switch (pAttr->AttrType)
	      {
		 case AtNumAttr:
		 case AtTextAttr:
		    break;
		 case AtReferenceAttr:
		    WriteShort (pAttr->AttrTypeRef);
		    WriteName (pAttr->AttrTypeRefNature);
		    break;
		 case AtEnumAttr:
		    WriteShort (pAttr->AttrNEnumValues);
		    for (j = 0; j < pAttr->AttrNEnumValues; j++)
		       WriteName (pAttr->AttrEnumValue[j]);
		    break;
	      }
     }
   /* ecrit les regles de structure */
   for (i = 0; i < pSS->SsNRules; i++)
      WriteRule (pSS->SsRule->SrElem[i]);

   /* ecrit les regles d'extension */
   if (pSS->SsExtension)
     {
	WriteShort (pSS->SsNExtensRules);
	for (i = 0; i < pSS->SsNExtensRules; i++)
	   WriteRule (&pSS->SsExtensBlock->EbExtensRule[i]);
     }
   TtaWriteClose (outfile);
   return True;
}