//=-- TextMatcher.h - Abstract class for matching text against patterns ------=
//
//  This class defines a standard interface for text matching classes to 
//  implement.
//
//=---------------------------------------------------------------------------=
//  This file is copyright (c) 1997-1998 Chris Lattner
//=---------------------------------------------------------------------------=

#ifndef TEXTMATCHER_H
#define TEXTMATCHER_H

class String;
#include "Table.h"

class MSAPI TextMatcher {
public :
  TextMatcher() {
    CachedResults.SetDefault(-1); 
  }

  virtual ~TextMatcher() {
#if 0
    Table<String,int>::Iterator I = CachedResults.GetStart();
    int i=0;

    while (I) {
      i++; I++;
    }
    cout << "Destroying TextMatcher: CacheSize = " << i << endl;
#endif
  }

  int Match(const String &S);


  // Return "half" of a filter, for matching operations that you might want
  // to do.  Note that if you do this, you lose out on all of the reference
  // counting and sharing that Filter/FilterHandle does. (not recommended!)
  //
  static TextMatcher *DecodeMatcher(const String &F = "*", int *FieldIDX = 0);
  
protected :
  virtual int MatchImpl(const char *S) = 0;
  Table<String,int> CachedResults;
};

#endif
