Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / nsgmls / SubstTable.h
1 /* $XConsortium: SubstTable.h /main/1 1996/07/29 17:05:53 cde-hp $ */
2 // Copyright (c) 1994 James Clark
3 // See the file COPYING for copying permission.
4
5 #ifndef SubstTable_INCLUDED
6 #define SubstTable_INCLUDED
7
8 #include <limits.h>
9 #include "StringOf.h"
10 #include "Boolean.h"
11
12 #ifdef SP_NAMESPACE
13 namespace SP_NAMESPACE {
14 #endif
15
16 template<class T>
17 class SubstTable {
18 public:
19   SubstTable();
20   void addSubst(T from, T to);
21   void subst(T &c) const { if (table_.size() > 0) c = table_[c]; }
22   void subst(String<T> &) const;
23   T operator[](T c) const { return table_.size() > 0 ? table_[c] : c; }
24   String<T> inverse(T) const;
25   void inverseTable(SubstTable<T> &) const;
26 private:
27   String<T> table_;
28   String<T> pairs_;             // mutable
29   Boolean pairsValid_;          // mutable
30 };
31
32 #ifdef SP_NAMESPACE
33 }
34 #endif
35
36 #endif /* SubstTable_INCLUDED */
37
38 #ifdef SP_DEFINE_TEMPLATES
39 #include "SubstTable.C"
40 #endif