home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / TEKST / TXI2IPF1 / SOURCE.ZIP / gen / String_Name_Map.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-04  |  3.1 KB  |  101 lines

  1. /*****************************************************************************
  2.  * $Id: String_Name_Map.h,v 1.1.1.1 1993/02/04 15:18:17 ak Exp $
  3.  *****************************************************************************
  4.  * $Log: String_Name_Map.h,v $
  5.  * Revision 1.1.1.1  1993/02/04  15:18:17  ak
  6.  * Please Edit this file to contain the RCS log information
  7.  * to be associated with this file (please remove these lines)
  8.  *
  9.  * Revision 1.1  1993/02/04  15:18:14  ak
  10.  * Initial revision
  11.  *
  12.  *****************************************************************************/
  13.  
  14. // This may look like C code, but it is really -*- C++ -*-
  15. /*
  16. Copyright (C) 1988 Free Software Foundation
  17.     written by Doug Lea (dl@rocky.oswego.edu)
  18.  
  19. This file is part of the GNU C++ Library.  This library is free
  20. software; you can redistribute it and/or modify it under the terms of
  21. the GNU Library General Public License as published by the Free
  22. Software Foundation; either version 2 of the License, or (at your
  23. option) any later version.  This library is distributed in the hope
  24. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  25. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  26. PURPOSE.  See the GNU Library General Public License for more details.
  27. You should have received a copy of the GNU Library General Public
  28. License along with this library; if not, write to the Free Software
  29. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  30. */
  31.  
  32.  
  33. #ifndef _StringNameMap_h
  34. #ifdef __GNUG__
  35. #pragma interface
  36. #endif
  37. #define _StringNameMap_h 1
  38.  
  39. #include <Pix.h>
  40. #include "String_defs.h"
  41.  
  42. class StringNameMap
  43. {
  44. protected:
  45.   int                   count;
  46.   Name                   def;
  47.  
  48. public:
  49.                         StringNameMap(Name& dflt);
  50.   virtual              ~StringNameMap();
  51.  
  52.   int                   length();                // current number of items
  53.   int                   empty();
  54.  
  55.   virtual int           contains(String& key);      // is key mapped?
  56.  
  57.   virtual void          clear();                 // delete all items
  58.  
  59.   virtual Name&          operator [] (String& key) = 0; // access contents by key
  60.  
  61.   virtual void          del(String& key) = 0;       // delete entry
  62.  
  63.   virtual Pix           first() = 0;             // Pix of first item or 0
  64.   virtual void          next(Pix& i) = 0;        // advance to next or 0
  65.   virtual String&          key(Pix i) = 0;          // access key at i
  66.   virtual Name&          contents(Pix i) = 0;     // access contents at i
  67.  
  68.   virtual int           owns(Pix i);             // is i a valid Pix  ?
  69.   virtual Pix           seek(String& key);          // Pix of key
  70.  
  71.   Name&                  dflt();                  // access default val
  72.  
  73.   void                  error(const char* msg);
  74.   virtual int           OK() = 0;                // rep invariant
  75. };
  76.  
  77.  
  78. inline StringNameMap::~StringNameMap() {}
  79.  
  80. inline int StringNameMap::length()
  81. {
  82.   return count;
  83. }
  84.  
  85. inline int StringNameMap::empty()
  86. {
  87.   return count == 0;
  88. }
  89.  
  90. inline Name& StringNameMap::dflt()
  91. {
  92.   return def;
  93. }
  94.  
  95. inline StringNameMap::StringNameMap(Name& dflt) :def(dflt)
  96. {
  97.   count = 0;
  98. }
  99.  
  100. #endif
  101.