rexdb.h
Go to the documentation of this file.
00001 /*
00002  *  Regular Pattern Analyzer Toolkit (RPA/Tk)
00003  *  Copyright (c) 2009-2012 Martin Stoilov
00004  *
00005  *  This program is free software: you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation, either version 3 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  *
00018  *  Martin Stoilov <martin@rpasearch.com>
00019  */
00020 
00021 
00031 #ifndef _REXDB_H_
00032 #define _REXDB_H_
00033 
00034 #include "rtypes.h"
00035 #include "rlib/robject.h"
00036 #include "rlib/rarray.h"
00037 #include "rex/rexstate.h"
00038 #include "rex/rexdfa.h"
00039 
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 #define R_OBJECT_REXDB 35
00046 
00055 typedef enum {
00056         REXDB_TYPE_NFA = 0,                     
00057         REXDB_TYPE_DFA = 1,                     
00058 } rexdb_type_t;
00059 
00060 struct rexcompiler_s;
00061 
00068 typedef struct rexdb_s {
00069         robject_t obj;                          
00070         rexdb_type_t type;                      
00071         struct rexcompiler_s *co;       
00072         rarray_t *states;                       
00073         rarray_t *substates;            
00074         rexstate_t *start;
00075 } rexdb_t;
00076 
00077 
00087 rexdb_t *rex_db_create(rexdb_type_t type);
00088 
00097 rexdb_t *rex_db_createdfa(rexdb_t *nfa, unsigned long start);
00098 
00103 void rex_db_destroy(rexdb_t *rexdb);
00104 
00121 long rex_db_addexpression(rexdb_t *nfa, unsigned long prev, const char *str, unsigned int size, rexuserdata_t userdata);
00122 
00126 long rex_db_addexpression_s(rexdb_t *nfa, unsigned long prev, const char *str, rexuserdata_t userdata);
00127 
00128 
00129 robject_t *rex_db_init(robject_t *obj, unsigned int objtype, r_object_cleanupfun cleanup, rexdb_type_t type);
00130 long rex_db_createstate(rexdb_t *rexdb, rex_statetype_t type);
00131 long rex_db_insertstate(rexdb_t *rexdb, rexstate_t *s);
00132 long rex_db_findstate(rexdb_t *rexdb, const rarray_t *subset);
00133 rexstate_t *rex_db_getstate(rexdb_t *rexdb, long uid);
00134 rexsubstate_t *rex_db_getsubstate(rexdb_t *rexdb, unsigned long uid);
00135 rex_transition_t * rex_db_addrangetrasition(rexdb_t *rexdb, rexchar_t c1, rexchar_t c2, unsigned long srcuid, unsigned long dstuid);
00136 rex_transition_t * rex_db_addtrasition_e(rexdb_t *rexdb, unsigned long srcuid, unsigned long dstuid);
00137 void rex_db_dumpstate(rexdb_t *rexdb, unsigned long uid);
00138 long rex_db_numtransitions(rexdb_t *rexdb);
00139 long rex_db_numstates(rexdb_t *rexdb);
00140 long rex_db_numsubstates(rexdb_t *rexdb);
00141 long rex_db_numaccsubstates(rexdb_t *rexdb);
00142 int rex_db_isempty(rexdb_t *db);
00143 const char *rex_db_version();
00144 
00160 rexdfa_t *rex_db_todfa(rexdb_t *db, int withsubstates);
00161 
00162 
00163 /*
00164  * Virtual methods implementation
00165  */
00166 void rex_db_cleanup(robject_t *obj);
00167 
00178 long rex_db_setblanks(rexdb_t *nfa, const char *str, unsigned int size);
00179 
00189 long rex_db_setblanks_s(rexdb_t *nfa, const char *str);
00190 
00196 #ifdef __cplusplus
00197 }
00198 #endif
00199 #endif