home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 v2.4 Fix / W95-v2.4fix.iso / ACADWIN / ADS / CPP / GENERAL / ADSTABLE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-08  |  6.1 KB  |  186 lines

  1. /* 
  2.     ADSTABLE.CPP -
  3.     
  4.     This file:
  5.  
  6.         Defines ADS_TABLE class and all it's descendents and
  7.         the machines( functions ) to create and destroy these 
  8.         objects.
  9.  
  10.  
  11.     (C) Copyright 1988-1994 by Autodesk, Inc.
  12.  
  13.     This program is copyrighted by Autodesk, Inc. and is  licensed
  14.     to you under the following conditions.  You may not distribute
  15.     or  publish the source code of this program in any form.   You
  16.     may  incorporate this code in object form in derivative  works
  17.     provided  such  derivative  works  are  (i.) are  designed and
  18.     intended  to  work  solely  with  Autodesk, Inc. products, and
  19.     (ii.)  contain  Autodesk's  copyright  notice  "(C)  Copyright
  20.     1988-1994 by Autodesk, Inc."
  21.  
  22.     AUTODESK  PROVIDES THIS PROGRAM "AS IS" AND WITH  ALL  FAULTS.
  23.     AUTODESK  SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF  MER-
  24.     CHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK,  INC.
  25.     DOES  NOT  WARRANT THAT THE OPERATION OF THE PROGRAM  WILL  BE
  26.     UNINTERRUPTED OR ERROR FREE.
  27.  
  28. */
  29. #include "adsinc.h"
  30.  
  31. //-----------------------------------------------------------------------------
  32. //static ADS_STRING table_end_string( "\n\tEnd of Table" );
  33. //static ADS_STRING table_begin_string( "\tBegin of Table\n" );
  34.  
  35. static ADS_STRING table_record_seperator( "\n" );
  36. static ADS_STRING table_end_string( "\n" );
  37. static ADS_STRING table_begin_string( " " );
  38.  
  39. //static ADS_STRING table_record_seperator( " " );
  40.  
  41. //-----------------------------------------------------------------------------
  42. ADS_TABLE_OBJ*  MakeLayerTbl( struct resbuf *rb );
  43. ADS_TABLE_OBJ*  MakeLtypeTbl( struct resbuf *rb );
  44. ADS_TABLE_OBJ*  MakeViewTbl( struct resbuf *rb );
  45. ADS_TABLE_OBJ*  MakeStyleTbl( struct resbuf *rb );
  46. ADS_TABLE_OBJ*  MakeBlockTbl( struct resbuf *rb );
  47. ADS_TABLE_OBJ*  MakeUcsTbl( struct resbuf *rb );
  48. ADS_TABLE_OBJ*  MakeDimstyleTbl( struct resbuf *rb );
  49. ADS_TABLE_OBJ*  MakeVportTbl( struct resbuf *rb );
  50. ADS_TABLE_OBJ*  MakeAppidTbl( struct resbuf *rb );
  51.  
  52. //-----------------------------------------------------------------------------
  53. struct _ADS_TABLE_TYPES
  54. {
  55.     ADS_TABLE_OBJ* ( *MakeTableFun )( struct resbuf *rb );
  56.     char            *tablename;
  57. }ADS_TABLE_TYPES[] =
  58. {
  59.     { MakeLayerTbl,         "LAYER" }
  60.     , { MakeLtypeTbl,       "LTYPE" }
  61.     , { MakeViewTbl,        "VIEW" }
  62.     , { MakeStyleTbl,       "STYLE" }
  63.     , { MakeBlockTbl,       "BLOCK" }
  64.     , { MakeUcsTbl,         "UCS" }
  65.     , { MakeDimstyleTbl,    "DIMSTYLE" }
  66.     , { MakeVportTbl,       "VPORT" }
  67.     , { MakeAppidTbl,       "APPID" }
  68. };
  69.  
  70. //-----------------------------------------------------------------------------
  71. int FormatResBufInfo( char *buffer, struct resbuf* rb );
  72.  
  73. //-----------------------------------------------------------------------------
  74. void DeleteAdsTable( ADS_TABLE_OBJ* table_obj )
  75. {
  76.     delete table_obj;
  77. }
  78.  
  79. //-----------------------------------------------------------------------------
  80. struct ADS_TABLE_OBJ* MakeAdsTable( struct resbuf* rb )
  81. {
  82.     if ( rb->restype != 0 )
  83.     {
  84.         return NULL;
  85.     }
  86.     int     table_index;
  87.     for ( table_index = 0
  88.             ; table_index < ARRAY_SIZE( ADS_TABLE_TYPES  ) 
  89.             ; table_index++ )
  90.     {
  91.         if ( _stricmp( rb->resval.rstring
  92.                     , ADS_TABLE_TYPES[ table_index ].tablename ) == 0 )
  93.         {
  94.             return ( * ( ADS_TABLE_TYPES[ table_index ].MakeTableFun ) )( rb );
  95.         }
  96.     }
  97.     return NULL;
  98. }
  99.  
  100. //-----------------------------------------------------------------------------
  101. inline ADS_TABLE_OBJ*  MakeLayerTbl( struct resbuf *rb )
  102. {
  103.     return new ADS_LAYER( rb );
  104. }
  105.  
  106. //-----------------------------------------------------------------------------
  107. inline ADS_TABLE_OBJ*  MakeLtypeTbl( struct resbuf *rb )
  108. {
  109.     return new ADS_LTYPE( rb );
  110. }
  111.  
  112. //-----------------------------------------------------------------------------
  113. inline ADS_TABLE_OBJ*  MakeViewTbl( struct resbuf *rb )
  114. {
  115.     return new ADS_VIEW( rb );
  116. }
  117.  
  118. //-----------------------------------------------------------------------------
  119. inline ADS_TABLE_OBJ*  MakeStyleTbl( struct resbuf *rb )
  120. {
  121.     return new ADS_STYLE( rb );
  122. }
  123.  
  124. //-----------------------------------------------------------------------------
  125. inline ADS_TABLE_OBJ*  MakeBlockTbl( struct resbuf *rb )
  126. {
  127.     return new ADS_BLOCK( rb );
  128. }
  129.  
  130. //-----------------------------------------------------------------------------
  131. inline ADS_TABLE_OBJ*  MakeUcsTbl( struct resbuf *rb )
  132. {
  133.     return new ADS_UCS( rb );
  134. }
  135.  
  136. //-----------------------------------------------------------------------------
  137. inline ADS_TABLE_OBJ*  MakeDimstyleTbl( struct resbuf *rb )
  138. {
  139.     return new ADS_DIMSTYLE( rb );
  140. }
  141.  
  142. //-----------------------------------------------------------------------------
  143. inline ADS_TABLE_OBJ*  MakeVportTbl( struct resbuf *rb )
  144. {
  145.     return new ADS_VPORT( rb );
  146. }
  147.  
  148. //-----------------------------------------------------------------------------
  149. inline ADS_TABLE_OBJ*  MakeAppidTbl( struct resbuf *rb )
  150. {
  151.     return new ADS_APPID( rb );
  152. }
  153.  
  154. /******************************************************************************
  155. *                                                                             *
  156. *                    ADS_TABLE_OBJ member functions                           *
  157. *                                                                             *
  158. ******************************************************************************/
  159. //-----------------------------------------------------------------------------
  160. ADS_STRING& ADS_TABLE_OBJ::FormatTableString()
  161. {
  162.     if ( rb == NULL )
  163.     {
  164.         formatstring = "";
  165.         return formatstring;
  166.     }
  167.  
  168.     //
  169.     // Terrible way to do this, what if rb has more info GENERAL_BUFFER_SIZE
  170.     // can handle?
  171.     //
  172.     formatstring = table_begin_string;
  173.  
  174.     while ( rb )
  175.     {
  176.         char    record_buffer[ 256 ];
  177.         if ( DXFGroupCode2Str( rb, record_buffer ) != NULL )
  178.         {
  179.             formatstring += table_record_seperator + record_buffer;
  180.         }
  181.         rb = rb->rbnext;
  182.     }
  183.     formatstring += table_end_string;
  184.     return formatstring;
  185. }
  186.