Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

FSMplacebos.h

Go to the documentation of this file.
00001 #ifndef HAVE_LIBFSM
00002 
00003 /*-------------------------------------------------------------
00004  * gcc hacks
00005  */
00006 #ifdef __GNUC__
00007   #if __GNUC__ >= 3
00008     #include <ext/stl_hash_fun.h>
00009     #if __GNUC_MINOR__ == 0
00010       #define FSM_STL_NAMESPACE std
00011     #else
00012       #define FSM_STL_NAMESPACE __gnu_cxx
00013     #endif /* __GNUC_MINOR__ == 0 */
00014 
00015     namespace FSM_STL_NAMESPACE
00016     {
00017       template<> struct hash<std::string> {
00018         std::size_t operator()(const std::string &s) const {
00019           return __stl_hash_string(s.c_str());
00020         }
00021       };
00022     }
00023   #endif /* __GNUC => 3 */
00024 #else /* __GNUC__ */
00025   #define FSM_STL_NAMESPACE std
00026 #endif /* __GNUC__ */ 
00027 
00028 using namespace std;
00029 
00030 /*-------------------------------------------------------------
00031  * FSMTypes
00032  */
00033 typedef string FSMSymbolString;
00034 
00035 typedef short int FSMSymbol;
00036 
00037 typedef float FSMWeight;
00038 
00039 #define EPSILON 0
00040 #define FSMNOLABEL -1
00041 
00042 void FSMplacebo(const char *name);
00043 
00044 /*-------------------------------------------------------------
00045  * FSMSymSpec
00046  */
00048 class FSMSymSpec {
00049 public:
00050   /*------------------------------------------------
00051    * typedefs
00052    */
00053 
00054 public:
00055   /*------------------------------------------------
00056    * data
00057    */
00058   list<std::string> *messages;
00059 
00060 public:
00061   /*------------------------------------------------
00062    * methods
00063    */
00064   FSMSymSpec(char *filename=NULL, list<std::string> *msgs=NULL, bool att_compat=true)
00065     : messages(msgs) {};
00066 
00067   std::string &symbol_vector_to_string(const vector<FSMSymbol> &vec,
00068                                        std::string &str,
00069                                        const bool use_categories=false,
00070                                        const bool warn_on_undefined=true)
00071   {
00072     FSMplacebo("FSMSymSpec::symbol_vector_to_string()");
00073     return str;
00074   };
00075 
00076   const set<FSMSymbolString> *signs(void) {
00077     FSMplacebo("FSMSymSpec::signs()");
00078     return NULL;
00079   }
00080   const set<FSMSymbolString> *symbols(void) {
00081     FSMplacebo("FSMSymSpec::symbols()");
00082     return NULL;
00083   }
00084 
00085   const FSMSymbolString *symbol_to_symbolname(FSMSymbol sym) {
00086     FSMplacebo("FSMSymSpec::symbol_to_symbolname()");
00087     return NULL;
00088   }
00089 
00090   operator bool() { return false; }
00091 };
00092 
00093 /*-------------------------------------------------------------
00094  * FSM
00095  */
00097 class FSM {
00098  public:
00099   /*------------------------------------------------
00100    * typedefs
00101    */
00102   typedef vector<FSMSymbol> FSMSymbolVector;
00103 
00104   template <class T> class FSMWeightedIOPair
00105   {
00106   public:
00107     T istr;           
00108     T ostr;           
00109     FSMWeight weight; 
00110     
00111     // -- Constructors
00112     FSMWeightedIOPair(const T& is) : istr(is), ostr(T()), weight(0) {};
00113     FSMWeightedIOPair(const T& is, FSMWeight w) : istr(is), ostr(T()), weight(w) {};
00114     FSMWeightedIOPair(const T& is, const T& os) : istr(is), ostr(os), weight(0) {};
00115     FSMWeightedIOPair(const T& is, const T& os, FSMWeight w) : istr(is), ostr(os), weight(w) {};
00116 
00117 
00118     //-- Comparators
00119     friend bool operator<(const FSMWeightedIOPair& x, const FSMWeightedIOPair& y)
00120     {
00121       FSMplacebo("FSM::FSMWeightedIOPair::operator<");
00122       return false;
00123     }
00124   };
00125 
00126   typedef FSMWeightedIOPair<FSMSymbolVector> FSMWeightedSymbolVector;
00127   typedef FSMWeightedIOPair<FSMSymbolString> FSMStringWeight;
00128 
00129   typedef set<FSMWeightedSymbolVector> FSMWeightedSymbolVectorSet;
00130 
00131  public:
00132   /*------------------------------------------------
00133    * methods
00134    */
00135 
00136   FSM(const char *filename=NULL) {
00137     FSMplacebo("FSM::FSM()");
00138   }
00139 
00140   bool fsm_use_symbol_spec(FSMSymSpec *)
00141   {
00142     FSMplacebo("FSM::fsm_use_symbol_spec()");
00143     return false;
00144   }
00145 
00146   void fsm_clear(void) { return; }
00147 
00148   FSM *fsm_lookup(FSMSymbolString &s, FSM *result=NULL, bool do_connect=true)
00149   {
00150     FSMplacebo("FSM::fsm_lookup()");
00151     return result;
00152   }
00153 
00154   set<FSMWeightedSymbolVector> &fsm_symbol_vectors(set<FSMWeightedSymbolVector> &vectors,
00155                                                   bool cycle_test=true)
00156   {
00157     FSMplacebo("FSM::fsm_symbol_vectors()");
00158     return vectors;
00159   }
00160 
00161   FSM *fsm_lookup_vector(const FSMSymbolVector &v, FSM *result=NULL, bool connect=true)
00162   {
00163     FSMplacebo("FSM::fsm_lookup_vector()");
00164     return result;
00165   }
00166 
00167   operator bool() const { return false; }
00168 
00169   size_t fsm_no_of_states() { return 0; }
00170   size_t fsm_no_of_final_states() { return 0; }
00171   size_t fsm_no_of_transitions() { return 0; }
00172 };
00173 
00174 /*-------------------------------------------------------------
00175  * FSM
00176  */
00178 class FSMRegexCompiler {
00179 public:
00180   /*------------------------------------------------
00181    * typedefs
00182    */
00183 
00184 public:
00185   /*------------------------------------------------
00186    * methods
00187    */
00188   void use_symbol_spec(FSMSymSpec *symspec) {
00189     FSMplacebo("FSMRegexCompiler::use_symbol_spec()");
00190   }
00191 
00192   FSM *parse_from_string(const char *str, const char *srcname=NULL)
00193   {
00194     FSMplacebo("FSMRegexCompiler::parse_from_string()");
00195     return NULL;
00196   }
00197   
00198 
00199 };
00200 
00201 
00202 #endif /* HAVE_LIBFSM */

Generated on Fri Dec 2 18:14:56 2005 for libmootm by  doxygen 1.4.3-20050530