1 // Copyright (c) 1994 James Clark 2 // See the file COPYING for copying permission. 3 #pragma ident "%Z%%M% %I% %E% SMI" 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); subst(T & c)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.cxx" 40 #endif 41