home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Storage / LinkSpcB.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  5.8 KB  |  206 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        LinkSpecB.cpp
  3.  
  4.     Contains:    Implementation for ODBaseLinkSpec class.
  5.  
  6.     Owned by:    Craig Carper
  7.  
  8.     Copyright:    © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <2>     5/24/96    jpa        1246074: SOM_CATCH --> SOM_TRY..SOM_ENDTRY
  13.  
  14.     To Do:
  15.     In Progress:
  16.         
  17. */
  18.  
  19. #define VARIABLE_MACROS
  20.  
  21. #define ODBaseLinkSpec_Class_Source
  22. #include <LinkSpcB.xih>
  23.  
  24. #ifndef SOM_ODStorageUnit_xh
  25. #include "StorageU.xh"
  26. #endif
  27.  
  28. #ifndef _BARRAY_
  29. #include <BArray.h>
  30. #endif
  31.  
  32. #ifndef _STORUTIL_
  33. #include <StorUtil.h>
  34. #endif
  35.  
  36. #pragma segment ODBaseLinkSpec
  37.  
  38. //==============================================================================
  39. // ODBaseLinkSpec
  40. //==============================================================================
  41.  
  42. //------------------------------------------------------------------------------
  43. // ODBaseLinkSpec: somInit
  44. //------------------------------------------------------------------------------
  45.  
  46. SOM_Scope void  SOMLINK ODBaseLinkSpecsomInit(ODBaseLinkSpec *somSelf)
  47. {
  48.     ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
  49.     ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","somInit");
  50.  
  51.     parent_somInit(somSelf);
  52.  
  53.     _fPart = kODNULL;
  54.     _fPartData = CreateEmptyByteArrayStruct(0);
  55. }
  56.  
  57. //------------------------------------------------------------------------------
  58. // ODBaseLinkSpec: somUninit
  59. //------------------------------------------------------------------------------
  60.  
  61. SOM_Scope void  SOMLINK ODBaseLinkSpecsomUninit(ODBaseLinkSpec *somSelf)
  62. {
  63.     ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
  64.     ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","somUninit");
  65.  
  66.     DisposeByteArrayStruct(_fPartData);
  67.  
  68.     parent_somUninit(somSelf);
  69. }
  70.  
  71. //------------------------------------------------------------------------------
  72. // ODBaseLinkSpec: InitBaseLinkSpec
  73. //------------------------------------------------------------------------------
  74.  
  75. SOM_Scope void  SOMLINK ODBaseLinkSpecInitBaseLinkSpec(ODBaseLinkSpec *somSelf, Environment *ev,
  76.         ODPart* part,
  77.         ODByteArray* partData)
  78. {
  79.     ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
  80.     ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","InitBaseLinkSpec");
  81.  
  82.     SOM_TRY
  83.  
  84.     if ( partData )
  85.     {
  86.         DisposeByteArrayStruct(_fPartData);
  87.         _fPartData = CopyByteArrayStruct(partData);
  88.     }
  89.  
  90.     _fPart = part;
  91.  
  92.     SOM_CATCH_ALL
  93.     SOM_ENDTRY
  94. }
  95.  
  96. //------------------------------------------------------------------------------
  97. // ODBaseLinkSpec::GetPart
  98. //------------------------------------------------------------------------------
  99.  
  100. SOM_Scope ODPart*  SOMLINK ODBaseLinkSpecGetPart(ODBaseLinkSpec *somSelf, Environment *ev)
  101. {
  102.     ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
  103.     ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","GetPart");
  104.  
  105.     return _fPart;
  106. }
  107.  
  108. //------------------------------------------------------------------------------
  109. // ODBaseLinkSpec::GetPartData
  110. //------------------------------------------------------------------------------
  111.  
  112. SOM_Scope ODByteArray  SOMLINK ODBaseLinkSpecGetPartData(ODBaseLinkSpec *somSelf, Environment *ev)
  113. {
  114.     ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
  115.     ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","GetPartData");
  116.  
  117.     SOM_TRY
  118.     
  119.     return CopyByteArrayStruct(&_fPartData);
  120.  
  121.     SOM_CATCH_ALL
  122.     SOM_ENDTRY
  123.     return CreateEmptyByteArrayStruct(0);
  124. }
  125.  
  126. //------------------------------------------------------------------------------
  127. // ODBaseLinkSpec: WriteLinkSpec
  128. //------------------------------------------------------------------------------
  129.  
  130. SOM_Scope void  SOMLINK ODBaseLinkSpecWriteLinkSpec(ODBaseLinkSpec *somSelf, Environment *ev,
  131.         ODStorageUnit* su)
  132. {
  133.     ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
  134.     ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","WriteLinkSpec");
  135.  
  136.     SOM_TRY
  137.     
  138.     // Assumes su has been focused to a property and link spec value
  139.  
  140.     StorageUnitSetValue(su, ev, sizeof(ODPart*), (ODValue) &_fPart);
  141.     StorageUnitSetValue(su, ev, sizeof(ODULong), (ODValue) &_fPartData._length);
  142.     StorageUnitSetValue(su, ev, _fPartData._length, (ODValue) _fPartData._buffer);
  143.  
  144.     SOM_CATCH_ALL
  145.     SOM_ENDTRY
  146. }
  147.  
  148. //------------------------------------------------------------------------------
  149. // ODBaseLinkSpec: ReadLinkSpec
  150. //------------------------------------------------------------------------------
  151.  
  152. SOM_Scope void  SOMLINK ODBaseLinkSpecReadLinkSpec(ODBaseLinkSpec *somSelf, Environment *ev,
  153.         ODStorageUnit* su)
  154. {
  155.     ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
  156.     ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","ReadLinkSpec");
  157.  
  158.     SOM_TRY
  159.  
  160.     ODPart*            part;
  161.     ODByteArray        partData;
  162.     ODULong            dataSize;
  163.     ODULong            valueSize;
  164.  
  165.     // Assumes su has been focused to a property and link spec value,
  166.     // and the current offset is where the base link spec was written.
  167.  
  168.     valueSize = StorageUnitGetValue(su, ev, sizeof(ODPart*), (ODValue) &part);
  169.     if ( valueSize != sizeof(ODPart*) )
  170.         THROW(kODErrCorruptLinkSpecValue);
  171.  
  172.     valueSize = StorageUnitGetValue(su, ev, sizeof(ODULong), (ODValue) &dataSize); 
  173.     if ( valueSize != sizeof(ODULong) )
  174.         THROW(kODErrCorruptLinkSpecValue);
  175.  
  176.     partData = CreateEmptyByteArrayStruct(dataSize);
  177.     if ( dataSize > 0 )
  178.     {
  179.         valueSize = StorageUnitGetValue(su, ev, dataSize, (ODValue) partData._buffer);
  180.         if ( valueSize != dataSize )
  181.         {
  182.             DisposeByteArrayStruct(partData);
  183.             THROW(kODErrCorruptLinkSpecValue);
  184.         }
  185.     }
  186.     partData._length = dataSize;
  187.     
  188.     _fPart = part;
  189.     DisposeByteArrayStruct(_fPartData);
  190.     _fPartData = partData;
  191.  
  192.     SOM_CATCH_ALL
  193.     SOM_ENDTRY
  194. }
  195.  
  196. //------------------------------------------------------------------------------
  197. // ODBaseLinkSpec::FromThisDraft
  198. //------------------------------------------------------------------------------
  199.  
  200. SOM_Scope ODBoolean  SOMLINK ODBaseLinkSpecFromThisDraft(ODBaseLinkSpec *somSelf, Environment *ev)
  201. {
  202.     // ODBaseLinkSpecData *somThis = ODBaseLinkSpecGetData(somSelf);
  203.     ODBaseLinkSpecMethodDebug("ODBaseLinkSpec","FromThisDraft");
  204.  
  205.     return kODTrue;
  206. }