home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yeah09.zip / source / lib / SequenceEA.CPP < prev    next >
C/C++ Source or Header  |  1996-05-25  |  2KB  |  87 lines

  1. //------------------------------------------------------------
  2. //
  3. // Name:     SequenceEA.cpp
  4. // Version:  0.9
  5. // Author:   Björn Fahller.
  6. //
  7. // Copyright (C) Björn Fahller, 1996.
  8. //
  9. // Purpose:  Base class for the template based implementation of
  10. //           multi value single type extended attributes (EAT_MVST)
  11. //           based on EA (through TEA) of YEAH.
  12. //
  13. // History:
  14. //          Ver.  Date         What
  15. //          0.9   1996-05-26   First official release.
  16. //
  17. //------------------------------------------------------------
  18.  
  19. #include "yea.h"
  20. #include <strstrea.h>
  21.  
  22. IEXCLASSIMPLEMENT(EATSeqeuceEAInstError,EATypeMismatchError);
  23.  
  24. static EA* errorf(EA::Identifier id);
  25.  
  26. EA* (*SequenceEA::errorFunction)(EA::Identifier) = errorf;
  27.  
  28. SequenceEA::~SequenceEA(void)
  29. {
  30. }
  31.  
  32. SequenceEA::SequenceEA(EA::Identifier i, EA::CreatorMap* pCM)
  33.  : contentType(i),
  34.    cp(0),
  35.    pCreatorMap(pCM)
  36. {
  37. }
  38.  
  39. SequenceEA::SequenceEA(const SequenceEA& gaea)
  40.  : contentType(gaea.contentType),
  41.    cp(gaea.cp),
  42.    TEA<SequenceEA, SequenceEA::id>(gaea)
  43. {
  44. }
  45.  
  46. const SequenceEA& SequenceEA::operator=(const SequenceEA& gaea)
  47. {
  48.   if (&gaea != this)
  49.   {
  50.     cp = gaea.cp;
  51.     contentType = gaea.contentType;
  52.     TEA<SequenceEA, id>::operator=(gaea);
  53.   }
  54.   return *this;
  55. }
  56.  
  57. EA* SequenceEA::createFrom(istrstream& is, EA::CreatorMap* pSubMap)
  58. {
  59.   streampos pos = is.tellg();
  60.   unsigned short codePage;
  61.   is.read((char*)(&codePage), sizeof(codePage));
  62.   unsigned short entries;
  63.   is.read((char*)(&entries), sizeof(entries));
  64.   EA::Identifier id;
  65.   is.read((char*)(&id), sizeof(id));
  66.   EA::CreatorMap::Cursor c(*pSubMap);
  67.   EA* pea = 0;
  68.   if (pSubMap->locateElementWithKey(id,c))
  69.   {
  70.     EA::CreatorIdPair& cm = pSubMap->elementAt(c);
  71.     pea = cm.c(is,cm.pSubMap);
  72.   }
  73.   else
  74.   {
  75.     pea = errorFunction(id);
  76.   }
  77.   is.seekg(pos);
  78.   return pea;
  79. }
  80.  
  81. static EA* errorf(EA::Identifier id)
  82. {
  83.   EATSeqeuceEAInstError err("TSequenceEA of unknown kind",id);
  84.   ITHROW(err);
  85.   return 0;
  86. }
  87.