2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
gb_table.h
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
(c) 2000-2012 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-08-17 12:41:51 +02:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2007-12-30 17:41:49 +01:00
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __GB_TABLE_H
|
|
|
|
#define __GB_TABLE_H
|
|
|
|
|
|
|
|
#include "gb_array.h"
|
|
|
|
|
|
|
|
#define NO_SYMBOL (-1)
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct {
|
|
|
|
char *name;
|
2010-05-27 15:51:09 +02:00
|
|
|
int len;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
PACKED
|
|
|
|
SYMBOL;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
enum {
|
|
|
|
TF_NORMAL = 0,
|
|
|
|
TF_IGNORE_CASE = 1
|
|
|
|
}
|
|
|
|
TABLE_FLAG;
|
|
|
|
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct _table {
|
|
|
|
SYMBOL *symbol;
|
2010-05-27 15:51:09 +02:00
|
|
|
ushort *sort;
|
2007-12-30 17:41:49 +01:00
|
|
|
TABLE_FLAG flag;
|
|
|
|
}
|
|
|
|
TABLE;
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void TABLE_create_static(TABLE *table, size_t size, TABLE_FLAG flag);
|
|
|
|
void TABLE_delete_static(TABLE *table);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
void TABLE_create(TABLE **result, size_t size, TABLE_FLAG flag);
|
|
|
|
void TABLE_create_from(TABLE **result, size_t size, const char *sym_list[], TABLE_FLAG flag);
|
|
|
|
void TABLE_delete(TABLE **table);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-08-06 22:14:41 +02:00
|
|
|
char TABLE_compare_ignore_case(const char *s1, int len1, const char *s2, int len2);
|
|
|
|
char TABLE_compare(const char *s1, int len1, const char *s2, int len2);
|
|
|
|
char TABLE_compare_ignore_case_len(const char *s1, int len1, const char *s2, int len2);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-29 02:11:55 +02:00
|
|
|
//int TABLE_count(TABLE *table);
|
|
|
|
#define TABLE_count(_table) (ARRAY_count((_table)->symbol))
|
2009-07-08 21:57:50 +02:00
|
|
|
const char *TABLE_get_symbol_name(TABLE *table, int index);
|
|
|
|
const char *TABLE_get_symbol_name_suffix(TABLE *table, int index, const char* suffix);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-25 13:19:00 +02:00
|
|
|
bool TABLE_find_symbol(TABLE *table, const char *name, int len, int *index);
|
|
|
|
bool TABLE_add_symbol(TABLE *table, const char *name, int len, int *index);
|
2009-07-08 21:57:50 +02:00
|
|
|
void TABLE_sort(TABLE *table);
|
|
|
|
void TABLE_print(TABLE *table, bool sort);
|
|
|
|
/*PUBLIC bool TABLE_copy_symbol(TABLE *dst, TABLE *src, int index_src, SYMBOL **symbol, int *index);*/
|
|
|
|
void TABLE_add_new_symbol_without_sort(TABLE *table, const char *name, int len, int sort, SYMBOL **symbol, int *index);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-06-05 01:48:53 +02:00
|
|
|
int SYMBOL_find(void *symbol, ushort *sort, int n_symbol, size_t s_symbol, int flag, const char *name, int len, const char *prefix);
|
2010-05-19 22:18:23 +02:00
|
|
|
//bool SYMBOL_find_old(void *symbol, int n_symbol, size_t s_symbol, int flag, const char *name, int len, const char *prefix, int *result);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#define TABLE_get_symbol(table, ind) ((SYMBOL *)ARRAY_get((table)->symbol, ind))
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
SYMBOL *TABLE_get_symbol_sort(TABLE *table, int index);
|
2010-05-25 13:19:00 +02:00
|
|
|
void TABLE_copy_symbol_with_prefix(TABLE *table, int ind_src, char prefix, int *index);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif
|